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    SetAcceptSocialGraphDirectMessages {
238        enabled: bool,
239    },
240    SetAcceptOvermutedDirectMessages {
241        enabled: bool,
242    },
243    SetAcceptUnknownDirectMessages {
244        enabled: bool,
245    },
246    /// Block / unblock a peer owner (Signal-style global blocklist).
247    /// When blocked, the core drops the peer from both the nostr
248    /// relay subscription and the mobile push subscription, refuses
249    /// outgoing sends, and hides their thread / discards their
250    /// incoming messages.
251    SetUserBlocked {
252        owner_pubkey_hex: String,
253        blocked: bool,
254    },
255    /// Mark a direct chat's peer as accepted (Signal whitelist). The
256    /// projection's `is_request` flag flips to false. Sending the
257    /// first outgoing message also implicitly accepts.
258    SetMessageRequestAccepted {
259        chat_id: String,
260    },
261    /// Pause / resume the nearby mailbag's store-and-forward writer
262    /// and reader. The bag's existing contents survive the toggle so
263    /// the user can flip it back on without losing what was queued;
264    /// wiping is a separate, shell-local "Empty mailbag" action that
265    /// targets the platform's nearby service directly.
266    SetNearbyMailbagEnabled {
267        enabled: bool,
268    },
269    SetNearbyShowInChatList {
270        enabled: bool,
271    },
272    AddNostrRelay {
273        relay_url: String,
274    },
275    UpdateNostrRelay {
276        old_relay_url: String,
277        new_relay_url: String,
278    },
279    RemoveNostrRelay {
280        relay_url: String,
281    },
282    SetNostrRelays {
283        relay_urls: Vec<String>,
284    },
285    ResetNostrRelays,
286    SetImageProxyEnabled {
287        enabled: bool,
288    },
289    SetImageProxyFallbackEnabled {
290        enabled: bool,
291    },
292    SetImageProxyUrl {
293        url: String,
294    },
295    SetImageProxyKeyHex {
296        key_hex: String,
297    },
298    SetImageProxySaltHex {
299        salt_hex: String,
300    },
301    ResetImageProxySettings,
302    SetMobilePushServerUrl {
303        url: String,
304    },
305    ResetMobilePushServerUrl,
306    IngestMobilePushPayload {
307        payload_json: String,
308    },
309    MarkMessagesSeen {
310        chat_id: String,
311        message_ids: Vec<String>,
312    },
313    SendReceipt {
314        chat_id: String,
315        receipt_type: String,
316        message_ids: Vec<String>,
317    },
318    EditMessage {
319        chat_id: String,
320        message_id: String,
321        text: String,
322    },
323    DeleteMessageForEveryone {
324        chat_id: String,
325        message_id: String,
326    },
327    SetHideBlockedGroupMessages {
328        enabled: bool,
329    },
330    SetAllowMessageDeletionByOthers {
331        enabled: bool,
332    },
333    DeleteLocalMessage {
334        chat_id: String,
335        message_id: String,
336    },
337    DeleteChat {
338        chat_id: String,
339    },
340    UpdateGroupName {
341        group_id: String,
342        name: String,
343    },
344    UpdateGroupPicture {
345        group_id: String,
346        file_path: String,
347        filename: String,
348    },
349    /// Admin: set or clear the group's free-text description (Signal's group
350    /// description). `None` clears.
351    UpdateGroupAbout {
352        group_id: String,
353        about: Option<String>,
354    },
355    AddGroupMembers {
356        group_id: String,
357        member_inputs: Vec<String>,
358    },
359    SetGroupAdmin {
360        group_id: String,
361        owner_pubkey_hex: String,
362        is_admin: bool,
363    },
364    RemoveGroupMember {
365        group_id: String,
366        owner_pubkey_hex: String,
367    },
368    UploadProfilePicture {
369        file_path: String,
370    },
371    AddAuthorizedDevice {
372        device_input: String,
373    },
374    AddAuthorizedDeviceWithHistory {
375        device_input: String,
376        include_message_history: bool,
377    },
378    RemoveAuthorizedDevice {
379        device_pubkey_hex: String,
380    },
381    AcknowledgeRevokedDevice,
382    PushScreen {
383        screen: Screen,
384    },
385    UpdateScreenStack {
386        stack: Vec<Screen>,
387    },
388    // Pop the top of the navigation stack. Replaces "UI reads the
389    // stack, computes the pop, dispatches UpdateScreenStack with the
390    // new array" — the core owns the screen stack, the UI just signals
391    // the intent. Appended at the end of the enum so adding it doesn't
392    // shift existing variants' uniffi tags on still-stale bindings.
393    NavigateBack,
394    /// Persist the unsent composer text for a chat. Shells dispatch
395    /// this on composer change (debounced) and on send-or-leave so
396    /// the draft survives navigation, app suspend, and relaunch —
397    /// same shape as Signal's `updateWithDraft`. Empty string clears.
398    SetChatDraft {
399        chat_id: String,
400        text: String,
401    },
402    /// Publish a blank owner metadata event so public profile name/photo are
403    /// cleared before the shell removes local keys and data.
404    DeleteProfileMetadata,
405    /// Set or clear a local nickname for a contact. Appended at the end of
406    /// the enum so adding it doesn't shift existing variants' uniffi tags
407    /// on still-stale bindings.
408    SetContactNickname {
409        owner_pubkey_hex: String,
410        nickname: String,
411    },
412    /// Private contact details, shared only with this account's linked devices.
413    SetContactDetails {
414        owner_pubkey_hex: String,
415        nickname: String,
416        note: String,
417    },
418}