Skip to main content

cloudillo_types/
action_types.rs

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