Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UpdateReply API and replyUpdateBlocker field for reply #184

Open
MrOrz opened this issue Jul 11, 2020 · 2 comments
Open

UpdateReply API and replyUpdateBlocker field for reply #184

MrOrz opened this issue Jul 11, 2020 · 2 comments

Comments

@MrOrz
Copy link
Member

MrOrz commented Jul 11, 2020

As discussed in 20200212 meeting, we want to allow editor to edit their reply when

  • The reply is only used by the editor itself (the author should know the impact of the edit)
  • The reply has not yet received any feedback (the edit should now invalidate user's feedbacks)

We plan to add 1 mutation API, and one new field to Reply type for this:

"""
The reason why the editor cannot edit
"""
enum ReplyUpdateBlocker {
  NOT_AUTHORIZED # Not logged in or not the author of reply
  HAS_FEEDBACK
  USED_BY_OTHER_EDITORS
}

type Reply {
  """
  The reason why the current user cannot edit this reply. null if the current user can edit.

  The blockers are determined in the following order:
  (1) current user is the author or not
  (2) `positiveFeedbackCount` and `negativeFeedbackCount` are both 0 or not
  (3) all normal article-reply to this article are by the current author or not
  """
  updateBlocker: ReplyUpdateBlocker
}

mutation {
  """
  Updates reply text, type & reference when
  (1) current user is the author
  (2) `positiveFeedbackCount` and `negativeFeedbackCount` are both 0
  (3) all normal article-reply to this article are by the current author
  """
  UpdateReply(
    replyId: String!
    text: String
    type: ReplyTypeEnum
    reference: String
    waitForHyperlinks: Boolean = false
  ) {
    ""'
    The reply after update. `null` when update is not successful
    """
    reply: Reply

    """
    The reason why update fails. null when can update.
    """
    blocker: ReplyUpdateBlocker
  }
}

"all normal article-reply to this article are by the current author" can be achieved by loading article-reply of a reply using articleRepliesByReplyIdLoader and check each article-reply's author ID.

@MrOrz
Copy link
Member Author

MrOrz commented Jul 15, 2020

As discussed in https://g0v-slack-archive.g0v.ronny.tw/index/channel/C2PPMRQGP/2020-07#ts-1594556835.293700
The return type of the API can leverage union type, as Medium suggested.

@MrOrz
Copy link
Member Author

MrOrz commented Jul 15, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant