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

Editing Messages 409 Conflict #414

Open
tance77 opened this issue Oct 15, 2024 · 3 comments
Open

Editing Messages 409 Conflict #414

tance77 opened this issue Oct 15, 2024 · 3 comments
Assignees
Labels
priority: medium This PR should be reviewed after all high priority PRs. status: waiting This issue waits for feedback from author. type: question This issue is a question.

Comments

@tance77
Copy link

tance77 commented Oct 15, 2024

When editing a message I’ve noticed an issue: going from the message text A to B and then back to A causes a 409 conflict error. However, if I edit from A to B, then to C, and finally back to A, there’s no conflict. This behavior is confusing—why does the system only check the previous action?

Function that we're having issues with:

https://github.com/pubnub/js-chat/blob/master/lib/src/entities/message.ts#L202

What would be the best way to work around this behavior when editing a message?

Idea 1:

We could delete all actions following the conflict, but the time token would not update.

Idea 2:

Delete all the edit actions, but then changes in the UI flash from A to EMPTY to B to EMPTY to A

@parfeon
Copy link
Contributor

parfeon commented Oct 15, 2024

@tance77 thank you for reaching out.

I tried to reproduce the ABCA flow and the last step gave me a conflict error (tried with regular REST API).

As for a potential workaround (will suggest it to the Chat team because the Core SDK developed by another team) could be:

  1. edit text
  2. do nothing on success
  3. on error:
    1. fetch reactions for message
    2. find edit action with value which has been used with failed edit
    3. delete reaction with previous edit
    4. re-send edit, which should be successful this time.

Because of complexity and potential errors (if any, structure will change in published reactions) it probably would be better to do as part of editText function call inside of Chat JS SDK.

@tance77
Copy link
Author

tance77 commented Oct 15, 2024

@parfeon Thanks for the solution—it works!

I'm still a bit confused, though, about why a conflict occurs when the time tokens differ, but the content is the same. Shouldn't that be valid? Or, better yet, what's the reasoning behind it being considered a conflict?

@parfeon
Copy link
Contributor

parfeon commented Oct 17, 2024

@tance77 the Chat SDK team is going to try to assess this improvement suggestion and add it to their backlog (maybe they will implement it differently or our endpoints will evolve to that time).

@parfeon parfeon self-assigned this Oct 29, 2024
@parfeon parfeon added status: waiting This issue waits for feedback from author. type: question This issue is a question. priority: medium This PR should be reviewed after all high priority PRs. labels Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium This PR should be reviewed after all high priority PRs. status: waiting This issue waits for feedback from author. type: question This issue is a question.
Projects
None yet
Development

No branches or pull requests

2 participants