1use super::*;
2use crate::utils::CommandSyntax;
3
4#[derive(Debug, Clone, PartialEq)]
20#[cfg_attr(feature = "bon", derive(::bon::Builder))]
21pub struct ApiCreateMyAddress {
22 pub user_id: i64,
23}
24
25impl CommandSyntax for ApiCreateMyAddress {
26 fn interpret(&self) -> String {
27 let mut buf = String::with_capacity(64);
28 buf.push_str("/_address ");
29 buf.push_str(&self.user_id.to_string());
30 buf
31 }
32}
33
34#[derive(Debug, Clone, PartialEq)]
50#[cfg_attr(feature = "bon", derive(::bon::Builder))]
51pub struct ApiDeleteMyAddress {
52 pub user_id: i64,
53}
54
55impl CommandSyntax for ApiDeleteMyAddress {
56 fn interpret(&self) -> String {
57 let mut buf = String::with_capacity(64);
58 buf.push_str("/_delete_address ");
59 buf.push_str(&self.user_id.to_string());
60 buf
61 }
62}
63
64#[derive(Debug, Clone, PartialEq)]
80#[cfg_attr(feature = "bon", derive(::bon::Builder))]
81pub struct ApiShowMyAddress {
82 pub user_id: i64,
83}
84
85impl CommandSyntax for ApiShowMyAddress {
86 fn interpret(&self) -> String {
87 let mut buf = String::with_capacity(64);
88 buf.push_str("/_show_address ");
89 buf.push_str(&self.user_id.to_string());
90 buf
91 }
92}
93
94#[derive(Debug, Clone, PartialEq)]
110#[cfg_attr(feature = "bon", derive(::bon::Builder))]
111pub struct ApiSetProfileAddress {
112 pub user_id: i64,
113 pub enable: bool,
114}
115
116impl CommandSyntax for ApiSetProfileAddress {
117 fn interpret(&self) -> String {
118 let mut buf = String::with_capacity(64);
119 buf.push_str("/_profile_address ");
120 buf.push_str(&self.user_id.to_string());
121 buf.push(' ');
122 if self.enable {
123 buf.push_str("on");
124 } else {
125 buf.push_str("off");
126 }
127 buf
128 }
129}
130
131#[derive(Debug, Clone, PartialEq)]
147#[cfg_attr(feature = "bon", derive(::bon::Builder))]
148pub struct ApiSetAddressSettings {
149 pub user_id: i64,
150 pub settings: AddressSettings,
151}
152
153impl CommandSyntax for ApiSetAddressSettings {
154 fn interpret(&self) -> String {
155 let mut buf = String::with_capacity(1024);
156 buf.push_str("/_address_settings ");
157 buf.push_str(&self.user_id.to_string());
158 buf.push(' ');
159 buf.push_str(&serde_json::to_string(&self.settings).unwrap());
160 buf
161 }
162}
163
164#[derive(Debug, Clone, PartialEq)]
180#[cfg_attr(feature = "bon", derive(::bon::Builder))]
181pub struct ApiSendMessages {
182 pub send_ref: ChatRef,
183 pub live_message: bool,
184 pub ttl: Option<i32>,
185 pub composed_messages: Vec<ComposedMessage>,
186}
187
188impl CommandSyntax for ApiSendMessages {
189 fn interpret(&self) -> String {
190 let mut buf = String::with_capacity(1024);
191 buf.push_str("/_send ");
192 buf.push_str(&self.send_ref.interpret());
193 if self.live_message {
194 buf.push(' ');
195 buf.push_str("live=");
196 buf.push_str("on");
197 }
198 if let Some(ttl) = &self.ttl {
199 buf.push(' ');
200 buf.push_str("ttl=");
201 buf.push_str(&ttl.to_string());
202 }
203 buf.push(' ');
204 buf.push_str("json ");
205 buf.push_str(&serde_json::to_string(&self.composed_messages).unwrap());
206 buf
207 }
208}
209
210#[derive(Debug, Clone, PartialEq)]
226#[cfg_attr(feature = "bon", derive(::bon::Builder))]
227pub struct ApiUpdateChatItem {
228 pub chat_ref: ChatRef,
229 pub chat_item_id: i64,
230 pub live_message: bool,
231 pub updated_message: UpdatedMessage,
232}
233
234impl CommandSyntax for ApiUpdateChatItem {
235 fn interpret(&self) -> String {
236 let mut buf = String::with_capacity(1024);
237 buf.push_str("/_update ");
238 buf.push_str("item ");
239 buf.push_str(&self.chat_ref.interpret());
240 buf.push(' ');
241 buf.push_str(&self.chat_item_id.to_string());
242 if self.live_message {
243 buf.push(' ');
244 buf.push_str("live=");
245 buf.push_str("on");
246 }
247 buf.push(' ');
248 buf.push_str("json ");
249 buf.push_str(&serde_json::to_string(&self.updated_message).unwrap());
250 buf
251 }
252}
253
254#[derive(Debug, Clone, PartialEq)]
270#[cfg_attr(feature = "bon", derive(::bon::Builder))]
271pub struct ApiDeleteChatItem {
272 pub chat_ref: ChatRef,
273 pub chat_item_ids: Vec<i64>,
274 pub delete_mode: CIDeleteMode,
275}
276
277impl CommandSyntax for ApiDeleteChatItem {
278 fn interpret(&self) -> String {
279 let mut buf = String::with_capacity(256);
280 buf.push_str("/_delete ");
281 buf.push_str("item ");
282 buf.push_str(&self.chat_ref.interpret());
283 buf.push(' ');
284 let mut iter = self.chat_item_ids.iter();
285 if let Some(el) = iter.next() {
286 buf.push_str(&el.to_string());
287 }
288 for el in iter {
289 buf.push(',');
290 buf.push_str(&el.to_string());
291 }
292 buf.push(' ');
293 match self.delete_mode {
294 CIDeleteMode::Broadcast => {
295 buf.push_str("broadcast");
296 }
297 CIDeleteMode::Internal => {
298 buf.push_str("internal");
299 }
300 CIDeleteMode::InternalMark => {
301 buf.push_str("internalMark");
302 }
303 }
304 buf
305 }
306}
307
308#[derive(Debug, Clone, PartialEq)]
324#[cfg_attr(feature = "bon", derive(::bon::Builder))]
325pub struct ApiDeleteMemberChatItem {
326 pub group_id: i64,
327 pub chat_item_ids: Vec<i64>,
328}
329
330impl CommandSyntax for ApiDeleteMemberChatItem {
331 fn interpret(&self) -> String {
332 let mut buf = String::with_capacity(256);
333 buf.push_str("/_delete ");
334 buf.push_str("member ");
335 buf.push_str("item ");
336 buf.push('#');
337 buf.push_str(&self.group_id.to_string());
338 buf.push(' ');
339 let mut iter = self.chat_item_ids.iter();
340 if let Some(el) = iter.next() {
341 buf.push_str(&el.to_string());
342 }
343 for el in iter {
344 buf.push(',');
345 buf.push_str(&el.to_string());
346 }
347 buf
348 }
349}
350
351#[derive(Debug, Clone, PartialEq)]
367#[cfg_attr(feature = "bon", derive(::bon::Builder))]
368pub struct ApiChatItemReaction {
369 pub chat_ref: ChatRef,
370 pub chat_item_id: i64,
371 pub add: bool,
372 pub reaction: MsgReaction,
373}
374
375impl CommandSyntax for ApiChatItemReaction {
376 fn interpret(&self) -> String {
377 let mut buf = String::with_capacity(1024);
378 buf.push_str("/_reaction ");
379 buf.push_str(&self.chat_ref.interpret());
380 buf.push(' ');
381 buf.push_str(&self.chat_item_id.to_string());
382 buf.push(' ');
383 if self.add {
384 buf.push_str("on");
385 } else {
386 buf.push_str("off");
387 }
388 buf.push(' ');
389 buf.push_str(&serde_json::to_string(&self.reaction).unwrap());
390 buf
391 }
392}
393
394#[derive(Debug, Clone, PartialEq)]
410#[cfg_attr(feature = "bon", derive(::bon::Builder))]
411pub struct ReceiveFile {
412 pub file_id: i64,
413 pub user_approved_relays: bool,
414 pub store_encrypted: Option<bool>,
415 pub file_inline: Option<bool>,
416 pub file_path: Option<String>,
417}
418
419impl CommandSyntax for ReceiveFile {
420 fn interpret(&self) -> String {
421 let mut buf = String::with_capacity(256);
422 buf.push_str("/freceive ");
423 buf.push_str(&self.file_id.to_string());
424 if self.user_approved_relays {
425 buf.push(' ');
426 buf.push_str("approved_relays=");
427 buf.push_str("on");
428 }
429 if let Some(store_encrypted) = &self.store_encrypted {
430 buf.push(' ');
431 buf.push_str("encrypt=");
432 if *store_encrypted {
433 buf.push_str("on");
434 } else {
435 buf.push_str("off");
436 }
437 }
438 if let Some(file_inline) = &self.file_inline {
439 buf.push(' ');
440 buf.push_str("inline=");
441 if *file_inline {
442 buf.push_str("on");
443 } else {
444 buf.push_str("off");
445 }
446 }
447 if let Some(file_path) = &self.file_path {
448 buf.push(' ');
449 buf.push_str(&file_path.to_string());
450 }
451 buf
452 }
453}
454
455#[derive(Debug, Clone, PartialEq)]
471#[cfg_attr(feature = "bon", derive(::bon::Builder))]
472pub struct CancelFile {
473 pub file_id: i64,
474}
475
476impl CommandSyntax for CancelFile {
477 fn interpret(&self) -> String {
478 let mut buf = String::with_capacity(64);
479 buf.push_str("/fcancel ");
480 buf.push_str(&self.file_id.to_string());
481 buf
482 }
483}
484
485#[derive(Debug, Clone, PartialEq)]
501#[cfg_attr(feature = "bon", derive(::bon::Builder))]
502pub struct ApiAddMember {
503 pub group_id: i64,
504 pub contact_id: i64,
505 pub member_role: GroupMemberRole,
506}
507
508impl CommandSyntax for ApiAddMember {
509 fn interpret(&self) -> String {
510 let mut buf = String::with_capacity(256);
511 buf.push_str("/_add ");
512 buf.push('#');
513 buf.push_str(&self.group_id.to_string());
514 buf.push(' ');
515 buf.push_str(&self.contact_id.to_string());
516 buf.push(' ');
517 match self.member_role {
518 GroupMemberRole::Observer => {
519 buf.push_str("observer");
520 }
521 GroupMemberRole::Author => {
522 buf.push_str("author");
523 }
524 GroupMemberRole::Member => {
525 buf.push_str("member");
526 }
527 GroupMemberRole::Moderator => {
528 buf.push_str("moderator");
529 }
530 GroupMemberRole::Admin => {
531 buf.push_str("admin");
532 }
533 GroupMemberRole::Owner => {
534 buf.push_str("owner");
535 }
536 }
537 buf
538 }
539}
540
541#[derive(Debug, Clone, PartialEq)]
557#[cfg_attr(feature = "bon", derive(::bon::Builder))]
558pub struct ApiJoinGroup {
559 pub group_id: i64,
560}
561
562impl CommandSyntax for ApiJoinGroup {
563 fn interpret(&self) -> String {
564 let mut buf = String::with_capacity(64);
565 buf.push_str("/_join ");
566 buf.push('#');
567 buf.push_str(&self.group_id.to_string());
568 buf
569 }
570}
571
572#[derive(Debug, Clone, PartialEq)]
588#[cfg_attr(feature = "bon", derive(::bon::Builder))]
589pub struct ApiAcceptMember {
590 pub group_id: i64,
591 pub group_member_id: i64,
592 pub member_role: GroupMemberRole,
593}
594
595impl CommandSyntax for ApiAcceptMember {
596 fn interpret(&self) -> String {
597 let mut buf = String::with_capacity(256);
598 buf.push_str("/_accept ");
599 buf.push_str("member ");
600 buf.push('#');
601 buf.push_str(&self.group_id.to_string());
602 buf.push(' ');
603 buf.push_str(&self.group_member_id.to_string());
604 buf.push(' ');
605 match self.member_role {
606 GroupMemberRole::Observer => {
607 buf.push_str("observer");
608 }
609 GroupMemberRole::Author => {
610 buf.push_str("author");
611 }
612 GroupMemberRole::Member => {
613 buf.push_str("member");
614 }
615 GroupMemberRole::Moderator => {
616 buf.push_str("moderator");
617 }
618 GroupMemberRole::Admin => {
619 buf.push_str("admin");
620 }
621 GroupMemberRole::Owner => {
622 buf.push_str("owner");
623 }
624 }
625 buf
626 }
627}
628
629#[derive(Debug, Clone, PartialEq)]
645#[cfg_attr(feature = "bon", derive(::bon::Builder))]
646pub struct ApiMembersRole {
647 pub group_id: i64,
648 pub group_member_ids: Vec<i64>,
649 pub member_role: GroupMemberRole,
650}
651
652impl CommandSyntax for ApiMembersRole {
653 fn interpret(&self) -> String {
654 let mut buf = String::with_capacity(256);
655 buf.push_str("/_member ");
656 buf.push_str("role ");
657 buf.push('#');
658 buf.push_str(&self.group_id.to_string());
659 buf.push(' ');
660 let mut iter = self.group_member_ids.iter();
661 if let Some(el) = iter.next() {
662 buf.push_str(&el.to_string());
663 }
664 for el in iter {
665 buf.push(',');
666 buf.push_str(&el.to_string());
667 }
668 buf.push(' ');
669 match self.member_role {
670 GroupMemberRole::Observer => {
671 buf.push_str("observer");
672 }
673 GroupMemberRole::Author => {
674 buf.push_str("author");
675 }
676 GroupMemberRole::Member => {
677 buf.push_str("member");
678 }
679 GroupMemberRole::Moderator => {
680 buf.push_str("moderator");
681 }
682 GroupMemberRole::Admin => {
683 buf.push_str("admin");
684 }
685 GroupMemberRole::Owner => {
686 buf.push_str("owner");
687 }
688 }
689 buf
690 }
691}
692
693#[derive(Debug, Clone, PartialEq)]
709#[cfg_attr(feature = "bon", derive(::bon::Builder))]
710pub struct ApiBlockMembersForAll {
711 pub group_id: i64,
712 pub group_member_ids: Vec<i64>,
713 pub blocked: bool,
714}
715
716impl CommandSyntax for ApiBlockMembersForAll {
717 fn interpret(&self) -> String {
718 let mut buf = String::with_capacity(256);
719 buf.push_str("/_block ");
720 buf.push('#');
721 buf.push_str(&self.group_id.to_string());
722 buf.push(' ');
723 let mut iter = self.group_member_ids.iter();
724 if let Some(el) = iter.next() {
725 buf.push_str(&el.to_string());
726 }
727 for el in iter {
728 buf.push(',');
729 buf.push_str(&el.to_string());
730 }
731 buf.push(' ');
732 buf.push_str("blocked=");
733 if self.blocked {
734 buf.push_str("on");
735 } else {
736 buf.push_str("off");
737 }
738 buf
739 }
740}
741
742#[derive(Debug, Clone, PartialEq)]
758#[cfg_attr(feature = "bon", derive(::bon::Builder))]
759pub struct ApiRemoveMembers {
760 pub group_id: i64,
761 pub group_member_ids: Vec<i64>,
762 pub with_messages: bool,
763}
764
765impl CommandSyntax for ApiRemoveMembers {
766 fn interpret(&self) -> String {
767 let mut buf = String::with_capacity(256);
768 buf.push_str("/_remove ");
769 buf.push('#');
770 buf.push_str(&self.group_id.to_string());
771 buf.push(' ');
772 let mut iter = self.group_member_ids.iter();
773 if let Some(el) = iter.next() {
774 buf.push_str(&el.to_string());
775 }
776 for el in iter {
777 buf.push(',');
778 buf.push_str(&el.to_string());
779 }
780 if self.with_messages {
781 buf.push(' ');
782 buf.push_str("messages=");
783 buf.push_str("on");
784 }
785 buf
786 }
787}
788
789#[derive(Debug, Clone, PartialEq)]
805#[cfg_attr(feature = "bon", derive(::bon::Builder))]
806pub struct ApiLeaveGroup {
807 pub group_id: i64,
808}
809
810impl CommandSyntax for ApiLeaveGroup {
811 fn interpret(&self) -> String {
812 let mut buf = String::with_capacity(64);
813 buf.push_str("/_leave ");
814 buf.push('#');
815 buf.push_str(&self.group_id.to_string());
816 buf
817 }
818}
819
820#[derive(Debug, Clone, PartialEq)]
836#[cfg_attr(feature = "bon", derive(::bon::Builder))]
837pub struct ApiListMembers {
838 pub group_id: i64,
839}
840
841impl CommandSyntax for ApiListMembers {
842 fn interpret(&self) -> String {
843 let mut buf = String::with_capacity(64);
844 buf.push_str("/_members ");
845 buf.push('#');
846 buf.push_str(&self.group_id.to_string());
847 buf
848 }
849}
850
851#[derive(Debug, Clone, PartialEq)]
867#[cfg_attr(feature = "bon", derive(::bon::Builder))]
868pub struct ApiNewGroup {
869 pub user_id: i64,
870 pub incognito: bool,
871 pub group_profile: GroupProfile,
872}
873
874impl CommandSyntax for ApiNewGroup {
875 fn interpret(&self) -> String {
876 let mut buf = String::with_capacity(1024);
877 buf.push_str("/_group ");
878 buf.push_str(&self.user_id.to_string());
879 if self.incognito {
880 buf.push(' ');
881 buf.push_str("incognito=");
882 buf.push_str("on");
883 }
884 buf.push(' ');
885 buf.push_str(&serde_json::to_string(&self.group_profile).unwrap());
886 buf
887 }
888}
889
890#[derive(Debug, Clone, PartialEq)]
906#[cfg_attr(feature = "bon", derive(::bon::Builder))]
907pub struct ApiUpdateGroupProfile {
908 pub group_id: i64,
909 pub group_profile: GroupProfile,
910}
911
912impl CommandSyntax for ApiUpdateGroupProfile {
913 fn interpret(&self) -> String {
914 let mut buf = String::with_capacity(1024);
915 buf.push_str("/_group_profile ");
916 buf.push('#');
917 buf.push_str(&self.group_id.to_string());
918 buf.push(' ');
919 buf.push_str(&serde_json::to_string(&self.group_profile).unwrap());
920 buf
921 }
922}
923
924#[derive(Debug, Clone, PartialEq)]
940#[cfg_attr(feature = "bon", derive(::bon::Builder))]
941pub struct ApiCreateGroupLink {
942 pub group_id: i64,
943 pub member_role: GroupMemberRole,
944}
945
946impl CommandSyntax for ApiCreateGroupLink {
947 fn interpret(&self) -> String {
948 let mut buf = String::with_capacity(64);
949 buf.push_str("/_create ");
950 buf.push_str("link ");
951 buf.push('#');
952 buf.push_str(&self.group_id.to_string());
953 buf.push(' ');
954 match self.member_role {
955 GroupMemberRole::Observer => {
956 buf.push_str("observer");
957 }
958 GroupMemberRole::Author => {
959 buf.push_str("author");
960 }
961 GroupMemberRole::Member => {
962 buf.push_str("member");
963 }
964 GroupMemberRole::Moderator => {
965 buf.push_str("moderator");
966 }
967 GroupMemberRole::Admin => {
968 buf.push_str("admin");
969 }
970 GroupMemberRole::Owner => {
971 buf.push_str("owner");
972 }
973 }
974 buf
975 }
976}
977
978#[derive(Debug, Clone, PartialEq)]
994#[cfg_attr(feature = "bon", derive(::bon::Builder))]
995pub struct ApiGroupLinkMemberRole {
996 pub group_id: i64,
997 pub member_role: GroupMemberRole,
998}
999
1000impl CommandSyntax for ApiGroupLinkMemberRole {
1001 fn interpret(&self) -> String {
1002 let mut buf = String::with_capacity(64);
1003 buf.push_str("/_set ");
1004 buf.push_str("link ");
1005 buf.push_str("role ");
1006 buf.push('#');
1007 buf.push_str(&self.group_id.to_string());
1008 buf.push(' ');
1009 match self.member_role {
1010 GroupMemberRole::Observer => {
1011 buf.push_str("observer");
1012 }
1013 GroupMemberRole::Author => {
1014 buf.push_str("author");
1015 }
1016 GroupMemberRole::Member => {
1017 buf.push_str("member");
1018 }
1019 GroupMemberRole::Moderator => {
1020 buf.push_str("moderator");
1021 }
1022 GroupMemberRole::Admin => {
1023 buf.push_str("admin");
1024 }
1025 GroupMemberRole::Owner => {
1026 buf.push_str("owner");
1027 }
1028 }
1029 buf
1030 }
1031}
1032
1033#[derive(Debug, Clone, PartialEq)]
1049#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1050pub struct ApiDeleteGroupLink {
1051 pub group_id: i64,
1052}
1053
1054impl CommandSyntax for ApiDeleteGroupLink {
1055 fn interpret(&self) -> String {
1056 let mut buf = String::with_capacity(64);
1057 buf.push_str("/_delete ");
1058 buf.push_str("link ");
1059 buf.push('#');
1060 buf.push_str(&self.group_id.to_string());
1061 buf
1062 }
1063}
1064
1065#[derive(Debug, Clone, PartialEq)]
1081#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1082pub struct ApiGetGroupLink {
1083 pub group_id: i64,
1084}
1085
1086impl CommandSyntax for ApiGetGroupLink {
1087 fn interpret(&self) -> String {
1088 let mut buf = String::with_capacity(64);
1089 buf.push_str("/_get ");
1090 buf.push_str("link ");
1091 buf.push('#');
1092 buf.push_str(&self.group_id.to_string());
1093 buf
1094 }
1095}
1096
1097#[derive(Debug, Clone, PartialEq)]
1113#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1114pub struct ApiAddContact {
1115 pub user_id: i64,
1116 pub incognito: bool,
1117}
1118
1119impl CommandSyntax for ApiAddContact {
1120 fn interpret(&self) -> String {
1121 let mut buf = String::with_capacity(64);
1122 buf.push_str("/_connect ");
1123 buf.push_str(&self.user_id.to_string());
1124 if self.incognito {
1125 buf.push(' ');
1126 buf.push_str("incognito=");
1127 buf.push_str("on");
1128 }
1129 buf
1130 }
1131}
1132
1133#[derive(Debug, Clone, PartialEq)]
1149#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1150pub struct ApiConnectPlan {
1151 pub user_id: i64,
1152 pub connection_link: Option<String>,
1153}
1154
1155impl CommandSyntax for ApiConnectPlan {
1156 fn interpret(&self) -> String {
1157 let mut buf = String::with_capacity(64);
1158 buf.push_str("/_connect ");
1159 buf.push_str("plan ");
1160 buf.push_str(&self.user_id.to_string());
1161 buf.push(' ');
1162 buf.push_str(
1163 &self
1164 .connection_link
1165 .as_deref()
1166 .unwrap_or_default()
1167 .to_string(),
1168 );
1169 buf
1170 }
1171}
1172
1173#[derive(Debug, Clone, PartialEq)]
1189#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1190pub struct ApiConnect {
1191 pub user_id: i64,
1192 pub incognito: bool,
1193 pub prepared_link: Option<CreatedConnLink>,
1194}
1195
1196impl CommandSyntax for ApiConnect {
1197 fn interpret(&self) -> String {
1198 let mut buf = String::with_capacity(256);
1199 buf.push_str("/_connect ");
1200 buf.push_str(&self.user_id.to_string());
1201 if let Some(prepared_link) = &self.prepared_link {
1202 buf.push(' ');
1203 buf.push_str(&prepared_link.interpret());
1204 }
1205 buf
1206 }
1207}
1208
1209#[derive(Debug, Clone, PartialEq)]
1225#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1226pub struct Connect {
1227 pub incognito: bool,
1228 pub conn_link: Option<String>,
1229}
1230
1231impl CommandSyntax for Connect {
1232 fn interpret(&self) -> String {
1233 let mut buf = String::with_capacity(64);
1234 buf.push_str("/connect");
1235 if let Some(conn_link) = &self.conn_link {
1236 buf.push(' ');
1237 buf.push_str(&conn_link.to_string());
1238 }
1239 buf
1240 }
1241}
1242
1243#[derive(Debug, Clone, PartialEq)]
1259#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1260pub struct ApiAcceptContact {
1261 pub contact_req_id: i64,
1262}
1263
1264impl CommandSyntax for ApiAcceptContact {
1265 fn interpret(&self) -> String {
1266 let mut buf = String::with_capacity(64);
1267 buf.push_str("/_accept ");
1268 buf.push_str(&self.contact_req_id.to_string());
1269 buf
1270 }
1271}
1272
1273#[derive(Debug, Clone, PartialEq)]
1289#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1290pub struct ApiRejectContact {
1291 pub contact_req_id: i64,
1292}
1293
1294impl CommandSyntax for ApiRejectContact {
1295 fn interpret(&self) -> String {
1296 let mut buf = String::with_capacity(64);
1297 buf.push_str("/_reject ");
1298 buf.push_str(&self.contact_req_id.to_string());
1299 buf
1300 }
1301}
1302
1303#[derive(Debug, Clone, PartialEq)]
1319#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1320pub struct ApiListContacts {
1321 pub user_id: i64,
1322}
1323
1324impl CommandSyntax for ApiListContacts {
1325 fn interpret(&self) -> String {
1326 let mut buf = String::with_capacity(64);
1327 buf.push_str("/_contacts ");
1328 buf.push_str(&self.user_id.to_string());
1329 buf
1330 }
1331}
1332
1333#[derive(Debug, Clone, PartialEq)]
1349#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1350pub struct ApiListGroups {
1351 pub user_id: i64,
1352 pub contact_id: Option<i64>,
1353 pub search: Option<String>,
1354}
1355
1356impl CommandSyntax for ApiListGroups {
1357 fn interpret(&self) -> String {
1358 let mut buf = String::with_capacity(256);
1359 buf.push_str("/_groups ");
1360 buf.push_str(&self.user_id.to_string());
1361 if let Some(contact_id) = &self.contact_id {
1362 buf.push(' ');
1363 buf.push('@');
1364 buf.push_str(&contact_id.to_string());
1365 }
1366 if let Some(search) = &self.search {
1367 buf.push(' ');
1368 buf.push_str(&search.to_string());
1369 }
1370 buf
1371 }
1372}
1373
1374#[derive(Debug, Clone, PartialEq)]
1390#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1391pub struct ApiDeleteChat {
1392 pub chat_ref: ChatRef,
1393 pub chat_delete_mode: ChatDeleteMode,
1394}
1395
1396impl CommandSyntax for ApiDeleteChat {
1397 fn interpret(&self) -> String {
1398 let mut buf = String::with_capacity(64);
1399 buf.push_str("/_delete ");
1400 buf.push_str(&self.chat_ref.interpret());
1401 buf.push(' ');
1402 buf.push_str(&self.chat_delete_mode.interpret());
1403 buf
1404 }
1405}
1406
1407#[derive(Debug, Clone, PartialEq)]
1423#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1424pub struct ShowActiveUser {}
1425
1426impl CommandSyntax for ShowActiveUser {
1427 fn interpret(&self) -> String {
1428 let mut buf = String::new();
1429 buf.push_str("/user");
1430 buf
1431 }
1432}
1433
1434#[derive(Debug, Clone, PartialEq)]
1450#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1451pub struct CreateActiveUser {
1452 pub new_user: NewUser,
1453}
1454
1455impl CommandSyntax for CreateActiveUser {
1456 fn interpret(&self) -> String {
1457 let mut buf = String::with_capacity(1024);
1458 buf.push_str("/_create ");
1459 buf.push_str("user ");
1460 buf.push_str(&serde_json::to_string(&self.new_user).unwrap());
1461 buf
1462 }
1463}
1464
1465#[derive(Debug, Clone, PartialEq)]
1481#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1482pub struct ListUsers {}
1483
1484impl CommandSyntax for ListUsers {
1485 fn interpret(&self) -> String {
1486 let mut buf = String::new();
1487 buf.push_str("/users");
1488 buf
1489 }
1490}
1491
1492#[derive(Debug, Clone, PartialEq)]
1508#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1509pub struct ApiSetActiveUser {
1510 pub user_id: i64,
1511 pub view_pwd: Option<String>,
1512}
1513
1514impl CommandSyntax for ApiSetActiveUser {
1515 fn interpret(&self) -> String {
1516 let mut buf = String::with_capacity(1024);
1517 buf.push_str("/_user ");
1518 buf.push_str(&self.user_id.to_string());
1519 if let Some(view_pwd) = &self.view_pwd {
1520 buf.push(' ');
1521 buf.push_str(&serde_json::to_string(&view_pwd).unwrap());
1522 }
1523 buf
1524 }
1525}
1526
1527#[derive(Debug, Clone, PartialEq)]
1543#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1544pub struct ApiDeleteUser {
1545 pub user_id: i64,
1546 pub del_smp_queues: bool,
1547 pub view_pwd: Option<String>,
1548}
1549
1550impl CommandSyntax for ApiDeleteUser {
1551 fn interpret(&self) -> String {
1552 let mut buf = String::with_capacity(1024);
1553 buf.push_str("/_delete ");
1554 buf.push_str("user ");
1555 buf.push_str(&self.user_id.to_string());
1556 buf.push(' ');
1557 buf.push_str("del_smp=");
1558 if self.del_smp_queues {
1559 buf.push_str("on");
1560 } else {
1561 buf.push_str("off");
1562 }
1563 if let Some(view_pwd) = &self.view_pwd {
1564 buf.push(' ');
1565 buf.push_str(&serde_json::to_string(&view_pwd).unwrap());
1566 }
1567 buf
1568 }
1569}
1570
1571#[derive(Debug, Clone, PartialEq)]
1587#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1588pub struct ApiUpdateProfile {
1589 pub user_id: i64,
1590 pub profile: Profile,
1591}
1592
1593impl CommandSyntax for ApiUpdateProfile {
1594 fn interpret(&self) -> String {
1595 let mut buf = String::with_capacity(1024);
1596 buf.push_str("/_profile ");
1597 buf.push_str(&self.user_id.to_string());
1598 buf.push(' ');
1599 buf.push_str(&serde_json::to_string(&self.profile).unwrap());
1600 buf
1601 }
1602}
1603
1604#[derive(Debug, Clone, PartialEq)]
1620#[cfg_attr(feature = "bon", derive(::bon::Builder))]
1621pub struct ApiSetContactPrefs {
1622 pub contact_id: i64,
1623 pub preferences: Preferences,
1624}
1625
1626impl CommandSyntax for ApiSetContactPrefs {
1627 fn interpret(&self) -> String {
1628 let mut buf = String::with_capacity(1024);
1629 buf.push_str("/_set ");
1630 buf.push_str("prefs ");
1631 buf.push('@');
1632 buf.push_str(&self.contact_id.to_string());
1633 buf.push(' ');
1634 buf.push_str(&serde_json::to_string(&self.preferences).unwrap());
1635 buf
1636 }
1637}