Open-Assistant icon indicating copy to clipboard operation
Open-Assistant copied to clipboard

Add REST endpoint to query & delete posts (messages)

Open andreaskoepf opened this issue 2 years ago • 2 comments

In the DB we are dealing with message trees. We need REST endpoints to query single messages, conversations & message-trees.

post_id here means PK of post table in db. The frontend-provided (only in combination with api_client_id unique) id will be called frontend_post_id.

Required functionality

  • query a message by post_id

  • query a message by frontend_post_id

  • query a conversation given a post_id (list of messages traced to tree-root in order (starting at root))

  • query all messages of a message tree given a post_id (lookup thread_id of message -> query whole tree) (unordered)

  • query children/descendants given a parent_post_id (with max_depth)

  • query longest conversation of a message tree (by providing a post_id of any message in the tree)

  • query messages of tree with most direct children (by providing a post_id of any message in the tree)

  • query by user_id, ordered by date with conditions: max_count (limit), after_date (optional) & before end_date (optional)

  • query by created_date, max_count (limit), start_date (optional), end_date (optional), only_roots (optional)

Only trusted api_clients:

  • delete message (e.g. by setting deleted flag to true)
  • delete all messages of a user (select all user's messages and perform delete them)
  • query stats: number of total entries in post table, number of threads (message trees)

Optional (using existing functions):

  • sample random messages
  • sample random thread

andreaskoepf avatar Dec 29 '22 20:12 andreaskoepf

change regarding delete: only flag messages as deleted, actual data removal has to be done by admins.

andreaskoepf avatar Dec 30 '22 00:12 andreaskoepf

At API surface-level the new naming scheme should be used, see #124.

andreaskoepf avatar Dec 30 '22 10:12 andreaskoepf