-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(users/pending-delete-toggle): migrate proto ops & refs
- Loading branch information
Showing
6 changed files
with
54 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod pending_delete_toggle; | ||
pub mod profile_validate; | ||
pub mod resolve_display_name; | ||
pub mod resolve_email; | ||
|
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,47 @@ | ||
use chirp_workflow::prelude::*; | ||
use proto::backend::{self, pkg::*}; | ||
use rivet_operation::prelude::proto; | ||
|
||
#[derive(Debug)] | ||
pub struct Input { | ||
pub user_id: Uuid, | ||
pub active: bool | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct Output { | ||
} | ||
|
||
|
||
#[operation] | ||
pub async fn pending_delete_toggle( | ||
ctx: &OperationCtx, | ||
input: &Input | ||
) -> GlobalResult<Output> { | ||
let user_id = input.user_id; | ||
|
||
// Verify the user is registered | ||
let identity = op!([ctx] user_identity_get { | ||
user_ids: vec![user_id.into()], | ||
}) | ||
.await?; | ||
let identities = &unwrap_ref!(identity.users.first()).identities; | ||
ensure_with!(!identities.is_empty(), IDENTITY_NOT_REGISTERED); | ||
|
||
sql_execute!( | ||
[ctx] | ||
"UPDATE db_user.users SET delete_request_ts = $2 WHERE user_id = $1", | ||
user_id, | ||
input.active.then(util::timestamp::now), | ||
) | ||
.await?; | ||
|
||
ctx.cache().purge("user", [user_id]).await?; | ||
|
||
msg!([ctx] user::msg::update(user_id) { | ||
user_id: Some(user_id.into()), | ||
}) | ||
.await?; | ||
|
||
Ok(Output {}) | ||
} |