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