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    SetPublicFollow {
6        owner_pubkey_hex: String,
7        following: bool,
8    },
9    ApproveContactName {
10        owner_pubkey_hex: String,
11        name: String,
12    },
13    SetContactFavorite {
14        owner_pubkey_hex: String,
15        favorite: bool,
16    },
17    StartCall {
18        chat_id: String,
19        video: bool,
20    },
21    AnswerCall {
22        call_id: String,
23    },
24    AnswerCallWithVoice {
25        call_id: String,
26    },
27    EndCall {
28        call_id: String,
29    },
30    SetCallMuted {
31        muted: bool,
32    },
33    SetCallVideoEnabled {
34        enabled: bool,
35    },
36    SendCallMedia {
37        call_id: String,
38        kind: u8,
39        timestamp_us: u64,
40        key_frame: bool,
41        data: Vec<u8>,
42    },
43    RequestCallKeyFrame {
44        call_id: String,
45    },
46    SetCallMediaConnected {
47        call_id: String,
48        connected: bool,
49    },
50    SetCallQuality {
51        quality: String,
52        max_bitrate_bps: u32,
53    },
54    SetVoiceCallsEnabled {
55        enabled: bool,
56    },
57    SetVideoCallsEnabled {
58        enabled: bool,
59    },
60    CreateAccount {
61        name: String,
62    },
63    UpdateProfileMetadata {
64        name: String,
65        picture_url: Option<String>,
66        about: Option<String>,
67    },
68    RestoreSession {
69        owner_nsec: String,
70    },
71    RestoreAccountBundle {
72        owner_nsec: Option<String>,
73        owner_pubkey_hex: String,
74        device_nsec: String,
75    },
76    RestorePendingDeviceLink {
77        device_nsec: String,
78        approval_bootstrap_json: String,
79    },
80    StartRemoteSignerLogin,
81    ConnectRemoteSigner {
82        connection_uri: String,
83    },
84    CancelRemoteSignerLogin,
85    BeginSignerLogin {
86        owner_pubkey_hex: String,
87    },
88    CompleteSignerLogin {
89        request_id: String,
90        signed_event_json: String,
91    },
92    CancelSignerLogin {
93        request_id: String,
94    },
95    StartLinkedDevice {
96        owner_input: String,
97    },
98    SetCurrentDeviceLabels {
99        device_label: String,
100        client_label: String,
101    },
102    AppForegrounded,
103    /// Hide the UI while an Android foreground service keeps receiving.
104    AppBackgrounded,
105    Logout,
106    CreateChat {
107        peer_input: String,
108    },
109    CreateGroup {
110        name: String,
111        member_inputs: Vec<String>,
112    },
113    CreateGroupWithPicture {
114        name: String,
115        member_inputs: Vec<String>,
116        picture_file_path: String,
117        picture_filename: String,
118    },
119    CreatePublicInvite,
120    CreateFullInvite,
121    CreateGroupInvite {
122        group_id: String,
123        max_uses: Option<u32>,
124        expires_in_seconds: Option<u64>,
125    },
126    RevokeGroupInvite {
127        group_id: String,
128        invite_id: String,
129    },
130    SetInviteOpenOnJoin {
131        enabled: bool,
132    },
133    AcceptInvite {
134        invite_input: String,
135    },
136    OpenChat {
137        chat_id: String,
138    },
139    RetryDirectChatCapability {
140        chat_id: String,
141    },
142    SendMessage {
143        chat_id: String,
144        text: String,
145    },
146    SendDisappearingMessage {
147        chat_id: String,
148        text: String,
149        expires_at_secs: u64,
150    },
151    SetChatMessageTtl {
152        chat_id: String,
153        ttl_seconds: Option<u64>,
154    },
155    SetChatMuted {
156        chat_id: String,
157        muted: bool,
158    },
159    SetChatMuteUntil {
160        chat_id: String,
161        until_secs: u64,
162    },
163    SetChatMentionNotifications {
164        chat_id: String,
165        enabled: bool,
166    },
167    SetChatPinned {
168        chat_id: String,
169        pinned: bool,
170    },
171    SetChatUnread {
172        chat_id: String,
173        unread: bool,
174    },
175    SendAttachment {
176        chat_id: String,
177        file_path: String,
178        filename: String,
179        caption: String,
180    },
181    SendAttachments {
182        chat_id: String,
183        attachments: Vec<OutgoingAttachment>,
184        caption: String,
185    },
186    SendDirectFiles {
187        chat_id: String,
188        attachments: Vec<OutgoingAttachment>,
189        caption: String,
190    },
191    DeclineDirectFiles {
192        chat_id: String,
193        transfer_id: String,
194    },
195    CancelDirectFiles {
196        chat_id: String,
197        transfer_id: String,
198    },
199    ToggleReaction {
200        chat_id: String,
201        message_id: String,
202        emoji: String,
203    },
204    SendTyping {
205        chat_id: String,
206    },
207    StopTyping {
208        chat_id: String,
209    },
210    SetTypingIndicatorsEnabled {
211        enabled: bool,
212    },
213    SetReadReceiptsEnabled {
214        enabled: bool,
215    },
216    SetDesktopNotificationsEnabled {
217        enabled: bool,
218    },
219    SetInviteAcceptanceNotificationsEnabled {
220        enabled: bool,
221    },
222    SetStartupAtLoginEnabled {
223        enabled: bool,
224    },
225    SetNearbyEnabled {
226        enabled: bool,
227    },
228    SetNearbyBluetoothEnabled {
229        enabled: bool,
230    },
231    SetNearbyLanEnabled {
232        enabled: bool,
233    },
234    SetDebugLoggingEnabled {
235        enabled: bool,
236    },
237    SetAcceptUnknownDirectMessages {
238        enabled: bool,
239    },
240    /// Block / unblock a peer owner (Signal-style global blocklist).
241    /// When blocked, the core drops the peer from both the nostr
242    /// relay subscription and the mobile push subscription, refuses
243    /// outgoing sends, and hides their thread / discards their
244    /// incoming messages.
245    SetUserBlocked {
246        owner_pubkey_hex: String,
247        blocked: bool,
248    },
249    /// Mark a direct chat's peer as accepted (Signal whitelist). The
250    /// projection's `is_request` flag flips to false. Sending the
251    /// first outgoing message also implicitly accepts.
252    SetMessageRequestAccepted {
253        chat_id: String,
254    },
255    /// Pause / resume the nearby mailbag's store-and-forward writer
256    /// and reader. The bag's existing contents survive the toggle so
257    /// the user can flip it back on without losing what was queued;
258    /// wiping is a separate, shell-local "Empty mailbag" action that
259    /// targets the platform's nearby service directly.
260    SetNearbyMailbagEnabled {
261        enabled: bool,
262    },
263    SetNearbyShowInChatList {
264        enabled: bool,
265    },
266    AddNostrRelay {
267        relay_url: String,
268    },
269    UpdateNostrRelay {
270        old_relay_url: String,
271        new_relay_url: String,
272    },
273    RemoveNostrRelay {
274        relay_url: String,
275    },
276    SetNostrRelays {
277        relay_urls: Vec<String>,
278    },
279    ResetNostrRelays,
280    SetImageProxyEnabled {
281        enabled: bool,
282    },
283    SetImageProxyFallbackEnabled {
284        enabled: bool,
285    },
286    SetImageProxyUrl {
287        url: String,
288    },
289    SetImageProxyKeyHex {
290        key_hex: String,
291    },
292    SetImageProxySaltHex {
293        salt_hex: String,
294    },
295    ResetImageProxySettings,
296    SetMobilePushServerUrl {
297        url: String,
298    },
299    ResetMobilePushServerUrl,
300    IngestMobilePushPayload {
301        payload_json: String,
302    },
303    MarkMessagesSeen {
304        chat_id: String,
305        message_ids: Vec<String>,
306    },
307    SendReceipt {
308        chat_id: String,
309        receipt_type: String,
310        message_ids: Vec<String>,
311    },
312    EditMessage {
313        chat_id: String,
314        message_id: String,
315        text: String,
316    },
317    DeleteMessageForEveryone {
318        chat_id: String,
319        message_id: String,
320    },
321    SetHideBlockedGroupMessages {
322        enabled: bool,
323    },
324    SetAllowMessageDeletionByOthers {
325        enabled: bool,
326    },
327    DeleteLocalMessage {
328        chat_id: String,
329        message_id: String,
330    },
331    DeleteChat {
332        chat_id: String,
333    },
334    UpdateGroupName {
335        group_id: String,
336        name: String,
337    },
338    UpdateGroupPicture {
339        group_id: String,
340        file_path: String,
341        filename: String,
342    },
343    /// Admin: set or clear the group's free-text description (Signal's group
344    /// description). `None` clears.
345    UpdateGroupAbout {
346        group_id: String,
347        about: Option<String>,
348    },
349    AddGroupMembers {
350        group_id: String,
351        member_inputs: Vec<String>,
352    },
353    SetGroupAdmin {
354        group_id: String,
355        owner_pubkey_hex: String,
356        is_admin: bool,
357    },
358    RemoveGroupMember {
359        group_id: String,
360        owner_pubkey_hex: String,
361    },
362    UploadProfilePicture {
363        file_path: String,
364    },
365    AddAuthorizedDevice {
366        device_input: String,
367    },
368    AddAuthorizedDeviceWithHistory {
369        device_input: String,
370        include_message_history: bool,
371    },
372    RemoveAuthorizedDevice {
373        device_pubkey_hex: String,
374    },
375    AcknowledgeRevokedDevice,
376    PushScreen {
377        screen: Screen,
378    },
379    UpdateScreenStack {
380        stack: Vec<Screen>,
381    },
382    // Pop the top of the navigation stack. Replaces "UI reads the
383    // stack, computes the pop, dispatches UpdateScreenStack with the
384    // new array" — the core owns the screen stack, the UI just signals
385    // the intent. Appended at the end of the enum so adding it doesn't
386    // shift existing variants' uniffi tags on still-stale bindings.
387    NavigateBack,
388    /// Persist the unsent composer text for a chat. Shells dispatch
389    /// this on composer change (debounced) and on send-or-leave so
390    /// the draft survives navigation, app suspend, and relaunch —
391    /// same shape as Signal's `updateWithDraft`. Empty string clears.
392    SetChatDraft {
393        chat_id: String,
394        text: String,
395    },
396    /// Publish a blank owner metadata event so public profile name/photo are
397    /// cleared before the shell removes local keys and data.
398    DeleteProfileMetadata,
399    /// Set or clear a local nickname for a contact. Appended at the end of
400    /// the enum so adding it doesn't shift existing variants' uniffi tags
401    /// on still-stale bindings.
402    SetContactNickname {
403        owner_pubkey_hex: String,
404        nickname: String,
405    },
406    /// Private contact details, shared only with this account's linked devices.
407    SetContactDetails {
408        owner_pubkey_hex: String,
409        nickname: String,
410        note: String,
411    },
412}