Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Failable chat messages #1093

@placer14

Description

@placer14

Chat messages are currently persisted after successfully sending the message to the remote peer. In the cases where the remote peer is offline or the node is in a high-latency environment a message may take several minutes to be successfully sent. In these cases, the chat messages appear to be persisted immediately after posting the message, but if a user were switch away and revisit the view, the recently posted message may not appear if the message has not been successfully sent at the time.

Solution:

  • we return from posting new chat messages as soon as possible (without waiting for the send to complete) ensuring that the message ID is returned in response
  • ensure the websocket returning early with the completed state of the chat request does not race the requesting call (prefer to ensure a race condition can be handled (see Add ID Parameter to Async Socket Calls #925) or design to prevent the race condition if we can't)
  • we will reorder the operations in our chat API (within {specify api endpoints to include groupchat as well as regular chat}) to persist the message to the local DB immediately regardless of the successful delivery of the message.
  • we will migrate our schema to add a failed_reason non-nullable text column to the chat DB table which describes the reason for the message delivery failure.
  • unsuccessful message delivery should populate DB record(s) w failed_reason with the cause of the failure
  • unsuccessful message delivery should generate a socket notification (body to be defined)
  • successful message delivery should generate a socket notification (body to be defined) (optional)
  • /ob/chatmessages response should include a new key to present this failed state to the UI
    {
        "message": "Tes #8",
        "messageId": "QmWepAACQP3vcoXRrhz1HNftiE5G3eRKZZtgikwnXhabUE",
        "outgoing": true,
        "peerId": "",
        "read": false,
        "failed": // string or bool?
        "subject": "QmRWDYgYTxqAJk4URoxJD2NvzkrJ3vtSWEoZY1WmS5esAs",
        "timestamp": "2018-08-16T11:38:58-04:00"
    },

UI impact:

  • Must represent failed state (and reason?) to the user
  • Must accept failure/success message delivery socket notifications
  • Must return immediately to minimize open-connections within the UI

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureFeature or enhancement to openbazaar-go

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions