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