-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Impl group_index::c2c_report_message + add variant (#4723)
- Loading branch information
Showing
7 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,5 @@ pub struct Args { | |
pub enum Response { | ||
Success, | ||
AlreadyReported, | ||
InternalError(String), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
backend/canisters/group_index/impl/src/updates/c2c_report_message.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use crate::guards::caller_is_group_or_community_canister; | ||
use crate::read_state; | ||
use canister_api_macros::update_msgpack; | ||
use canister_tracing_macros::trace; | ||
use group_index_canister::c2c_report_message::{Response::*, *}; | ||
|
||
#[update_msgpack(guard = "caller_is_group_or_community_canister")] | ||
#[trace] | ||
async fn c2c_report_message(args: Args) -> Response { | ||
let user_index_canister_id = read_state(|state| state.data.user_index_canister_id); | ||
|
||
let c2c_args = user_index_canister::c2c_report_message::Args { | ||
chat_id: args.chat_id.into(), | ||
reporter: args.reporter, | ||
thread_root_message_index: args.thread_root_message_index, | ||
message: args.message, | ||
reason_code: args.reason_code, | ||
notes: args.notes, | ||
already_deleted: args.already_deleted, | ||
}; | ||
|
||
match user_index_canister_c2c_client::c2c_report_message(user_index_canister_id, &c2c_args).await { | ||
Ok(user_index_canister::c2c_report_message::Response::Success) => Success, | ||
Ok(user_index_canister::c2c_report_message::Response::AlreadyReported) => AlreadyReported, | ||
Err(error) => InternalError(format!("{error:?}")), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters