mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
drafts: Add an API endpoint for fetching drafts.
This endpoint will allow a user to fetch their drafts. Signed-off-by: Hemanth V. Alluri <hdrive1999@gmail.com>
This commit is contained in:
committed by
Tim Abbott
parent
630fd10be1
commit
21c9adbb3c
@@ -84,6 +84,11 @@ def further_validated_draft_dict(draft_dict: Dict[str, Any],
|
||||
"last_edit_time": last_edit_time,
|
||||
}
|
||||
|
||||
def fetch_drafts(request: HttpRequest, user_profile: UserProfile) -> HttpResponse:
|
||||
user_drafts = Draft.objects.filter(user_profile=user_profile).order_by("last_edit_time")
|
||||
draft_dicts = {draft.id: draft.to_dict() for draft in user_drafts}
|
||||
return json_success({"count": user_drafts.count(), "drafts": draft_dicts})
|
||||
|
||||
@has_request_variables
|
||||
def create_drafts(request: HttpRequest, user_profile: UserProfile,
|
||||
draft_dicts: List[Dict[str, Any]]=REQ("drafts",
|
||||
|
||||
Reference in New Issue
Block a user