11pub mod add_invoice;
2+ pub mod adm_send_dm;
23pub mod conversation_key;
4+ pub mod dm_to_user;
35pub mod get_dm;
6+ pub mod get_dm_user;
47pub mod list_disputes;
58pub mod list_orders;
69pub mod new_order;
@@ -13,8 +16,11 @@ pub mod take_dispute;
1316pub mod take_sell;
1417
1518use crate :: cli:: add_invoice:: execute_add_invoice;
19+ use crate :: cli:: adm_send_dm:: execute_adm_send_dm;
1620use crate :: cli:: conversation_key:: execute_conversation_key;
21+ use crate :: cli:: dm_to_user:: execute_dm_to_user;
1722use crate :: cli:: get_dm:: execute_get_dm;
23+ use crate :: cli:: get_dm_user:: execute_get_dm_user;
1824use crate :: cli:: list_disputes:: execute_list_disputes;
1925use crate :: cli:: list_orders:: execute_list_orders;
2026use crate :: cli:: new_order:: execute_new_order;
@@ -158,6 +164,13 @@ pub enum Commands {
158164 #[ arg( short) ]
159165 from_user : bool ,
160166 } ,
167+ /// Get direct messages sent to any trade keys
168+ GetDmUser {
169+ /// Since time of the messages in minutes
170+ #[ arg( short, long) ]
171+ #[ clap( default_value_t = 30 ) ]
172+ since : i64 ,
173+ } ,
161174 /// Get the latest direct messages for admin
162175 GetAdminDm {
163176 /// Since time of the messages in minutes
@@ -180,6 +193,18 @@ pub enum Commands {
180193 #[ arg( short, long) ]
181194 message : String ,
182195 } ,
196+ /// Send gift wrapped direct message to a user
197+ DmToUser {
198+ /// Pubkey of the recipient
199+ #[ arg( short, long) ]
200+ pubkey : String ,
201+ /// Order id to get ephemeral keys
202+ #[ arg( short, long) ]
203+ order_id : Uuid ,
204+ /// Message to send
205+ #[ arg( short, long) ]
206+ message : String ,
207+ } ,
183208 /// Send fiat sent message to confirm payment to other user
184209 FiatSent {
185210 /// Order id
@@ -241,6 +266,15 @@ pub enum Commands {
241266 #[ arg( short, long) ]
242267 dispute_id : Uuid ,
243268 } ,
269+ /// Send gift wrapped direct message to a user (only admin)
270+ AdmSendDm {
271+ /// Pubkey of the recipient
272+ #[ arg( short, long) ]
273+ pubkey : String ,
274+ /// Message to send
275+ #[ arg( short, long) ]
276+ message : String ,
277+ } ,
244278 /// Get the conversation key for direct messaging with a user
245279 ConversationKey {
246280 /// Pubkey of the counterpart
@@ -373,10 +407,13 @@ pub async fn run() -> Result<()> {
373407 execute_add_invoice ( order_id, invoice, & identity_keys, mostro_key, & client) . await ?
374408 }
375409 Commands :: GetDm { since, from_user } => {
376- execute_get_dm ( since, trade_index, & client, * from_user, false ) . await ?
410+ execute_get_dm ( since, trade_index, & client, * from_user, false , & mostro_key) . await ?
411+ }
412+ Commands :: GetDmUser { since } => {
413+ execute_get_dm_user ( since, & client, & mostro_key) . await ?
377414 }
378415 Commands :: GetAdminDm { since, from_user } => {
379- execute_get_dm ( since, trade_index, & client, * from_user, true ) . await ?
416+ execute_get_dm ( since, trade_index, & client, * from_user, true , & mostro_key ) . await ?
380417 }
381418 Commands :: FiatSent { order_id }
382419 | Commands :: Release { order_id }
@@ -477,6 +514,18 @@ pub async fn run() -> Result<()> {
477514 let pubkey = PublicKey :: from_str ( pubkey) ?;
478515 execute_send_dm ( pubkey, & client, order_id, message) . await ?
479516 }
517+ Commands :: DmToUser {
518+ pubkey,
519+ order_id,
520+ message,
521+ } => {
522+ let pubkey = PublicKey :: from_str ( pubkey) ?;
523+ execute_dm_to_user ( pubkey, & client, order_id, message) . await ?
524+ }
525+ Commands :: AdmSendDm { pubkey, message } => {
526+ let pubkey = PublicKey :: from_str ( pubkey) ?;
527+ execute_adm_send_dm ( pubkey, & client, message) . await ?
528+ }
480529 } ;
481530 }
482531
0 commit comments