xmtp / xps-gateway

XPS (XMTP Postal Service) JSON-RPC for xmtp-specific interactions with decentralized networks
https://xmtp.github.io/xps-gateway/
MIT License
2 stars 1 forks source link

JSON RPC `sendGroupMessage` #19

Closed jac18281828 closed 8 months ago

jac18281828 commented 9 months ago

Discussed in https://github.com/xmtp/xps-gateway/discussions/11

Originally posted by **jac18281828** December 19, 2023 This discussion is about establishing a new method in the messaging workflow called `sendGroupMessage`. This method will forward a signed payload to the xps-contract `MessageSender`. related to: https://github.com/xmtp/xps-contract/issues/14 # Documentation for JSON RPC Endpoint: `sendGroupMessage` ## Overview The `sendGroupMessage` method is used to send a message within a specified conversation. It is an external function that is part of a larger system managing communications between users or entities. This method requires two parameters: a unique identifier for the conversation (`conversationId`) and the message content (`payload`). ## JSON RPC Endpoint Specification #### Request: - **Method:** `POST` - **URL:** `/rpc/v1/sendGroupMessage` - **Headers:** - `Content-Type: application/json` - **Body:** - **JSON Object:** - `jsonrpc`: `"2.0"` - `method`: `"sendGroupMessage"` - `params`: Array (optional parameters as required) - `id`: Request identifier (integer or string) ### Method Name `sendGroupMessage` ### Request Parameters 1. `conversationId`: A unique identifier for the conversation. This is a 32-byte string, typically in hexadecimal format. 2. `payload`: The content of the message. This is a variable-length byte array that can hold any form of data, such as text, images, or other binary formats. 3. `sigV`: The signature V 4. `sigR`: The signature R 5. `sigS`: The signature S ### Request Format ```json { "jsonrpc": "2.0", "method": "sendGroupMessage", "params": { "conversationId": "", "payload": "", "V": "", "R": "", "S": "" }, "id": 1 } ``` - `jsonrpc`: Specifies the version of the JSON RPC protocol being used. Always "2.0". - `method`: The name of the method being called. Here it is "sendMessage". - `params`: A structured value holding the parameters necessary for the method. It contains: - `conversationId`: The unique identifier for the conversation. - `payload`: The message content in bytes. - `V`: The signature V - `R`: The signature R - `S`: The signature S - `id`: A unique identifier established by the client that must be number or string. Used for correlating the response with the request. ### Response Format The response will typically include the result of the operation or an error if the operation was unsuccessful. #### Success Response ```json { "jsonrpc": "2.0", "result": "status", "tx": "", "id": 1 } ``` - `result`: Contains data related to the success of the operation. The nature of this data can vary based on the implementation. #### Error Response ```json { "jsonrpc": "2.0", "error": { "code": , "message": "" }, "id": 1 } ``` - `error`: An object containing details about the error. - `code`: A numeric error code. - `message`: A human-readable string describing the error. ### Example Usage #### Request ```json { "jsonrpc": "2.0", "method": "sendGroupMessage", "params": { "conversationId": "0x1234abcd...", "payload": "SGVsbG8sIHdvcmxkIQ==", "V": "####", "R": "#####", "S": "#####" }, "id": 42 } ``` #### Response ```json { "jsonrpc": "2.0", "result": "Message sent successfully", "tx": "", "id": 42 } ``` ### Notes - Ensure that the `conversationId` is valid and exists in the system. - The `payload` should be properly encoded (e.g., base64) if it contains binary data. - The method must be called by an authorized entity, adhering to any authentication and authorization mechanisms in place. - The system should have proper error handling to deal with invalid requests, unauthorized access, and other potential issues. - Revert should be returned to caller as an error status
jac18281828 commented 9 months ago