Example #1
0
def profile():
    """查询用户信息
    """
    user_meta = user_service.query_user_meta(session_helper.get_uid())
    if not user_meta:
        user_meta = {
            "uid": session_helper.get_uid(),
            "cred": proto.EnumUserCred.GUEST
        }
    return result.Result.simple(obj=user_meta)
Example #2
0
def doc_post(title, source, desc):
    creator = session_helper.get_uid()
    if not user_service.query_user_meta(creator):
        raise exception.AppMissingUser()

    if not source.endswith(".zip"):
        raise exception.AppNotSupportSource()

    doc_id = doc_service.generate_doc_id()
    doc_service.post_doc(doc_id, title, source, desc, creator)
    return result.Result.simple(obj={"doc_id": doc_id})
Example #3
0
def token(path):
    uid = session_helper.get_uid()
    if not user_service.query_user_meta(uid):
        raise exception.AppMissingUser()

    actual_path = f"user/{uid}/{path}"
    upload_token = app.kodo_client.upload_token(actual_path)
    resp = {
        "token": upload_token,
        "path": actual_path,
    }
    return result.Result.simple(obj=resp)
Example #4
0
def query_doc(doc_id):
    doc_item = query_doc_meta(doc_id)
    creator = doc_item["creator"]
    doc_item["creator"] = user_service.query_user_meta(creator)
    return doc_item
Example #5
0
def list_doc(user, status, start, limit):
    page = doc_db.list_doc(user, status, start, limit)
    for item in page.items:
        creator = item["creator"]
        item["creator"] = user_service.query_user_meta(creator)
    return page
Example #6
0
File: user.py Project: lsj9383/saya
def login_as(uid):
    user_meta = user_service.query_user_meta(uid)
    if not user_meta:
        raise exception.AppMissingUser()
    session_helper.save_uid(user_meta["uid"])
    return result.Result.simple()