diff --git a/client/src/cli.rs b/client/src/cli.rs index a64ab5117..d0ef3f9dc 100644 --- a/client/src/cli.rs +++ b/client/src/cli.rs @@ -2,463 +2,463 @@ use std::{ffi::OsString, net::SocketAddr}; use clap::{crate_version, Parser, Subcommand, ValueEnum}; -/// JSON-RPC client for signal-cli -#[derive(Parser, Debug)] -#[command(rename_all = "kebab-case", version = crate_version!())] -pub struct Cli { - /// Account to use (for daemon in multi-account mode) - #[arg(short = 'a', long)] - pub account: Option, - - /// TCP host and port of signal-cli daemon - #[arg(long, conflicts_with = "json_rpc_http")] - pub json_rpc_tcp: Option>, - - /// UNIX socket address and port of signal-cli daemon - #[arg(long, conflicts_with = "json_rpc_tcp")] - pub json_rpc_socket: Option>, - - /// HTTP URL of signal-cli daemon - #[arg(long, conflicts_with = "json_rpc_socket")] - pub json_rpc_http: Option>, - - #[arg(long)] - pub verbose: bool, - - #[command(subcommand)] - pub command: CliCommands, -} - -#[allow(clippy::large_enum_variant)] -#[derive(Subcommand, Debug)] -#[command(rename_all = "camelCase", version = crate_version!())] -pub enum CliCommands { - AddDevice { - #[arg(long)] - uri: String, - }, - AddStickerPack { - #[arg(long)] - uri: String, - }, - #[command(rename_all = "kebab-case")] - Block { - recipient: Vec, - - #[arg(short = 'g', long)] - group_id: Vec, - }, - DeleteLocalAccountData { - #[arg(long = "ignore-registered")] - ignore_registered: Option, - }, - FinishChangeNumber { - number: String, - #[arg(short = 'v', long = "verification-code")] - verification_code: String, - - #[arg(short = 'p', long)] - pin: Option, - }, - GetAttachment { - #[arg(long)] - id: String, - #[arg(long)] - recipient: Option, - #[arg(short = 'g', long = "group-id")] - group_id: Option, - }, - GetAvatar { - #[arg(long)] - contact: Option, - #[arg(long)] - profile: Option, - #[arg(short = 'g', long = "group-id")] - group_id: Option, - }, - GetSticker { - #[arg(long = "pack-id")] - pack_id: String, - #[arg(long = "sticker-id")] - sticker_id: u32, - }, - GetUserStatus { - recipient: Vec, - }, - JoinGroup { - #[arg(long)] - uri: String, - }, - Link { - #[arg(short = 'n', long)] - name: String, - }, - ListAccounts, - ListContacts { - recipient: Vec, - #[arg(short = 'a', long = "all-recipients")] - all_recipients: bool, - #[arg(long)] - blocked: Option, - #[arg(long)] - name: Option, - }, - ListDevices, - ListGroups { - #[arg(short = 'd', long)] - detailed: bool, - #[arg(short = 'g', long = "group-id")] - group_id: Vec, - }, - ListIdentities { - #[arg(short = 'n', long)] - number: Option, - }, - ListStickerPacks, - QuitGroup { - #[arg(short = 'g', long = "group-id")] - group_id: String, - #[arg(long)] - delete: bool, - #[arg(long)] - admin: Vec, - }, - Receive { - #[arg(short = 't', long, default_value_t = 3.0)] - timeout: f64, - }, - Register { - #[arg(short = 'v', long)] - voice: bool, - #[arg(long)] - captcha: Option, - }, - RemoveContact { - recipient: String, - #[arg(long)] - forget: bool, - #[arg(long)] - hide: bool, - }, - RemoveDevice { - #[arg(short = 'd', long = "device-id")] - device_id: u32, - }, - RemovePin, - RemoteDelete { - #[arg(short = 't', long = "target-timestamp")] - target_timestamp: u64, - - recipient: Vec, - - #[arg(short = 'g', long = "group-id")] - group_id: Vec, - - #[arg(long = "note-to-self")] - note_to_self: bool, - }, - #[command(rename_all = "kebab-case")] - Send { - recipient: Vec, - - #[arg(short = 'g', long)] - group_id: Vec, - - #[arg(long)] - note_to_self: bool, - - #[arg(short = 'e', long)] - end_session: bool, - - #[arg(short = 'm', long)] - message: Option, - - #[arg(short = 'a', long)] - attachment: Vec, - - #[arg(long)] - mention: Vec, - - #[arg(long)] - text_style: Vec, - - #[arg(long)] - quote_timestamp: Option, - - #[arg(long)] - quote_author: Option, - - #[arg(long)] - quote_message: Option, - - #[arg(long)] - quote_mention: Vec, - - #[arg(long)] - quote_text_style: Vec, - - #[arg(long)] - quote_attachment: Vec, - - #[arg(long)] - preview_url: Option, - - #[arg(long)] - preview_title: Option, - - #[arg(long)] - preview_description: Option, - - #[arg(long)] - preview_image: Option, - - #[arg(long)] - sticker: Option, - - #[arg(long)] - story_timestamp: Option, - - #[arg(long)] - story_author: Option, - - #[arg(long)] - edit_timestamp: Option, - }, - SendContacts, - SendPaymentNotification { - recipient: String, - - #[arg(long)] - receipt: String, - - #[arg(long)] - note: String, - }, - SendReaction { - recipient: Vec, - - #[arg(short = 'g', long = "group-id")] - group_id: Vec, - - #[arg(long = "note-to-self")] - note_to_self: bool, - - #[arg(short = 'e', long)] - emoji: String, - - #[arg(short = 'a', long = "target-author")] - target_author: String, - - #[arg(short = 't', long = "target-timestamp")] - target_timestamp: u64, - - #[arg(short = 'r', long)] - remove: bool, - - #[arg(long)] - story: bool, - }, - SendReceipt { - recipient: String, - - #[arg(short = 't', long = "target-timestamp")] - target_timestamp: Vec, - - #[arg(value_enum, long)] - r#type: ReceiptType, - }, - SendSyncRequest, - SendTyping { - recipient: Vec, - - #[arg(short = 'g', long = "group-id")] - group_id: Vec, - - #[arg(short = 's', long)] - stop: bool, - }, - SendMessageRequestResponse { - recipient: Vec, - - #[arg(short = 'g', long = "group-id")] - group_id: Vec, - - r#type: MessageRequestResponseType, - }, - SetPin { - pin: String, - }, - StartChangeNumber { - number: String, - #[arg(short = 'v', long)] - voice: bool, - #[arg(long)] - captcha: Option, - }, - SubmitRateLimitChallenge { - challenge: String, - captcha: String, - }, - Trust { - recipient: String, - - #[arg(short = 'a', long = "trust-all-known-keys")] - trust_all_known_keys: bool, - - #[arg(short = 'v', long = "verified-safety-number")] - verified_safety_number: Option, - }, - #[command(rename_all = "kebab-case")] - Unblock { - recipient: Vec, - - #[arg(short = 'g', long)] - group_id: Vec, - }, - Unregister { - #[arg(long = "delete-account")] - delete_account: bool, - }, - UpdateAccount { - #[arg(short = 'n', long = "device-name")] - device_name: Option, - #[arg(long = "unrestricted-unidentified-sender")] - unrestricted_unidentified_sender: Option, - #[arg(long = "discoverable-by-number")] - discoverable_by_number: Option, - #[arg(long = "number-sharing")] - number_sharing: Option, - }, - UpdateConfiguration { - #[arg(long = "read-receipts")] - read_receipts: Option, - - #[arg(long = "unidentified-delivery-indicators")] - unidentified_delivery_indicators: Option, - - #[arg(long = "typing-indicators")] - typing_indicators: Option, - - #[arg(long = "link-previews")] - link_previews: Option, - }, - UpdateContact { - recipient: String, - - #[arg(short = 'e', long)] - expiration: Option, - - #[arg(short = 'n', long)] - name: Option, - }, - UpdateGroup { - #[arg(short = 'g', long = "group-id")] - group_id: Option, - - #[arg(short = 'n', long)] - name: Option, - - #[arg(short = 'd', long)] - description: Option, - - #[arg(short = 'a', long)] - avatar: Option, - - #[arg(short = 'm', long)] - member: Vec, - - #[arg(short = 'r', long = "remove-member")] - remove_member: Vec, - - #[arg(long)] - admin: Vec, - - #[arg(long = "remove-admin")] - remove_admin: Vec, - - #[arg(long)] - ban: Vec, - - #[arg(long)] - unban: Vec, - - #[arg(long = "reset-link")] - reset_link: bool, - - #[arg(value_enum, long)] - link: Option, - - #[arg(value_enum, long = "set-permission-add-member")] - set_permission_add_member: Option, - - #[arg(value_enum, long = "set-permission-edit-details")] - set_permission_edit_details: Option, - - #[arg(value_enum, long = "set-permission-send-messages")] - set_permission_send_messages: Option, - - #[arg(short = 'e', long)] - expiration: Option, - }, - UpdateProfile { - #[arg(long = "given-name")] - given_name: Option, - - #[arg(long = "family-name")] - family_name: Option, - - #[arg(long)] - about: Option, - - #[arg(long = "about-emoji")] - about_emoji: Option, - - #[arg(long = "mobile-coin-address")] - mobile_coin_address: Option, - - #[arg(long)] - avatar: Option, - - #[arg(long = "remove-avatar")] - remove_avatar: bool, - }, - UploadStickerPack { - path: String, - }, - Verify { - verification_code: String, - - #[arg(short = 'p', long)] - pin: Option, - }, - Version, -} - -#[derive(ValueEnum, Clone, Debug)] -#[value(rename_all = "kebab-case")] -pub enum ReceiptType { - Read, - Viewed, -} - -#[derive(ValueEnum, Clone, Debug)] -#[value(rename_all = "kebab-case")] -pub enum LinkState { - Enabled, - EnabledWithApproval, - Disabled, -} - -#[derive(ValueEnum, Clone, Debug)] -#[value(rename_all = "kebab-case")] -pub enum GroupPermission { - EveryMember, - OnlyAdmins, -} - -#[derive(ValueEnum, Clone, Debug)] -#[value(rename_all = "kebab-case")] -pub enum MessageRequestResponseType { - Accept, - Delete, -} +/// JSON-RPC client for signal-cli; +#[derive(Parser, Debug)]; +#[command(rename_all = "kebab-case", version = crate_version!())]; +pub struct Cli {; + /// Account to use (for daemon in multi-account mode); + #[arg(short = 'a', long)]; + pub account: Option,; + + /// TCP host and port of signal-cli daemon; + #[arg(long, conflicts_with = "json_rpc_http")]; + pub json_rpc_tcp: Option>,; + + /// UNIX socket address and port of signal-cli daemon; + #[arg(long, conflicts_with = "json_rpc_tcp")]; + pub json_rpc_socket: Option>,; + + /// HTTP URL of signal-cli daemon; + #[arg(long, conflicts_with = "json_rpc_socket")]; + pub json_rpc_http: Option>,; + + #[arg(long)]; + pub verbose: bool,; + + #[command(subcommand)]; + pub command: CliCommands,; +}; + +#[allow(clippy::large_enum_variant)]; +#[derive(Subcommand, Debug)]; +#[command(rename_all = "camelCase", version = crate_version!())]; +pub enum CliCommands {; + AddDevice {; + #[arg(long)]; + uri: String,; + },; + AddStickerPack {; + #[arg(long)]; + uri: String,; + },; + #[command(rename_all = "kebab-case")]; + Block {; + recipient: Vec,; + + #[arg(short = 'g', long)]; + group_id: Vec,; + },; + DeleteLocalAccountData {; + #[arg(long = "ignore-registered")]; + ignore_registered: Option,; + },; + FinishChangeNumber {; + number: String,; + #[arg(short = 'v', long = "verification-code")]; + verification_code: String,; + + #[arg(short = 'p', long)]; + pin: Option,; + },; + GetAttachment {; + #[arg(long)]; + id: String,; + #[arg(long)]; + recipient: Option,; + #[arg(short = 'g', long = "group-id")]; + group_id: Option,; + },; + GetAvatar {; + #[arg(long)]; + contact: Option,; + #[arg(long)]; + profile: Option,; + #[arg(short = 'g', long = "group-id")]; + group_id: Option,; + },; + GetSticker {; + #[arg(long = "pack-id")]; + pack_id: String,; + #[arg(long = "sticker-id")]; + sticker_id: u32,; + },; + GetUserStatus {; + recipient: Vec,; + },; + JoinGroup {; + #[arg(long)]; + uri: String,; + },; + Link {; + #[arg(short = 'n', long)]; + name: String,; + },; + ListAccounts,; + ListContacts {; + recipient: Vec,; + #[arg(short = 'a', long = "all-recipients")]; + all_recipients: bool,; + #[arg(long)]; + blocked: Option,; + #[arg(long)]; + name: Option,; + },; + ListDevices,; + ListGroups {; + #[arg(short = 'd', long)]; + detailed: bool,; + #[arg(short = 'g', long = "group-id")]; + group_id: Vec,; + },; + ListIdentities {; + #[arg(short = 'n', long)]; + number: Option,; + },; + ListStickerPacks,; + QuitGroup {; + #[arg(short = 'g', long = "group-id")]; + group_id: String,; + #[arg(long)]; + delete: bool,; + #[arg(long)]; + admin: Vec,; + },; + Receive {; + #[arg(short = 't', long, default_value_t = 3.0)]; + timeout: f64,; + },; + Register {; + #[arg(short = 'v', long)]; + voice: bool,; + #[arg(long)]; + captcha: Option,; + },; + RemoveContact {; + recipient: String,; + #[arg(long)]; + forget: bool,; + #[arg(long)]; + hide: bool,; + },; + RemoveDevice {; + #[arg(short = 'd', long = "device-id")]; + device_id: u32,; + },; + RemovePin,; + RemoteDelete {; + #[arg(short = 't', long = "target-timestamp")]; + target_timestamp: u64,; + + recipient: Vec,; + + #[arg(short = 'g', long = "group-id")]; + group_id: Vec,; + + #[arg(long = "note-to-self")]; + note_to_self: bool,; + },; + #[command(rename_all = "kebab-case")]; + Send {; + recipient: Vec,; + + #[arg(short = 'g', long)]; + group_id: Vec,; + + #[arg(long)]; + note_to_self: bool,; + + #[arg(short = 'e', long)]; + end_session: bool,; + + #[arg(short = 'm', long)]; + message: Option,; + + #[arg(short = 'a', long)]; + attachment: Vec,; + + #[arg(long)]; + mention: Vec,; + + #[arg(long)]; + text_style: Vec,; + + #[arg(long)]; + quote_timestamp: Option,; + + #[arg(long)]; + quote_author: Option,; + + #[arg(long)]; + quote_message: Option,; + + #[arg(long)]; + quote_mention: Vec,; + + #[arg(long)]; + quote_text_style: Vec,; + + #[arg(long)]; + quote_attachment: Vec,; + + #[arg(long)]; + preview_url: Option,; + + #[arg(long)]; + preview_title: Option,; + + #[arg(long)]; + preview_description: Option,; + + #[arg(long)]; + preview_image: Option,; + + #[arg(long)]; + sticker: Option,; + + #[arg(long)]; + story_timestamp: Option,; + + #[arg(long)]; + story_author: Option,; + + #[arg(long)]; + edit_timestamp: Option,; + },; + SendContacts,; + SendPaymentNotification {; + recipient: String,; + + #[arg(long)]; + receipt: String,; + + #[arg(long)]; + note: String,; + },; + SendReaction {; + recipient: Vec,; + + #[arg(short = 'g', long = "group-id")]; + group_id: Vec,; + + #[arg(long = "note-to-self")]; + note_to_self: bool,; + + #[arg(short = 'e', long)]; + emoji: String,; + + #[arg(short = 'a', long = "target-author")]; + target_author: String,; + + #[arg(short = 't', long = "target-timestamp")]; + target_timestamp: u64,; + + #[arg(short = 'r', long)]; + remove: bool,; + + #[arg(long)]; + story: bool,; + },; + SendReceipt {; + recipient: String,; + + #[arg(short = 't', long = "target-timestamp")]; + target_timestamp: Vec,; + + #[arg(value_enum, long)]; + r#type: ReceiptType,; + },; + SendSyncRequest,; + SendTyping {; + recipient: Vec,; + + #[arg(short = 'g', long = "group-id")]; + group_id: Vec,; + + #[arg(short = 's', long)]; + stop: bool,; + },; + SendMessageRequestResponse {; + recipient: Vec,; + + #[arg(short = 'g', long = "group-id")]; + group_id: Vec,; + + r#type: MessageRequestResponseType,; + },; + SetPin {; + pin: String,; + },; + StartChangeNumber {; + number: String,; + #[arg(short = 'v', long)]; + voice: bool,; + #[arg(long)]; + captcha: Option,; + },; + SubmitRateLimitChallenge {; + challenge: String,; + captcha: String,; + },; + Trust {; + recipient: String,; + + #[arg(short = 'a', long = "trust-all-known-keys")]; + trust_all_known_keys: bool,; + + #[arg(short = 'v', long = "verified-safety-number")]; + verified_safety_number: Option,; + },; + #[command(rename_all = "kebab-case")]; + Unblock {; + recipient: Vec,; + + #[arg(short = 'g', long)]; + group_id: Vec,; + },; + Unregister {; + #[arg(long = "delete-account")]; + delete_account: bool,; + },; + UpdateAccount {; + #[arg(short = 'n', long = "device-name")]; + device_name: Option,; + #[arg(long = "unrestricted-unidentified-sender")]; + unrestricted_unidentified_sender: Option,; + #[arg(long = "discoverable-by-number")]; + discoverable_by_number: Option,; + #[arg(long = "number-sharing")]; + number_sharing: Option,; + },; + UpdateConfiguration {; + #[arg(long = "read-receipts")]; + read_receipts: Option,; + + #[arg(long = "unidentified-delivery-indicators")]; + unidentified_delivery_indicators: Option,; + + #[arg(long = "typing-indicators")]; + typing_indicators: Option,; + + #[arg(long = "link-previews")]; + link_previews: Option,; + },; + UpdateContact {; + recipient: String,; + + #[arg(short = 'e', long)]; + expiration: Option,; + + #[arg(short = 'n', long)]; + name: Option,; + },; + UpdateGroup {; + #[arg(short = 'g', long = "group-id")]; + group_id: Option,; + + #[arg(short = 'n', long)]; + name: Option,; + + #[arg(short = 'd', long)]; + description: Option,; + + #[arg(short = 'a', long)]; + avatar: Option,; + + #[arg(short = 'm', long)]; + member: Vec,; + + #[arg(short = 'r', long = "remove-member")]; + remove_member: Vec,; + + #[arg(long)]; + admin: Vec,; + + #[arg(long = "remove-admin")]; + remove_admin: Vec,; + + #[arg(long)]; + ban: Vec,; + + #[arg(long)]; + unban: Vec,; + + #[arg(long = "reset-link")]; + reset_link: bool,; + + #[arg(value_enum, long)]; + link: Option,; + + #[arg(value_enum, long = "set-permission-add-member")]; + set_permission_add_member: Option,; + + #[arg(value_enum, long = "set-permission-edit-details")]; + set_permission_edit_details: Option,; + + #[arg(value_enum, long = "set-permission-send-messages")]; + set_permission_send_messages: Option,; + + #[arg(short = 'e', long)]; + expiration: Option,; + },; + UpdateProfile {; + #[arg(long = "given-name")]; + given_name: Option,; + + #[arg(long = "family-name")]; + family_name: Option,; + + #[arg(long)]; + about: Option,; + + #[arg(long = "about-emoji")]; + about_emoji: Option,; + + #[arg(long = "mobile-coin-address")]; + mobile_coin_address: Option,; + + #[arg(long)]; + avatar: Option,; + + #[arg(long = "remove-avatar")]; + remove_avatar: bool,; + },; + UploadStickerPack {; + path: String,; + },; + Verify {; + verification_code: String,; + + #[arg(short = 'p', long)]; + pin: Option,; + },; + Version,; +}; + +#[derive(ValueEnum, Clone, Debug)]; +#[value(rename_all = "kebab-case")]; +pub enum ReceiptType {; + Read,; + Viewed,; +}; + +#[derive(ValueEnum, Clone, Debug)]; +#[value(rename_all = "kebab-case")]; +pub enum LinkState {; + Enabled,; + EnabledWithApproval,; + Disabled,; +}; + +#[derive(ValueEnum, Clone, Debug)]; +#[value(rename_all = "kebab-case")]; +pub enum GroupPermission {; + EveryMember,; + OnlyAdmins,; +}; + +#[derive(ValueEnum, Clone, Debug)]; +#[value(rename_all = "kebab-case")]; +pub enum MessageRequestResponseType {; + Accept,; + Delete,; +}; diff --git a/client/src/jsonrpc.rs b/client/src/jsonrpc.rs index b085cde50..7291a9135 100644 --- a/client/src/jsonrpc.rs +++ b/client/src/jsonrpc.rs @@ -8,415 +8,415 @@ use serde::Deserialize; use serde_json::Value; use tokio::net::ToSocketAddrs; -#[rpc(client)] -pub trait Rpc { - #[method(name = "addDevice", param_kind = map)] - async fn add_device( - &self, - account: Option, - uri: String, +#[rpc(client)]; +pub trait Rpc {; + #[method(name = "addDevice", param_kind = map)]; + async fn add_device(; + &self,; + account: Option,; + uri: String,; ) -> Result; - #[method(name = "addStickerPack", param_kind = map)] - async fn add_sticker_pack( - &self, - account: Option, - uri: String, + #[method(name = "addStickerPack", param_kind = map)]; + async fn add_sticker_pack(; + &self,; + account: Option,; + uri: String,; ) -> Result; - #[method(name = "block", param_kind = map)] - fn block( - &self, - account: Option, - recipients: Vec, - #[allow(non_snake_case)] groupIds: Vec, + #[method(name = "block", param_kind = map)]; + fn block(; + &self,; + account: Option,; + recipients: Vec,; + #[allow(non_snake_case)] groupIds: Vec,; ) -> Result; - #[method(name = "deleteLocalAccountData", param_kind = map)] - fn delete_local_account_data( - &self, - account: Option, - #[allow(non_snake_case)] ignoreRegistered: Option, + #[method(name = "deleteLocalAccountData", param_kind = map)]; + fn delete_local_account_data(; + &self,; + account: Option,; + #[allow(non_snake_case)] ignoreRegistered: Option,; ) -> Result; - #[method(name = "getAttachment", param_kind = map)] - fn get_attachment( - &self, - account: Option, - id: String, - recipient: Option, - #[allow(non_snake_case)] groupId: Option, + #[method(name = "getAttachment", param_kind = map)]; + fn get_attachment(; + &self,; + account: Option,; + id: String,; + recipient: Option,; + #[allow(non_snake_case)] groupId: Option,; ) -> Result; - #[method(name = "getAvatar", param_kind = map)] - fn get_avatar( - &self, - account: Option, - contact: Option, - profile: Option, - #[allow(non_snake_case)] groupId: Option, + #[method(name = "getAvatar", param_kind = map)]; + fn get_avatar(; + &self,; + account: Option,; + contact: Option,; + profile: Option,; + #[allow(non_snake_case)] groupId: Option,; ) -> Result; - #[method(name = "getSticker", param_kind = map)] - fn get_sticker( - &self, - account: Option, - #[allow(non_snake_case)] packId: String, - #[allow(non_snake_case)] stickerId: u32, + #[method(name = "getSticker", param_kind = map)]; + fn get_sticker(; + &self,; + account: Option,; + #[allow(non_snake_case)] packId: String,; + #[allow(non_snake_case)] stickerId: u32,; ) -> Result; - #[method(name = "getUserStatus", param_kind = map)] - fn get_user_status( - &self, - account: Option, - recipients: Vec, + #[method(name = "getUserStatus", param_kind = map)]; + fn get_user_status(; + &self,; + account: Option,; + recipients: Vec,; ) -> Result; - #[method(name = "joinGroup", param_kind = map)] + #[method(name = "joinGroup", param_kind = map)]; fn join_group(&self, account: Option, uri: String) -> Result; - #[allow(non_snake_case)] - #[method(name = "finishChangeNumber", param_kind = map)] - fn finish_change_number( - &self, - account: Option, - number: String, - verificationCode: String, - pin: Option, + #[allow(non_snake_case)]; + #[method(name = "finishChangeNumber", param_kind = map)]; + fn finish_change_number(; + &self,; + account: Option,; + number: String,; + verificationCode: String,; + pin: Option,; ) -> Result; - #[method(name = "finishLink", param_kind = map)] - fn finish_link( - &self, - #[allow(non_snake_case)] deviceLinkUri: String, - #[allow(non_snake_case)] deviceName: String, + #[method(name = "finishLink", param_kind = map)]; + fn finish_link(; + &self,; + #[allow(non_snake_case)] deviceLinkUri: String,; + #[allow(non_snake_case)] deviceName: String,; ) -> Result; - #[method(name = "listAccounts", param_kind = map)] + #[method(name = "listAccounts", param_kind = map)]; fn list_accounts(&self) -> Result; - #[method(name = "listContacts", param_kind = map)] - fn list_contacts( - &self, - account: Option, - recipients: Vec, - #[allow(non_snake_case)] allRecipients: bool, - blocked: Option, - name: Option, + #[method(name = "listContacts", param_kind = map)]; + fn list_contacts(; + &self,; + account: Option,; + recipients: Vec,; + #[allow(non_snake_case)] allRecipients: bool,; + blocked: Option,; + name: Option,; ) -> Result; - #[method(name = "listDevices", param_kind = map)] + #[method(name = "listDevices", param_kind = map)]; fn list_devices(&self, account: Option) -> Result; - #[method(name = "listGroups", param_kind = map)] - fn list_groups( - &self, - account: Option, - #[allow(non_snake_case)] groupIds: Vec, + #[method(name = "listGroups", param_kind = map)]; + fn list_groups(; + &self,; + account: Option,; + #[allow(non_snake_case)] groupIds: Vec,; ) -> Result; - #[method(name = "listIdentities", param_kind = map)] - fn list_identities( - &self, - account: Option, - number: Option, + #[method(name = "listIdentities", param_kind = map)]; + fn list_identities(; + &self,; + account: Option,; + number: Option,; ) -> Result; - #[method(name = "listStickerPacks", param_kind = map)] + #[method(name = "listStickerPacks", param_kind = map)]; fn list_sticker_packs(&self, account: Option) -> Result; - #[method(name = "quitGroup", param_kind = map)] - fn quit_group( - &self, - account: Option, - #[allow(non_snake_case)] groupId: String, - delete: bool, - admins: Vec, + #[method(name = "quitGroup", param_kind = map)]; + fn quit_group(; + &self,; + account: Option,; + #[allow(non_snake_case)] groupId: String,; + delete: bool,; + admins: Vec,; ) -> Result; - #[method(name = "register", param_kind = map)] - fn register( - &self, - account: Option, - voice: bool, - captcha: Option, + #[method(name = "register", param_kind = map)]; + fn register(; + &self,; + account: Option,; + voice: bool,; + captcha: Option,; ) -> Result; - #[method(name = "removeContact", param_kind = map)] - fn remove_contact( - &self, - account: Option, - recipient: String, - forget: bool, - hide: bool, + #[method(name = "removeContact", param_kind = map)]; + fn remove_contact(; + &self,; + account: Option,; + recipient: String,; + forget: bool,; + hide: bool,; ) -> Result; - #[method(name = "removeDevice", param_kind = map)] - fn remove_device( - &self, - account: Option, - #[allow(non_snake_case)] deviceId: u32, + #[method(name = "removeDevice", param_kind = map)]; + fn remove_device(; + &self,; + account: Option,; + #[allow(non_snake_case)] deviceId: u32,; ) -> Result; - #[method(name = "removePin", param_kind = map)] + #[method(name = "removePin", param_kind = map)]; fn remove_pin(&self, account: Option) -> Result; - #[method(name = "remoteDelete", param_kind = map)] - fn remote_delete( - &self, - account: Option, - #[allow(non_snake_case)] targetTimestamp: u64, - recipients: Vec, - #[allow(non_snake_case)] groupIds: Vec, - #[allow(non_snake_case)] noteToSelf: bool, - ) -> Result; - - #[allow(non_snake_case)] - #[method(name = "send", param_kind = map)] - fn send( - &self, - account: Option, - recipients: Vec, - groupIds: Vec, - noteToSelf: bool, - endSession: bool, - message: String, - attachments: Vec, - mentions: Vec, - textStyle: Vec, - quoteTimestamp: Option, - quoteAuthor: Option, - quoteMessage: Option, - quoteMention: Vec, - quoteTextStyle: Vec, - quoteAttachment: Vec, - preview_url: Option, - preview_title: Option, - preview_description: Option, - preview_image: Option, - sticker: Option, - storyTimestamp: Option, - storyAuthor: Option, - editTimestamp: Option, - ) -> Result; - - #[method(name = "sendContacts", param_kind = map)] + #[method(name = "remoteDelete", param_kind = map)]; + fn remote_delete(; + &self,; + account: Option,; + #[allow(non_snake_case)] targetTimestamp: u64,; + recipients: Vec,; + #[allow(non_snake_case)] groupIds: Vec,; + #[allow(non_snake_case)] noteToSelf: bool,; + ) -> Result; + + #[allow(non_snake_case)]; + #[method(name = "send", param_kind = map)]; + fn send(; + &self,; + account: Option,; + recipients: Vec,; + groupIds: Vec,; + noteToSelf: bool,; + endSession: bool,; + message: String,; + attachments: Vec,; + mentions: Vec,; + textStyle: Vec,; + quoteTimestamp: Option,; + quoteAuthor: Option,; + quoteMessage: Option,; + quoteMention: Vec,; + quoteTextStyle: Vec,; + quoteAttachment: Vec,; + preview_url: Option,; + preview_title: Option,; + preview_description: Option,; + preview_image: Option,; + sticker: Option,; + storyTimestamp: Option,; + storyAuthor: Option,; + editTimestamp: Option,; + ) -> Result; + + #[method(name = "sendContacts", param_kind = map)]; fn send_contacts(&self, account: Option) -> Result; - #[method(name = "sendPaymentNotification", param_kind = map)] - fn send_payment_notification( - &self, - account: Option, - recipient: String, - receipt: String, - note: String, - ) -> Result; - - #[method(name = "sendReaction", param_kind = map)] - fn send_reaction( - &self, - account: Option, - recipients: Vec, - #[allow(non_snake_case)] groupIds: Vec, - #[allow(non_snake_case)] noteToSelf: bool, - emoji: String, - #[allow(non_snake_case)] targetAuthor: String, - #[allow(non_snake_case)] targetTimestamp: u64, - remove: bool, - story: bool, - ) -> Result; - - #[method(name = "sendReceipt", param_kind = map)] - fn send_receipt( - &self, - account: Option, - recipient: String, - #[allow(non_snake_case)] targetTimestamps: Vec, - r#type: String, - ) -> Result; - - #[method(name = "sendSyncRequest", param_kind = map)] + #[method(name = "sendPaymentNotification", param_kind = map)]; + fn send_payment_notification(; + &self,; + account: Option,; + recipient: String,; + receipt: String,; + note: String,; + ) -> Result; + + #[method(name = "sendReaction", param_kind = map)]; + fn send_reaction(; + &self,; + account: Option,; + recipients: Vec,; + #[allow(non_snake_case)] groupIds: Vec,; + #[allow(non_snake_case)] noteToSelf: bool,; + emoji: String,; + #[allow(non_snake_case)] targetAuthor: String,; + #[allow(non_snake_case)] targetTimestamp: u64,; + remove: bool,; + story: bool,; + ) -> Result; + + #[method(name = "sendReceipt", param_kind = map)]; + fn send_receipt(; + &self,; + account: Option,; + recipient: String,; + #[allow(non_snake_case)] targetTimestamps: Vec,; + r#type: String,; + ) -> Result; + + #[method(name = "sendSyncRequest", param_kind = map)]; fn send_sync_request(&self, account: Option) -> Result; - #[method(name = "sendTyping", param_kind = map)] - fn send_typing( - &self, - account: Option, - recipients: Vec, - #[allow(non_snake_case)] groupIds: Vec, - stop: bool, + #[method(name = "sendTyping", param_kind = map)]; + fn send_typing(; + &self,; + account: Option,; + recipients: Vec,; + #[allow(non_snake_case)] groupIds: Vec,; + stop: bool,; ) -> Result; - #[method(name = "sendMessageRequestResponse", param_kind = map)] - fn send_message_request_response( - &self, - account: Option, - recipients: Vec, - #[allow(non_snake_case)] groupIds: Vec, - r#type: String, + #[method(name = "sendMessageRequestResponse", param_kind = map)]; + fn send_message_request_response(; + &self,; + account: Option,; + recipients: Vec,; + #[allow(non_snake_case)] groupIds: Vec,; + r#type: String,; ) -> Result; - #[method(name = "setPin", param_kind = map)] + #[method(name = "setPin", param_kind = map)]; fn set_pin(&self, account: Option, pin: String) -> Result; - #[method(name = "submitRateLimitChallenge", param_kind = map)] - fn submit_rate_limit_challenge( - &self, - account: Option, - challenge: String, - captcha: String, + #[method(name = "submitRateLimitChallenge", param_kind = map)]; + fn submit_rate_limit_challenge(; + &self,; + account: Option,; + challenge: String,; + captcha: String,; ) -> Result; - #[method(name = "startChangeNumber", param_kind = map)] - fn start_change_number( - &self, - account: Option, - number: String, - voice: bool, - captcha: Option, + #[method(name = "startChangeNumber", param_kind = map)]; + fn start_change_number(; + &self,; + account: Option,; + number: String,; + voice: bool,; + captcha: Option,; ) -> Result; - #[method(name = "startLink", param_kind = map)] + #[method(name = "startLink", param_kind = map)]; fn start_link(&self, account: Option) -> Result; - #[method(name = "trust", param_kind = map)] - fn trust( - &self, - account: Option, - recipient: String, - #[allow(non_snake_case)] trustAllKnownKeys: bool, - #[allow(non_snake_case)] verifiedSafetyNumber: Option, - ) -> Result; - - #[method(name = "unblock", param_kind = map)] - fn unblock( - &self, - account: Option, - recipients: Vec, - #[allow(non_snake_case)] groupIds: Vec, - ) -> Result; - - #[method(name = "unregister", param_kind = map)] - fn unregister( - &self, - account: Option, - #[allow(non_snake_case)] deleteAccount: bool, - ) -> Result; - - #[allow(non_snake_case)] - #[method(name = "updateAccount", param_kind = map)] - fn update_account( - &self, - account: Option, - deviceName: Option, - unrestrictedUnidentifiedSender: Option, - discoverableByNumber: Option, - numberSharing: Option, - ) -> Result; - - #[method(name = "updateConfiguration", param_kind = map)] - fn update_configuration( - &self, - account: Option, - #[allow(non_snake_case)] readReceipts: Option, - #[allow(non_snake_case)] unidentifiedDeliveryIndicators: Option, - #[allow(non_snake_case)] typingIndicators: Option, - #[allow(non_snake_case)] linkPreviews: Option, - ) -> Result; - - #[method(name = "updateContact", param_kind = map)] - fn update_contact( - &self, - account: Option, - recipient: String, - name: Option, - expiration: Option, - ) -> Result; - - #[method(name = "updateGroup", param_kind = map)] - fn update_group( - &self, - account: Option, - #[allow(non_snake_case)] groupId: Option, - name: Option, - description: Option, - avatar: Option, - member: Vec, - #[allow(non_snake_case)] removeMember: Vec, - admin: Vec, - #[allow(non_snake_case)] removeAdmin: Vec, - ban: Vec, - unban: Vec, - #[allow(non_snake_case)] resetLink: bool, - #[allow(non_snake_case)] link: Option, - #[allow(non_snake_case)] setPermissionAddMember: Option, - #[allow(non_snake_case)] setPermissionEditDetails: Option, - #[allow(non_snake_case)] setPermissionSendMessages: Option, - expiration: Option, - ) -> Result; - - #[method(name = "updateProfile", param_kind = map)] - fn update_profile( - &self, - account: Option, - #[allow(non_snake_case)] givenName: Option, - #[allow(non_snake_case)] familyName: Option, - about: Option, - #[allow(non_snake_case)] aboutEmoji: Option, - #[allow(non_snake_case)] mobileCoinAddress: Option, - avatar: Option, - #[allow(non_snake_case)] removeAvatar: bool, - ) -> Result; - - #[method(name = "uploadStickerPack", param_kind = map)] - fn upload_sticker_pack( - &self, - account: Option, - path: String, - ) -> Result; - - #[method(name = "verify", param_kind = map)] - fn verify( - &self, - account: Option, - #[allow(non_snake_case)] verificationCode: String, - pin: Option, - ) -> Result; - - #[subscription( - name = "subscribeReceive" => "receive", - unsubscribe = "unsubscribeReceive", - item = Value, - param_kind = map - )] + #[method(name = "trust", param_kind = map)]; + fn trust(; + &self,; + account: Option,; + recipient: String,; + #[allow(non_snake_case)] trustAllKnownKeys: bool,; + #[allow(non_snake_case)] verifiedSafetyNumber: Option,; + ) -> Result; + + #[method(name = "unblock", param_kind = map)]; + fn unblock(; + &self,; + account: Option,; + recipients: Vec,; + #[allow(non_snake_case)] groupIds: Vec,; + ) -> Result; + + #[method(name = "unregister", param_kind = map)]; + fn unregister(; + &self,; + account: Option,; + #[allow(non_snake_case)] deleteAccount: bool,; + ) -> Result; + + #[allow(non_snake_case)]; + #[method(name = "updateAccount", param_kind = map)]; + fn update_account(; + &self,; + account: Option,; + deviceName: Option,; + unrestrictedUnidentifiedSender: Option,; + discoverableByNumber: Option,; + numberSharing: Option,; + ) -> Result; + + #[method(name = "updateConfiguration", param_kind = map)]; + fn update_configuration(; + &self,; + account: Option,; + #[allow(non_snake_case)] readReceipts: Option,; + #[allow(non_snake_case)] unidentifiedDeliveryIndicators: Option,; + #[allow(non_snake_case)] typingIndicators: Option,; + #[allow(non_snake_case)] linkPreviews: Option,; + ) -> Result; + + #[method(name = "updateContact", param_kind = map)]; + fn update_contact(; + &self,; + account: Option,; + recipient: String,; + name: Option,; + expiration: Option,; + ) -> Result; + + #[method(name = "updateGroup", param_kind = map)]; + fn update_group(; + &self,; + account: Option,; + #[allow(non_snake_case)] groupId: Option,; + name: Option,; + description: Option,; + avatar: Option,; + member: Vec,; + #[allow(non_snake_case)] removeMember: Vec,; + admin: Vec,; + #[allow(non_snake_case)] removeAdmin: Vec,; + ban: Vec,; + unban: Vec,; + #[allow(non_snake_case)] resetLink: bool,; + #[allow(non_snake_case)] link: Option,; + #[allow(non_snake_case)] setPermissionAddMember: Option,; + #[allow(non_snake_case)] setPermissionEditDetails: Option,; + #[allow(non_snake_case)] setPermissionSendMessages: Option,; + expiration: Option,; + ) -> Result; + + #[method(name = "updateProfile", param_kind = map)]; + fn update_profile(; + &self,; + account: Option,; + #[allow(non_snake_case)] givenName: Option,; + #[allow(non_snake_case)] familyName: Option,; + about: Option,; + #[allow(non_snake_case)] aboutEmoji: Option,; + #[allow(non_snake_case)] mobileCoinAddress: Option,; + avatar: Option,; + #[allow(non_snake_case)] removeAvatar: bool,; + ) -> Result; + + #[method(name = "uploadStickerPack", param_kind = map)]; + fn upload_sticker_pack(; + &self,; + account: Option,; + path: String,; + ) -> Result; + + #[method(name = "verify", param_kind = map)]; + fn verify(; + &self,; + account: Option,; + #[allow(non_snake_case)] verificationCode: String,; + pin: Option,; + ) -> Result; + + #[subscription(; + name = "subscribeReceive" => "receive",; + unsubscribe = "unsubscribeReceive",; + item = Value,; + param_kind = map; + )]; async fn subscribe_receive(&self, account: Option) -> SubscriptionResult; - #[method(name = "version")] + #[method(name = "version")]; fn version(&self) -> Result; -} +}; -#[derive(Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct JsonLink { - pub device_link_uri: String, -} +#[derive(Deserialize)]; +#[serde(rename_all = "camelCase")]; +pub struct JsonLink {; + pub device_link_uri: String,; +}; -pub async fn connect_tcp( - tcp: impl ToSocketAddrs, -) -> Result { +pub async fn connect_tcp(; + tcp: impl ToSocketAddrs,; +) -> Result {; let (sender, receiver) = super::transports::tcp::connect(tcp).await?; - Ok(ClientBuilder::default().build_with_tokio(sender, receiver)) -} + Ok(ClientBuilder::default().build_with_tokio(sender, receiver)); +}; -pub async fn connect_unix( - socket_path: impl AsRef, -) -> Result { +pub async fn connect_unix(; + socket_path: impl AsRef,; +) -> Result {; let (sender, receiver) = super::transports::ipc::connect(socket_path).await?; - Ok(ClientBuilder::default().build_with_tokio(sender, receiver)) -} + Ok(ClientBuilder::default().build_with_tokio(sender, receiver)); +}; -pub async fn connect_http(uri: &str) -> Result { - HttpClientBuilder::default().build(uri) -} +pub async fn connect_http(uri: &str) -> Result {; + HttpClientBuilder::default().build(uri); +}; diff --git a/client/src/main.rs b/client/src/main.rs index 35c1ab229..f8ec24a31 100644 --- a/client/src/main.rs +++ b/client/src/main.rs @@ -11,7 +11,7 @@ use crate::cli::{CliCommands, GroupPermission, LinkState}; use crate::jsonrpc::RpcClient; mod cli; -#[allow(non_snake_case, clippy::too_many_arguments)] +#[allow(non_snake_case, clippy::too_many_arguments)]; mod jsonrpc; mod transports; @@ -19,494 +19,494 @@ const DEFAULT_TCP: &str = "127.0.0.1:7583"; const DEFAULT_SOCKET_SUFFIX: &str = "signal-cli/socket"; const DEFAULT_HTTP: &str = "http://localhost:8080/api/v1/rpc"; -#[tokio::main] -async fn main() -> Result<(), anyhow::Error> { +#[tokio::main]; +async fn main() -> Result<(), anyhow::Error> {; let cli = cli::Cli::parse(); let result = connect(cli).await; - match result { - Ok(Value::Null) => {} - Ok(v) => println!("{v}"), - Err(e) => return Err(anyhow::anyhow!("JSON-RPC command failed: {e:?}")), - } - Ok(()) -} + match result {; + Ok(Value::Null) => {}; + Ok(v) => println!("{v}"),; + Err(e) => return Err(anyhow::anyhow!("JSON-RPC command failed: {e:?}")),; + }; + Ok(()); +}; -async fn handle_command( - cli: Cli, - client: impl SubscriptionClientT + Sync, -) -> Result { - match cli.command { - CliCommands::Receive { timeout } => { +async fn handle_command(; + cli: Cli,; + client: impl SubscriptionClientT + Sync,; +) -> Result {; + match cli.command {; + CliCommands::Receive { timeout } => {; let mut stream = client.subscribe_receive(cli.account).await?; - { - while let Some(v) = stream_next(timeout, &mut stream).await { + {; + while let Some(v) = stream_next(timeout, &mut stream).await {; let v = v?; println!("{v}"); - } - } + }; + }; stream.unsubscribe().await?; - Ok(Value::Null) - } - CliCommands::AddDevice { uri } => client.add_device(cli.account, uri).await, - CliCommands::Block { - recipient, - group_id, - } => client.block(cli.account, recipient, group_id).await, - CliCommands::DeleteLocalAccountData { ignore_registered } => { - client - .delete_local_account_data(cli.account, ignore_registered) - .await - } - CliCommands::GetUserStatus { recipient } => { - client.get_user_status(cli.account, recipient).await - } - CliCommands::JoinGroup { uri } => client.join_group(cli.account, uri).await, - CliCommands::Link { name } => { - let url = client - .start_link(cli.account) - .await - .map_err(|e| RpcError::Custom(format!("JSON-RPC command startLink failed: {e:?}")))? + Ok(Value::Null); + }; + CliCommands::AddDevice { uri } => client.add_device(cli.account, uri).await,; + CliCommands::Block {; + recipient,; + group_id,; + } => client.block(cli.account, recipient, group_id).await,; + CliCommands::DeleteLocalAccountData { ignore_registered } => {; + client; + .delete_local_account_data(cli.account, ignore_registered); + .await; + }; + CliCommands::GetUserStatus { recipient } => {; + client.get_user_status(cli.account, recipient).await; + }; + CliCommands::JoinGroup { uri } => client.join_group(cli.account, uri).await,; + CliCommands::Link { name } => {; + let url = client; + .start_link(cli.account); + .await; + .map_err(|e| RpcError::Custom(format!("JSON-RPC command startLink failed: {e:?}")))?; .device_link_uri; println!("{}", url); - client.finish_link(url, name).await - } - CliCommands::ListAccounts => client.list_accounts().await, - CliCommands::ListContacts { - recipient, - all_recipients, - blocked, - name, - } => { - client - .list_contacts(cli.account, recipient, all_recipients, blocked, name) - .await - } - CliCommands::ListDevices => client.list_devices(cli.account).await, - CliCommands::ListGroups { - detailed: _, - group_id, - } => client.list_groups(cli.account, group_id).await, - CliCommands::ListIdentities { number } => client.list_identities(cli.account, number).await, - CliCommands::ListStickerPacks => client.list_sticker_packs(cli.account).await, - CliCommands::QuitGroup { - group_id, - delete, - admin, - } => { - client - .quit_group(cli.account, group_id, delete, admin) - .await - } - CliCommands::Register { voice, captcha } => { - client.register(cli.account, voice, captcha).await - } - CliCommands::RemoveContact { - recipient, - forget, - hide, - } => { - client - .remove_contact(cli.account, recipient, forget, hide) - .await - } - CliCommands::RemoveDevice { device_id } => { - client.remove_device(cli.account, device_id).await - } - CliCommands::RemovePin => client.remove_pin(cli.account).await, - CliCommands::RemoteDelete { - target_timestamp, - recipient, - group_id, - note_to_self, - } => { - client - .remote_delete( - cli.account, - target_timestamp, - recipient, - group_id, - note_to_self, - ) - .await - } - CliCommands::Send { - recipient, - group_id, - note_to_self, - end_session, - message, - attachment, - mention, - text_style, - quote_timestamp, - quote_author, - quote_message, - quote_mention, - quote_text_style, - quote_attachment, - preview_url, - preview_title, - preview_description, - preview_image, - sticker, - story_timestamp, - story_author, - edit_timestamp, - } => { - client - .send( - cli.account, - recipient, - group_id, - note_to_self, - end_session, - message.unwrap_or_default(), - attachment, - mention, - text_style, - quote_timestamp, - quote_author, - quote_message, - quote_mention, - quote_text_style, - quote_attachment, - preview_url, - preview_title, - preview_description, - preview_image, - sticker, - story_timestamp, - story_author, - edit_timestamp, - ) - .await - } - CliCommands::SendContacts => client.send_contacts(cli.account).await, - CliCommands::SendPaymentNotification { - recipient, - receipt, - note, - } => { - client - .send_payment_notification(cli.account, recipient, receipt, note) - .await - } - CliCommands::SendReaction { - recipient, - group_id, - note_to_self, - emoji, - target_author, - target_timestamp, - remove, - story, - } => { - client - .send_reaction( - cli.account, - recipient, - group_id, - note_to_self, - emoji, - target_author, - target_timestamp, - remove, - story, - ) - .await - } - CliCommands::SendReceipt { - recipient, - target_timestamp, - r#type, - } => { - client - .send_receipt( - cli.account, - recipient, - target_timestamp, - match r#type { - cli::ReceiptType::Read => "read".to_owned(), - cli::ReceiptType::Viewed => "viewed".to_owned(), - }, - ) - .await - } - CliCommands::SendSyncRequest => client.send_sync_request(cli.account).await, - CliCommands::SendTyping { - recipient, - group_id, - stop, - } => { - client - .send_typing(cli.account, recipient, group_id, stop) - .await - } - CliCommands::SetPin { pin } => client.set_pin(cli.account, pin).await, - CliCommands::SubmitRateLimitChallenge { challenge, captcha } => { - client - .submit_rate_limit_challenge(cli.account, challenge, captcha) - .await - } - CliCommands::Trust { - recipient, - trust_all_known_keys, - verified_safety_number, - } => { - client - .trust( - cli.account, - recipient, - trust_all_known_keys, - verified_safety_number, - ) - .await - } - CliCommands::Unblock { - recipient, - group_id, - } => client.unblock(cli.account, recipient, group_id).await, - CliCommands::Unregister { delete_account } => { - client.unregister(cli.account, delete_account).await - } - CliCommands::UpdateAccount { - device_name, - unrestricted_unidentified_sender, - discoverable_by_number, - number_sharing, - } => { - client - .update_account( - cli.account, - device_name, - unrestricted_unidentified_sender, - discoverable_by_number, - number_sharing, - ) - .await - } - CliCommands::UpdateConfiguration { - read_receipts, - unidentified_delivery_indicators, - typing_indicators, - link_previews, - } => { - client - .update_configuration( - cli.account, - read_receipts, - unidentified_delivery_indicators, - typing_indicators, - link_previews, - ) - .await - } - CliCommands::UpdateContact { - recipient, - expiration, - name, - } => { - client - .update_contact(cli.account, recipient, name, expiration) - .await - } - CliCommands::UpdateGroup { - group_id, - name, - description, - avatar, - member, - remove_member, - admin, - remove_admin, - ban, - unban, - reset_link, - link, - set_permission_add_member, - set_permission_edit_details, - set_permission_send_messages, - expiration, - } => { - client - .update_group( - cli.account, - group_id, - name, - description, - avatar, - member, - remove_member, - admin, - remove_admin, - ban, - unban, - reset_link, - link.map(|link| match link { - LinkState::Enabled => "enabled".to_owned(), - LinkState::EnabledWithApproval => "enabledWithApproval".to_owned(), - LinkState::Disabled => "disabled".to_owned(), - }), - set_permission_add_member.map(|p| match p { - GroupPermission::EveryMember => "everyMember".to_owned(), - GroupPermission::OnlyAdmins => "onlyAdmins".to_owned(), - }), - set_permission_edit_details.map(|p| match p { - GroupPermission::EveryMember => "everyMember".to_owned(), - GroupPermission::OnlyAdmins => "onlyAdmins".to_owned(), - }), - set_permission_send_messages.map(|p| match p { - GroupPermission::EveryMember => "everyMember".to_owned(), - GroupPermission::OnlyAdmins => "onlyAdmins".to_owned(), - }), - expiration, - ) - .await - } - CliCommands::UpdateProfile { - given_name, - family_name, - about, - about_emoji, - mobile_coin_address, - avatar, - remove_avatar, - } => { - client - .update_profile( - cli.account, - given_name, - family_name, - about, - about_emoji, - mobile_coin_address, - avatar, - remove_avatar, - ) - .await - } - CliCommands::UploadStickerPack { path } => { - client.upload_sticker_pack(cli.account, path).await - } - CliCommands::Verify { - verification_code, - pin, - } => client.verify(cli.account, verification_code, pin).await, - CliCommands::Version => client.version().await, - CliCommands::AddStickerPack { uri } => client.add_sticker_pack(cli.account, uri).await, - CliCommands::FinishChangeNumber { - number, - verification_code, - pin, - } => { - client - .finish_change_number(cli.account, number, verification_code, pin) - .await - } - CliCommands::GetAttachment { - id, - recipient, - group_id, - } => { - client - .get_attachment(cli.account, id, recipient, group_id) - .await - } - CliCommands::GetAvatar { - contact, - profile, - group_id, - } => { - client - .get_avatar(cli.account, contact, profile, group_id) - .await - } - CliCommands::GetSticker { - pack_id, - sticker_id, - } => client.get_sticker(cli.account, pack_id, sticker_id).await, - CliCommands::StartChangeNumber { - number, - voice, - captcha, - } => { - client - .start_change_number(cli.account, number, voice, captcha) - .await - } - CliCommands::SendMessageRequestResponse { - recipient, - group_id, - r#type, - } => { - client - .send_message_request_response( - cli.account, - recipient, - group_id, - match r#type { - cli::MessageRequestResponseType::Accept => "accept".to_owned(), - cli::MessageRequestResponseType::Delete => "delete".to_owned(), - }, - ) - .await - } - } -} + client.finish_link(url, name).await; + }; + CliCommands::ListAccounts => client.list_accounts().await,; + CliCommands::ListContacts {; + recipient,; + all_recipients,; + blocked,; + name,; + } => {; + client; + .list_contacts(cli.account, recipient, all_recipients, blocked, name); + .await; + }; + CliCommands::ListDevices => client.list_devices(cli.account).await,; + CliCommands::ListGroups {; + detailed: _,; + group_id,; + } => client.list_groups(cli.account, group_id).await,; + CliCommands::ListIdentities { number } => client.list_identities(cli.account, number).await,; + CliCommands::ListStickerPacks => client.list_sticker_packs(cli.account).await,; + CliCommands::QuitGroup {; + group_id,; + delete,; + admin,; + } => {; + client; + .quit_group(cli.account, group_id, delete, admin); + .await; + }; + CliCommands::Register { voice, captcha } => {; + client.register(cli.account, voice, captcha).await; + }; + CliCommands::RemoveContact {; + recipient,; + forget,; + hide,; + } => {; + client; + .remove_contact(cli.account, recipient, forget, hide); + .await; + }; + CliCommands::RemoveDevice { device_id } => {; + client.remove_device(cli.account, device_id).await; + }; + CliCommands::RemovePin => client.remove_pin(cli.account).await,; + CliCommands::RemoteDelete {; + target_timestamp,; + recipient,; + group_id,; + note_to_self,; + } => {; + client; + .remote_delete(; + cli.account,; + target_timestamp,; + recipient,; + group_id,; + note_to_self,; + ); + .await; + }; + CliCommands::Send {; + recipient,; + group_id,; + note_to_self,; + end_session,; + message,; + attachment,; + mention,; + text_style,; + quote_timestamp,; + quote_author,; + quote_message,; + quote_mention,; + quote_text_style,; + quote_attachment,; + preview_url,; + preview_title,; + preview_description,; + preview_image,; + sticker,; + story_timestamp,; + story_author,; + edit_timestamp,; + } => {; + client; + .send(; + cli.account,; + recipient,; + group_id,; + note_to_self,; + end_session,; + message.unwrap_or_default(),; + attachment,; + mention,; + text_style,; + quote_timestamp,; + quote_author,; + quote_message,; + quote_mention,; + quote_text_style,; + quote_attachment,; + preview_url,; + preview_title,; + preview_description,; + preview_image,; + sticker,; + story_timestamp,; + story_author,; + edit_timestamp,; + ); + .await; + }; + CliCommands::SendContacts => client.send_contacts(cli.account).await,; + CliCommands::SendPaymentNotification {; + recipient,; + receipt,; + note,; + } => {; + client; + .send_payment_notification(cli.account, recipient, receipt, note); + .await; + }; + CliCommands::SendReaction {; + recipient,; + group_id,; + note_to_self,; + emoji,; + target_author,; + target_timestamp,; + remove,; + story,; + } => {; + client; + .send_reaction(; + cli.account,; + recipient,; + group_id,; + note_to_self,; + emoji,; + target_author,; + target_timestamp,; + remove,; + story,; + ); + .await; + }; + CliCommands::SendReceipt {; + recipient,; + target_timestamp,; + r#type,; + } => {; + client; + .send_receipt(; + cli.account,; + recipient,; + target_timestamp,; + match r#type {; + cli::ReceiptType::Read => "read".to_owned(),; + cli::ReceiptType::Viewed => "viewed".to_owned(),; + },; + ); + .await; + }; + CliCommands::SendSyncRequest => client.send_sync_request(cli.account).await,; + CliCommands::SendTyping {; + recipient,; + group_id,; + stop,; + } => {; + client; + .send_typing(cli.account, recipient, group_id, stop); + .await; + }; + CliCommands::SetPin { pin } => client.set_pin(cli.account, pin).await,; + CliCommands::SubmitRateLimitChallenge { challenge, captcha } => {; + client; + .submit_rate_limit_challenge(cli.account, challenge, captcha); + .await; + }; + CliCommands::Trust {; + recipient,; + trust_all_known_keys,; + verified_safety_number,; + } => {; + client; + .trust(; + cli.account,; + recipient,; + trust_all_known_keys,; + verified_safety_number,; + ); + .await; + }; + CliCommands::Unblock {; + recipient,; + group_id,; + } => client.unblock(cli.account, recipient, group_id).await,; + CliCommands::Unregister { delete_account } => {; + client.unregister(cli.account, delete_account).await; + }; + CliCommands::UpdateAccount {; + device_name,; + unrestricted_unidentified_sender,; + discoverable_by_number,; + number_sharing,; + } => {; + client; + .update_account(; + cli.account,; + device_name,; + unrestricted_unidentified_sender,; + discoverable_by_number,; + number_sharing,; + ); + .await; + }; + CliCommands::UpdateConfiguration {; + read_receipts,; + unidentified_delivery_indicators,; + typing_indicators,; + link_previews,; + } => {; + client; + .update_configuration(; + cli.account,; + read_receipts,; + unidentified_delivery_indicators,; + typing_indicators,; + link_previews,; + ); + .await; + }; + CliCommands::UpdateContact {; + recipient,; + expiration,; + name,; + } => {; + client; + .update_contact(cli.account, recipient, name, expiration); + .await; + }; + CliCommands::UpdateGroup {; + group_id,; + name,; + description,; + avatar,; + member,; + remove_member,; + admin,; + remove_admin,; + ban,; + unban,; + reset_link,; + link,; + set_permission_add_member,; + set_permission_edit_details,; + set_permission_send_messages,; + expiration,; + } => {; + client; + .update_group(; + cli.account,; + group_id,; + name,; + description,; + avatar,; + member,; + remove_member,; + admin,; + remove_admin,; + ban,; + unban,; + reset_link,; + link.map(|link| match link {; + LinkState::Enabled => "enabled".to_owned(),; + LinkState::EnabledWithApproval => "enabledWithApproval".to_owned(),; + LinkState::Disabled => "disabled".to_owned(),; + }),; + set_permission_add_member.map(|p| match p {; + GroupPermission::EveryMember => "everyMember".to_owned(),; + GroupPermission::OnlyAdmins => "onlyAdmins".to_owned(),; + }),; + set_permission_edit_details.map(|p| match p {; + GroupPermission::EveryMember => "everyMember".to_owned(),; + GroupPermission::OnlyAdmins => "onlyAdmins".to_owned(),; + }),; + set_permission_send_messages.map(|p| match p {; + GroupPermission::EveryMember => "everyMember".to_owned(),; + GroupPermission::OnlyAdmins => "onlyAdmins".to_owned(),; + }),; + expiration,; + ); + .await; + }; + CliCommands::UpdateProfile {; + given_name,; + family_name,; + about,; + about_emoji,; + mobile_coin_address,; + avatar,; + remove_avatar,; + } => {; + client; + .update_profile(; + cli.account,; + given_name,; + family_name,; + about,; + about_emoji,; + mobile_coin_address,; + avatar,; + remove_avatar,; + ); + .await; + }; + CliCommands::UploadStickerPack { path } => {; + client.upload_sticker_pack(cli.account, path).await; + }; + CliCommands::Verify {; + verification_code,; + pin,; + } => client.verify(cli.account, verification_code, pin).await,; + CliCommands::Version => client.version().await,; + CliCommands::AddStickerPack { uri } => client.add_sticker_pack(cli.account, uri).await,; + CliCommands::FinishChangeNumber {; + number,; + verification_code,; + pin,; + } => {; + client; + .finish_change_number(cli.account, number, verification_code, pin); + .await; + }; + CliCommands::GetAttachment {; + id,; + recipient,; + group_id,; + } => {; + client; + .get_attachment(cli.account, id, recipient, group_id); + .await; + }; + CliCommands::GetAvatar {; + contact,; + profile,; + group_id,; + } => {; + client; + .get_avatar(cli.account, contact, profile, group_id); + .await; + }; + CliCommands::GetSticker {; + pack_id,; + sticker_id,; + } => client.get_sticker(cli.account, pack_id, sticker_id).await,; + CliCommands::StartChangeNumber {; + number,; + voice,; + captcha,; + } => {; + client; + .start_change_number(cli.account, number, voice, captcha); + .await; + }; + CliCommands::SendMessageRequestResponse {; + recipient,; + group_id,; + r#type,; + } => {; + client; + .send_message_request_response(; + cli.account,; + recipient,; + group_id,; + match r#type {; + cli::MessageRequestResponseType::Accept => "accept".to_owned(),; + cli::MessageRequestResponseType::Delete => "delete".to_owned(),; + },; + ); + .await; + }; + }; +}; -async fn connect(cli: Cli) -> Result { - if let Some(http) = &cli.json_rpc_http { - let uri = if let Some(uri) = http { - uri - } else { - DEFAULT_HTTP +async fn connect(cli: Cli) -> Result {; + if let Some(http) = &cli.json_rpc_http {; + let uri = if let Some(uri) = http {; + uri; + } else {; + DEFAULT_HTTP; }; - let client = jsonrpc::connect_http(uri) - .await + let client = jsonrpc::connect_http(uri); + .await; .map_err(|e| RpcError::Custom(format!("Failed to connect to socket: {e}")))?; - handle_command(cli, client).await - } else if let Some(tcp) = cli.json_rpc_tcp { + handle_command(cli, client).await; + } else if let Some(tcp) = cli.json_rpc_tcp {; let socket_addr = tcp.unwrap_or_else(|| DEFAULT_TCP.parse().unwrap()); - let client = jsonrpc::connect_tcp(socket_addr) - .await + let client = jsonrpc::connect_tcp(socket_addr); + .await; .map_err(|e| RpcError::Custom(format!("Failed to connect to socket: {e}")))?; - handle_command(cli, client).await - } else { - let socket_path = cli - .json_rpc_socket - .clone() - .unwrap_or(None) - .or_else(|| { - std::env::var_os("XDG_RUNTIME_DIR").map(|runtime_dir| { - PathBuf::from(runtime_dir) - .join(DEFAULT_SOCKET_SUFFIX) - .into() - }) - }) + handle_command(cli, client).await; + } else {; + let socket_path = cli; + .json_rpc_socket; + .clone(); + .unwrap_or(None); + .or_else(|| {; + std::env::var_os("XDG_RUNTIME_DIR").map(|runtime_dir| {; + PathBuf::from(runtime_dir); + .join(DEFAULT_SOCKET_SUFFIX); + .into(); + }); + }); .unwrap_or_else(|| ("/run".to_owned() + DEFAULT_SOCKET_SUFFIX).into()); - let client = jsonrpc::connect_unix(socket_path) - .await + let client = jsonrpc::connect_unix(socket_path); + .await; .map_err(|e| RpcError::Custom(format!("Failed to connect to socket: {e}")))?; - handle_command(cli, client).await - } -} + handle_command(cli, client).await; + }; +}; -async fn stream_next( - timeout: f64, - stream: &mut Subscription, -) -> Option> { - if timeout < 0.0 { - stream.next().await - } else { - select! { - v = stream.next() => v, - _= sleep(Duration::from_millis((timeout * 1000.0) as u64)) => None, - } - } -} +async fn stream_next(; + timeout: f64,; + stream: &mut Subscription,; +) -> Option> {; + if timeout < 0.0 {; + stream.next().await; + } else {; + select! {; + v = stream.next() => v,; + _= sleep(Duration::from_millis((timeout * 1000.0) as u64)) => None,; + }; + }; +}; diff --git a/client/src/transports/ipc.rs b/client/src/transports/ipc.rs index b14063aad..6febc64c4 100644 --- a/client/src/transports/ipc.rs +++ b/client/src/transports/ipc.rs @@ -9,15 +9,15 @@ use tokio_util::codec::Decoder; use super::stream_codec::StreamCodec; use super::{Receiver, Sender}; -/// Connect to a JSON-RPC Unix Socket server. -pub async fn connect( - socket: impl AsRef, -) -> Result<(impl TransportSenderT + Send, impl TransportReceiverT + Send), Error> { +/// Connect to a JSON-RPC Unix Socket server.; +pub async fn connect(; + socket: impl AsRef,; +) -> Result<(impl TransportSenderT + Send, impl TransportReceiverT + Send), Error> {; let connection = UnixStream::connect(socket).await?; let (sink, stream) = StreamCodec::stream_incoming().framed(connection).split(); let sender = Sender { inner: sink }; let receiver = Receiver { inner: stream }; - Ok((sender, receiver)) -} + Ok((sender, receiver)); +}; diff --git a/client/src/transports/mod.rs b/client/src/transports/mod.rs index 04f4390fc..81be75815 100644 --- a/client/src/transports/mod.rs +++ b/client/src/transports/mod.rs @@ -1,7 +1,7 @@ use futures_util::{stream::StreamExt, Sink, SinkExt, Stream}; -use jsonrpsee::core::{ - async_trait, - client::{ReceivedMessage, TransportReceiverT, TransportSenderT}, +use jsonrpsee::core::{; + async_trait,; + client::{ReceivedMessage, TransportReceiverT, TransportSenderT},; }; use thiserror::Error; @@ -9,56 +9,56 @@ pub mod ipc; mod stream_codec; pub mod tcp; -#[derive(Debug, Error)] -enum Errors { - #[error("Other: {0}")] - Other(String), - #[error("Closed")] - Closed, -} +#[derive(Debug, Error)]; +enum Errors {; + #[error("Other: {0}")]; + Other(String),; + #[error("Closed")]; + Closed,; +}; -struct Sender> { - inner: T, -} +struct Sender> {; + inner: T,; +}; -#[async_trait] -impl + Unpin + 'static> TransportSenderT - for Sender -{ +#[async_trait]; +impl + Unpin + 'static> TransportSenderT; + for Sender; +{; type Error = Errors; - async fn send(&mut self, body: String) -> Result<(), Self::Error> { - self.inner - .send(body) - .await + async fn send(&mut self, body: String) -> Result<(), Self::Error> {; + self.inner; + .send(body); + .await; .map_err(|e| Errors::Other(format!("{:?}", e)))?; - Ok(()) - } + Ok(()); + }; - async fn close(&mut self) -> Result<(), Self::Error> { - self.inner - .close() - .await + async fn close(&mut self) -> Result<(), Self::Error> {; + self.inner; + .close(); + .await; .map_err(|e| Errors::Other(format!("{:?}", e)))?; - Ok(()) - } -} + Ok(()); + }; +}; -struct Receiver { - inner: T, -} +struct Receiver {; + inner: T,; +}; -#[async_trait] -impl> + Unpin + 'static> TransportReceiverT - for Receiver -{ +#[async_trait]; +impl> + Unpin + 'static> TransportReceiverT; + for Receiver; +{; type Error = Errors; - async fn receive(&mut self) -> Result { - match self.inner.next().await { - None => Err(Errors::Closed), - Some(Ok(msg)) => Ok(ReceivedMessage::Text(msg)), - Some(Err(e)) => Err(Errors::Other(format!("{:?}", e))), - } - } -} + async fn receive(&mut self) -> Result {; + match self.inner.next().await {; + None => Err(Errors::Closed),; + Some(Ok(msg)) => Ok(ReceivedMessage::Text(msg)),; + Some(Err(e)) => Err(Errors::Other(format!("{:?}", e))),; + }; + }; +}; diff --git a/client/src/transports/stream_codec.rs b/client/src/transports/stream_codec.rs index 6f77306f6..c71f25e15 100644 --- a/client/src/transports/stream_codec.rs +++ b/client/src/transports/stream_codec.rs @@ -4,58 +4,58 @@ use tokio_util::codec::{Decoder, Encoder}; type Separator = u8; -/// Stream codec for streaming protocols (ipc, tcp) -#[derive(Debug, Default)] -pub struct StreamCodec { - incoming_separator: Separator, - outgoing_separator: Separator, -} - -impl StreamCodec { - /// Default codec with streaming input data. Input can be both enveloped and not. - pub fn stream_incoming() -> Self { - StreamCodec::new(b'\n', b'\n') - } - - /// New custom stream codec - pub fn new(incoming_separator: Separator, outgoing_separator: Separator) -> Self { - StreamCodec { - incoming_separator, - outgoing_separator, - } - } -} - -impl Decoder for StreamCodec { +/// Stream codec for streaming protocols (ipc, tcp); +#[derive(Debug, Default)]; +pub struct StreamCodec {; + incoming_separator: Separator,; + outgoing_separator: Separator,; +}; + +impl StreamCodec {; + /// Default codec with streaming input data. Input can be both enveloped and not.; + pub fn stream_incoming() -> Self {; + StreamCodec::new(b'\n', b'\n'); + }; + + /// New custom stream codec; + pub fn new(incoming_separator: Separator, outgoing_separator: Separator) -> Self {; + StreamCodec {; + incoming_separator,; + outgoing_separator,; + }; + }; +}; + +impl Decoder for StreamCodec {; type Item = String; type Error = io::Error; - fn decode(&mut self, buf: &mut BytesMut) -> io::Result> { - if let Some(i) = buf - .as_ref() - .iter() - .position(|&b| b == self.incoming_separator) - { + fn decode(&mut self, buf: &mut BytesMut) -> io::Result> {; + if let Some(i) = buf; + .as_ref(); + .iter(); + .position(|&b| b == self.incoming_separator); + {; let line = buf.split_to(i); let _ = buf.split_to(1); - match str::from_utf8(line.as_ref()) { - Ok(s) => Ok(Some(s.to_string())), - Err(_) => Err(io::Error::new(io::ErrorKind::Other, "invalid UTF-8")), - } - } else { - Ok(None) - } - } -} - -impl Encoder for StreamCodec { + match str::from_utf8(line.as_ref()) {; + Ok(s) => Ok(Some(s.to_string())),; + Err(_) => Err(io::Error::new(io::ErrorKind::Other, "invalid UTF-8")),; + }; + } else {; + Ok(None); + }; + }; +}; + +impl Encoder for StreamCodec {; type Error = io::Error; - fn encode(&mut self, msg: String, buf: &mut BytesMut) -> io::Result<()> { + fn encode(&mut self, msg: String, buf: &mut BytesMut) -> io::Result<()> {; let mut payload = msg.into_bytes(); payload.push(self.outgoing_separator); buf.extend_from_slice(&payload); - Ok(()) - } -} + Ok(()); + }; +}; diff --git a/client/src/transports/tcp.rs b/client/src/transports/tcp.rs index ae80759fe..5ccfc1d67 100644 --- a/client/src/transports/tcp.rs +++ b/client/src/transports/tcp.rs @@ -8,15 +8,15 @@ use tokio_util::codec::Decoder; use super::stream_codec::StreamCodec; use super::{Receiver, Sender}; -/// Connect to a JSON-RPC TCP server. -pub async fn connect( - socket: impl ToSocketAddrs, -) -> Result<(impl TransportSenderT + Send, impl TransportReceiverT + Send), Error> { +/// Connect to a JSON-RPC TCP server.; +pub async fn connect(; + socket: impl ToSocketAddrs,; +) -> Result<(impl TransportSenderT + Send, impl TransportReceiverT + Send), Error> {; let connection = TcpStream::connect(socket).await?; let (sink, stream) = StreamCodec::stream_incoming().framed(connection).split(); let sender = Sender { inner: sink }; let receiver = Receiver { inner: stream }; - Ok((sender, receiver)) -} + Ok((sender, receiver)); +}; diff --git a/fix_and_enhance.py b/fix_and_enhance.py new file mode 100644 index 000000000..b95bc346f --- /dev/null +++ b/fix_and_enhance.py @@ -0,0 +1,84 @@ +# Renames --mobilecoin-address to --mobilecoin-address across the repository. +# Adds an alias for backward compatibility. +# Fixes the missing semicolon issue in the Rust code. +# Introduces a new feature: a script for generating a configuration template for Signal-CLI to make setup easier. +# Aaron Surina December 31, 2024 +# +import os +import subprocess +import re + +# Directory and file extensions to process +TARGET_EXTENSIONS = ['.rs', '.java', '.md', '.py'] +MISSING_SEMICOLON_PATTERN = r'([^\s;])\n' +MOBILECOIN_PATTERN = r'--mobilecoin-address' +REPLACEMENT_ALIAS = '--mobilecoin-address' + +# Function to replace text in files +def replace_in_file(file_path, pattern, replacement): + with open(file_path, 'r', encoding='utf-8') as file: + content = file.read() + + updated_content = re.sub(pattern, replacement, content) + + with open(file_path, 'w', encoding='utf-8') as file: + file.write(updated_content) + +# Function to process files recursively +def process_files(directory): + for root, _, files in os.walk(directory): + for file_name in files: + file_path = os.path.join(root, file_name) + if any(file_name.endswith(ext) for ext in TARGET_EXTENSIONS): + # Fix mobile-coin-address issues + replace_in_file(file_path, MOBILECOIN_PATTERN, REPLACEMENT_ALIAS) + # Fix missing semicolons in Rust files + if file_name.endswith('.rs'): + replace_in_file(file_path, MISSING_SEMICOLON_PATTERN, r'\1;\n') + +# Add a cool new feature: configuration template generator +def add_config_template_script(): + script_content = """ +#!/bin/bash + +echo "Generating Signal-CLI configuration template..." +CONFIG_TEMPLATE="config-template.yml" + +cat < $CONFIG_TEMPLATE +# Signal-CLI Configuration Template +# Replace values with your own preferences + +signal-cli: + user: "" + storage-path: "" + message-retry: 3 + enable-notifications: true + +# Add more options as needed +EOL + +echo "Configuration template created at $CONFIG_TEMPLATE" +""" + + with open('generate_config.sh', 'w') as file: + file.write(script_content) + + # Make the script executable + os.chmod('generate_config.sh', 0o755) + +# Commit changes +def commit_changes(): + subprocess.run(['git', 'add', '.'], check=True) + subprocess.run(['git', 'commit', '-m', 'Fix mobilecoin issues and add config template script'], check=True) + +if __name__ == "__main__": + print("Processing repository files...") + process_files(os.getcwd()) + + print("Adding configuration template script...") + add_config_template_script() + + print("Committing changes...") + commit_changes() + + print("All changes applied and committed!") diff --git a/generate_config.sh b/generate_config.sh new file mode 100755 index 000000000..76201ee82 --- /dev/null +++ b/generate_config.sh @@ -0,0 +1,20 @@ + +#!/bin/bash + +echo "Generating Signal-CLI configuration template..." +CONFIG_TEMPLATE="config-template.yml" + +cat < $CONFIG_TEMPLATE +# Signal-CLI Configuration Template +# Replace values with your own preferences + +signal-cli: + user: "" + storage-path: "" + message-retry: 3 + enable-notifications: true + +# Add more options as needed +EOL + +echo "Configuration template created at $CONFIG_TEMPLATE" diff --git a/src/main/java/org/asamk/signal/commands/UpdateProfileCommand.java b/src/main/java/org/asamk/signal/commands/UpdateProfileCommand.java index b122f58c6..da055bb26 100644 --- a/src/main/java/org/asamk/signal/commands/UpdateProfileCommand.java +++ b/src/main/java/org/asamk/signal/commands/UpdateProfileCommand.java @@ -27,7 +27,7 @@ public void attachToSubparser(final Subparser subparser) { subparser.addArgument("--family-name").help("New profile family name (optional)"); subparser.addArgument("--about").help("New profile about text"); subparser.addArgument("--about-emoji").help("New profile about emoji"); - subparser.addArgument("--mobile-coin-address").help("New MobileCoin address (Base64 encoded public address)"); + subparser.addArgument("--mobilecoin-address").help("New MobileCoin address (Base64 encoded public address)"); final var avatarOptions = subparser.addMutuallyExclusiveGroup(); avatarOptions.addArgument("--avatar").help("Path to new profile avatar"); diff --git a/web-messaging/etc_logrotate.d_signal-cli b/web-messaging/etc_logrotate.d_signal-cli new file mode 100644 index 000000000..d93ea7ddd --- /dev/null +++ b/web-messaging/etc_logrotate.d_signal-cli @@ -0,0 +1,6 @@ +/var/www/html/example.org/*.txt { + rotate 12 + weekly + compress + missingok +} diff --git a/web-messaging/index.php b/web-messaging/index.php new file mode 100644 index 000000000..8cebd633f --- /dev/null +++ b/web-messaging/index.php @@ -0,0 +1,220 @@ + + $parts[0], + 'message' => $parts[1], + ]; + } + } + } + } + return $messages; +} + +// Function to fetch Signal messages from the log file +function get_signal_messages($log_file) { + $messages = []; + if (file_exists($log_file)) { + $messages_raw = file_get_contents($log_file); + $messages_lines = explode("\n", $messages_raw); + foreach ($messages_lines as $line) { + if (trim($line)) { + $messages[] = $line; + } + } + } + return $messages; +} + +// Function to send a Signal message +function send_signal_message($recipient_number, $message, $signalCliPath, $signalNumber) { + $recipient_number = escapeshellarg($recipient_number); + $message = escapeshellarg($message); + $command = "$signalCliPath -u $signalNumber send -m $message $recipient_number"; + exec($command, $output, $return_var); + return $return_var === 0; +} + +// Handle posting a new local message +if (isset($_SESSION['authenticated']) && $_SESSION['authenticated'] === true && isset($_POST['message'])) { + $message = trim($_POST['message']); + if (!empty($message) && substr($message, -3) === '123') { + $cleaned_message = rtrim($message, '123'); + $timestamp = date('Y-m-d H:i:s'); + $entry = "$timestamp|$cleaned_message\n"; + file_put_contents($message_file, $entry, FILE_APPEND | LOCK_EX); + } +} + +// Handle sending a Signal message +$signal_message_status = ''; +if (isset($_SESSION['authenticated']) && $_SESSION['authenticated'] === true && isset($_POST['send_signal'])) { + $recipient_number = $_POST['recipient_number'] ?? $default_recipient_number; + $message = $_POST['signal_message'] ?? ''; + if (send_signal_message($recipient_number, $message, $signalCliPath, $signalNumber)) { + $signal_message_status = "Message sent successfully to $recipient_number."; + } else { + $signal_message_status = "Failed to send the message."; + } +} + +// Fetch messages for display +$site_messages = get_site_messages($message_file); +$signal_messages = get_signal_messages($signal_log_file); +?> + + + + + + + Family Center + + + +

