Skip to main content

cloudillo_types/
action_types.rs

1//! Action-related types shared between server and adapters.
2
3use serde::{Deserialize, Serialize};
4use serde_with::skip_serializing_none;
5
6use crate::types::Timestamp;
7
8pub use crate::auth_adapter::ACCESS_TOKEN_EXPIRY;
9
10#[skip_serializing_none]
11#[derive(Debug, Default, Clone, Serialize, Deserialize)]
12pub struct CreateAction {
13	#[serde(rename = "type")]
14	pub typ: Box<str>,
15	#[serde(rename = "subType")]
16	pub sub_typ: Option<Box<str>>,
17	#[serde(rename = "parentId")]
18	pub parent_id: Option<Box<str>>,
19	#[serde(rename = "audienceTag")]
20	pub audience_tag: Option<Box<str>>,
21	pub content: Option<serde_json::Value>,
22	pub attachments: Option<Vec<Box<str>>>,
23	pub subject: Option<Box<str>>,
24	#[serde(rename = "expiresAt")]
25	pub expires_at: Option<Timestamp>,
26	pub visibility: Option<char>,
27	/// Action flags (R/r=reactions, C/c=comments, O/o=open)
28	pub flags: Option<Box<str>>,
29	/// Extensible metadata (stored in x column, not in JWT)
30	/// Used for server-side data like x.role for SUBS actions
31	pub x: Option<serde_json::Value>,
32	/// If true, create as draft instead of publishing immediately
33	pub draft: Option<bool>,
34	/// Scheduled publish time (implies draft=true). Sets created_at to this time.
35	#[serde(rename = "publishAt")]
36	pub publish_at: Option<Timestamp>,
37}
38
39/// Action status codes for tracking action lifecycle state
40pub mod status {
41	/// Active/Accepted/Approved - Unified status for actions in good standing
42	/// Used for: new actions, manually accepted actions, auto-approved actions
43	pub const ACTIVE: char = 'A';
44
45	/// Confirmation required - Action awaits user decision (accept/reject)
46	/// Used for: CONN requests without mutual, FSHR file shares
47	pub const CONFIRMATION: char = 'C';
48
49	/// Notification - Auto-processed, informational only
50	/// Used for: mutual CONN auto-accepted, REACT notifications
51	pub const NOTIFICATION: char = 'N';
52
53	/// Deleted/Rejected - Action was rejected or deleted
54	/// Used for: rejected requests, deleted content
55	pub const DELETED: char = 'D';
56
57	/// Draft - Action is a draft, not yet published
58	/// Used for: drafts that can be edited before publishing
59	pub const DRAFT: char = 'R';
60
61	/// Scheduled - Draft with a scheduled publish time
62	/// Used for: drafts that will auto-publish at a future time
63	pub const SCHEDULED: char = 'S';
64}
65
66// vim: ts=4