Skip to main content

ably_chat_openapi/models/
message.rs

1/*
2 * Ably Chat REST API
3 *
4 * REST API for [Ably Chat](https://ably.com/docs/chat).  This specification describes the HTTP surface of the Ably Chat REST API (path prefix `/chat/v4`) that the official Chat client SDKs use for request/response operations such as sending, editing, deleting and querying messages, message reactions and room occupancy.  ## Scope & provenance Ably does **not** publish an official OpenAPI document for the Chat REST API (the official `ably/open-specs` `platform-v1.yaml` covers only the generic pub/sub REST API: `/channels`, `/push`, `/keys`, `/stats`, `/time`). This document was reconstructed from the `@ably/chat` JavaScript SDK v1.4.0 REST layer (`src/core/chat-api.ts`, `src/core/rest-types.ts`) together with Ably's documented REST conventions (host, authentication, versioning, pagination, error envelope).  It therefore covers the endpoints the client SDK exercises. It is **not** an exhaustive description of every server capability, and there are intentionally no endpoints for creating or deleting rooms: Chat rooms are channel-backed and implicit — they are not provisioned via REST.  ## Realtime vs REST Many Chat features (presence, typing indicators, room reactions, subscribing to live messages and reaction summaries) are delivered over Ably's realtime/pub-sub transport, not this REST API, and are out of scope here. 
5 *
6 * The version of the OpenAPI document: 4
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// Message : A chat message in the V4 REST representation.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct Message {
17    /// The unique identifier of the message.
18    #[serde(rename = "serial")]
19    pub serial: String,
20    #[serde(rename = "version")]
21    pub version: Box<models::MessageVersion>,
22    /// The text content of the message.
23    #[serde(rename = "text")]
24    pub text: String,
25    /// The client ID of the user who created the message.
26    #[serde(rename = "clientId")]
27    pub client_id: String,
28    #[serde(rename = "action")]
29    pub action: models::MessageAction,
30    /// Arbitrary user-defined metadata. Not interpreted or validated by Ably; treat as untrusted input when reading. 
31    #[serde(rename = "metadata")]
32    pub metadata: std::collections::HashMap<String, serde_json::Value>,
33    /// Arbitrary user-defined string headers, carried as Ably message `extras.headers`. Not interpreted or validated by Ably. 
34    #[serde(rename = "headers")]
35    pub headers: std::collections::HashMap<String, String>,
36    /// Milliseconds since the Unix epoch at which the message was created.
37    #[serde(rename = "timestamp")]
38    pub timestamp: i64,
39    /// User claim attached by the server when the publishing token contained a matching `ably.room.<roomName>` claim. Present only in that case. 
40    #[serde(rename = "userClaim", skip_serializing_if = "Option::is_none")]
41    pub user_claim: Option<String>,
42    #[serde(rename = "reactions", skip_serializing_if = "Option::is_none")]
43    pub reactions: Option<Box<models::MessageReactions>>,
44}
45
46impl Message {
47    /// A chat message in the V4 REST representation.
48    pub fn new(serial: String, version: models::MessageVersion, text: String, client_id: String, action: models::MessageAction, metadata: std::collections::HashMap<String, serde_json::Value>, headers: std::collections::HashMap<String, String>, timestamp: i64) -> Message {
49        Message {
50            serial,
51            version: Box::new(version),
52            text,
53            client_id,
54            action,
55            metadata,
56            headers,
57            timestamp,
58            user_claim: None,
59            reactions: None,
60        }
61    }
62}
63