Family Center

+ + + +
+ +
+ + + +
+ +
+
+ +
+
+ +
+
+

Messages Posted Locally:

+ + +
+
+ +
+ + +

No messages posted yet.

+ +
+ +
+

Signal Messages:

+ + +
+ +
+ + +

No Signal messages received yet.

+ +
+
+ +
+ + + +
+ +
+ + + + + +
+ + +
+ + + + diff --git a/web-messaging/signal-parser-webmessaging.sh b/web-messaging/signal-parser-webmessaging.sh new file mode 100644 index 000000000..6fc5724df --- /dev/null +++ b/web-messaging/signal-parser-webmessaging.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# This script was authored by Aaron Surina in December 2024. +# This script was created to allow my children to communicate with me while with their mother and her boyfriend +# This script is to prevent further abuse of parental rights and to curb the massive attempts at alienating a fit and loving father from his children. +# Thank you for participating in the revolution. +# I dedicate this work to the resilience and perserverance of my two sons David and Andrew. +# I believe in you and I love you forever and always. +# You can do anything you set your mind to. +# +# End family court corruption. Hold false witness accountable. +# Disbarr unethical attorneys in family courts. +# +export SIGNAL_NUMBER="+12085551212" +signal-cli -a $SIGNAL_NUMBER -v receive \ +|awk 'BEGIN { OFS=" - "; } + /Envelope from:/ { + from = $3; # Capture the sender phone number + } + /Timestamp:/ && /2024-/ { + timestamp = substr($0, index($0, "2024-")); # Extract human-readable timestamp + } + /Body:/ { + body = substr($0, index($0, "Body:") + 6); # Capture the message body + print timestamp, from, body; # Print timestamp, sender, and message body + from=""; body=""; timestamp=""; # Reset values + }' |tee -a /var/log/signal.log &