-
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.
Export members from stable memory when importing group into community (…
- Loading branch information
Showing
16 changed files
with
185 additions
and
15 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
29 changes: 29 additions & 0 deletions
29
backend/canisters/group/api/src/updates/c2c_export_group_members.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,29 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use serde_bytes::ByteBuf; | ||
use std::fmt::{Debug, Formatter}; | ||
use types::UserId; | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub struct Args { | ||
pub after: Option<UserId>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug)] | ||
pub enum Response { | ||
Success(SuccessResult), | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct SuccessResult { | ||
pub members: Vec<ByteBuf>, | ||
pub finished: bool, | ||
} | ||
|
||
impl Debug for SuccessResult { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
let mut s = f.debug_struct("SuccessResult"); | ||
s.field("members", &self.members.len()); | ||
s.field("finished", &self.finished); | ||
s.finish() | ||
} | ||
} |
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
21 changes: 21 additions & 0 deletions
21
backend/canisters/group/impl/src/updates/c2c_export_group_members.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,21 @@ | ||
use crate::guards::caller_is_community_being_imported_into; | ||
use crate::RuntimeState; | ||
use crate::{read_state, run_regular_jobs}; | ||
use canister_api_macros::update; | ||
use group_canister::c2c_export_group_members::{Response::*, *}; | ||
|
||
#[update(guard = "caller_is_community_being_imported_into", msgpack = true)] | ||
fn c2c_export_group_members(args: Args) -> Response { | ||
run_regular_jobs(); | ||
|
||
read_state(|state| c2c_export_group_members_impl(args, state)) | ||
} | ||
|
||
fn c2c_export_group_members_impl(args: Args, state: &RuntimeState) -> Response { | ||
let members = state.data.chat.members.read_members_as_bytes_from_stable_memory(args.after); | ||
|
||
Success(SuccessResult { | ||
finished: members.is_empty(), | ||
members, | ||
}) | ||
} |
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
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
Oops, something went wrong.