Skip to main content

iris_chat_core/
actions.rs

1use crate::state::{OutgoingAttachment, Screen};
2
3#[derive(uniffi::Enum, Clone, Debug)]
4pub enum AppAction {
5    CreateAccount {
6        name: String,
7    },
8    UpdateProfileMetadata {
9        name: String,
10        picture_url: Option<String>,
11    },
12    RestoreSession {
13        owner_nsec: String,
14    },
15    RestoreAccountBundle {
16        owner_nsec: Option<String>,
17        owner_pubkey_hex: String,
18        device_nsec: String,
19    },
20    StartLinkedDevice {
21        owner_input: String,
22    },
23    AppForegrounded,
24    Logout,
25    CreateChat {
26        peer_input: String,
27    },
28    CreateGroup {
29        name: String,
30        member_inputs: Vec<String>,
31    },
32    CreateGroupWithPicture {
33        name: String,
34        member_inputs: Vec<String>,
35        picture_file_path: String,
36        picture_filename: String,
37    },
38    CreatePublicInvite,
39    AcceptInvite {
40        invite_input: String,
41    },
42    OpenChat {
43        chat_id: String,
44    },
45    SendMessage {
46        chat_id: String,
47        text: String,
48    },
49    SendDisappearingMessage {
50        chat_id: String,
51        text: String,
52        expires_at_secs: u64,
53    },
54    SetChatMessageTtl {
55        chat_id: String,
56        ttl_seconds: Option<u64>,
57    },
58    SetChatMuted {
59        chat_id: String,
60        muted: bool,
61    },
62    SetChatPinned {
63        chat_id: String,
64        pinned: bool,
65    },
66    SetChatUnread {
67        chat_id: String,
68        unread: bool,
69    },
70    SendAttachment {
71        chat_id: String,
72        file_path: String,
73        filename: String,
74        caption: String,
75    },
76    SendAttachments {
77        chat_id: String,
78        attachments: Vec<OutgoingAttachment>,
79        caption: String,
80    },
81    ToggleReaction {
82        chat_id: String,
83        message_id: String,
84        emoji: String,
85    },
86    SendTyping {
87        chat_id: String,
88    },
89    StopTyping {
90        chat_id: String,
91    },
92    SetTypingIndicatorsEnabled {
93        enabled: bool,
94    },
95    SetReadReceiptsEnabled {
96        enabled: bool,
97    },
98    SetDesktopNotificationsEnabled {
99        enabled: bool,
100    },
101    SetInviteAcceptanceNotificationsEnabled {
102        enabled: bool,
103    },
104    SetStartupAtLoginEnabled {
105        enabled: bool,
106    },
107    SetNearbyEnabled {
108        enabled: bool,
109    },
110    SetNearbyBluetoothEnabled {
111        enabled: bool,
112    },
113    SetNearbyLanEnabled {
114        enabled: bool,
115    },
116    SetDebugLoggingEnabled {
117        enabled: bool,
118    },
119    SetAcceptUnknownDirectMessages {
120        enabled: bool,
121    },
122    /// Block / unblock a peer owner (Signal-style global blocklist).
123    /// When blocked, the core drops the peer from both the nostr
124    /// relay subscription and the mobile push subscription, refuses
125    /// outgoing sends, and hides their thread / discards their
126    /// incoming messages.
127    SetUserBlocked {
128        owner_pubkey_hex: String,
129        blocked: bool,
130    },
131    /// Mark a direct chat's peer as accepted (Signal whitelist). The
132    /// projection's `is_request` flag flips to false. Sending the
133    /// first outgoing message also implicitly accepts.
134    SetMessageRequestAccepted {
135        chat_id: String,
136    },
137    /// Pause / resume the nearby mailbag's store-and-forward writer
138    /// and reader. The bag's existing contents survive the toggle so
139    /// the user can flip it back on without losing what was queued;
140    /// wiping is a separate, shell-local "Empty mailbag" action that
141    /// targets the platform's nearby service directly.
142    SetNearbyMailbagEnabled {
143        enabled: bool,
144    },
145    AddNostrRelay {
146        relay_url: String,
147    },
148    UpdateNostrRelay {
149        old_relay_url: String,
150        new_relay_url: String,
151    },
152    RemoveNostrRelay {
153        relay_url: String,
154    },
155    SetNostrRelays {
156        relay_urls: Vec<String>,
157    },
158    ResetNostrRelays,
159    SetImageProxyEnabled {
160        enabled: bool,
161    },
162    SetImageProxyUrl {
163        url: String,
164    },
165    SetImageProxyKeyHex {
166        key_hex: String,
167    },
168    SetImageProxySaltHex {
169        salt_hex: String,
170    },
171    ResetImageProxySettings,
172    SetMobilePushServerUrl {
173        url: String,
174    },
175    ResetMobilePushServerUrl,
176    IngestMobilePushPayload {
177        payload_json: String,
178    },
179    MarkMessagesSeen {
180        chat_id: String,
181        message_ids: Vec<String>,
182    },
183    SendReceipt {
184        chat_id: String,
185        receipt_type: String,
186        message_ids: Vec<String>,
187    },
188    DeleteLocalMessage {
189        chat_id: String,
190        message_id: String,
191    },
192    DeleteChat {
193        chat_id: String,
194    },
195    UpdateGroupName {
196        group_id: String,
197        name: String,
198    },
199    UpdateGroupPicture {
200        group_id: String,
201        file_path: String,
202        filename: String,
203    },
204    AddGroupMembers {
205        group_id: String,
206        member_inputs: Vec<String>,
207    },
208    SetGroupAdmin {
209        group_id: String,
210        owner_pubkey_hex: String,
211        is_admin: bool,
212    },
213    RemoveGroupMember {
214        group_id: String,
215        owner_pubkey_hex: String,
216    },
217    UploadProfilePicture {
218        file_path: String,
219    },
220    AddAuthorizedDevice {
221        device_input: String,
222    },
223    RemoveAuthorizedDevice {
224        device_pubkey_hex: String,
225    },
226    AcknowledgeRevokedDevice,
227    PushScreen {
228        screen: Screen,
229    },
230    UpdateScreenStack {
231        stack: Vec<Screen>,
232    },
233    // Pop the top of the navigation stack. Replaces "UI reads the
234    // stack, computes the pop, dispatches UpdateScreenStack with the
235    // new array" — the core owns the screen stack, the UI just signals
236    // the intent. Appended at the end of the enum so adding it doesn't
237    // shift existing variants' uniffi tags on still-stale bindings.
238    NavigateBack,
239    /// Persist the unsent composer text for a chat. Shells dispatch
240    /// this on composer change (debounced) and on send-or-leave so
241    /// the draft survives navigation, app suspend, and relaunch —
242    /// same shape as Signal's `updateWithDraft`. Empty string clears.
243    SetChatDraft {
244        chat_id: String,
245        text: String,
246    },
247    /// Publish a blank owner metadata event so public profile name/photo are
248    /// cleared before the shell removes local keys and data.
249    DeleteProfileMetadata,
250}