Skip to content

Add ConversationPartController with update endpoint #1292

@begedin

Description

@begedin

Problem

See #1286 for an explanation of how a Message system works.

Once we have created a Message and it's associated Conversation, any side of the conversation can post a reply.

Each of these replies then creates a ConversationPart containing its contents.

Since editing would be part of the expected flow, we need an edit endpoint. It's likely not of highest priority, though

Subtasks

  • implement update_changeset
    • we keep putting this into the schema module, but I really think that does not fit well with the context paradigm, so I'm open to suggestions on where to put it. I'm thinking Messages.ConversationPart. Could even be private
    • casts [:body, :read_at]
    • if no :read_at value provided, set to current timestamp
  • test update_changeset, or testing Messages.update_conversation_part/2 might be enough
  • implement Policy.ConversationPart.update?
    • current_user is authorized if current_user.id == record.author_id
  • write tests for Policy.ConversationPart.update?
  • implement Messages.update_conversation_part(record, params)
    • probably delegates to Messages.ConversationPart.update/2
    • uses update_changeset
  • test Messages.update_conversation_part(record, params)
    • if update_changeset is private, make sure to test casting behavior to
  • implement ConversationPartController :update endpoint
    • fetches by id
    • authorizes using policy
    • updates record using Messages.update_conversation_part/2
  • write tests for :update endpoint

Questions

Do we want to allow editing old parts? Are there any restrictions?

I'm thinking we disable it in the client UI (only the last item can be edited by the author of it), and additionally, add a validation to the update changeset to prevent further editing through direct requests.

References

Requires work on #1278, #1286 to be merged before work here can be done

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions