Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rsky-pds/src/apis/com/atproto/identity/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pub mod request_plc_operation_signature;
pub mod get_recommended_did_credentials;
pub mod resolve_handle;
pub mod sign_plc_operation;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use crate::account_manager::helpers::account::AvailabilityFlags;
use crate::account_manager::AccountManager;
use crate::apis::ApiError;
use crate::auth_verifier::AccessFull;
use crate::mailer::{send_plc_operation, TokenParam};
use crate::models::models::EmailTokenPurpose;

#[rocket::post("/xrpc/com.atproto.identity.requestPlcOperationSignature")]
#[tracing::instrument(skip_all)]
pub async fn request_plc_operation_signature(auth: AccessFull) -> Result<(), ApiError> {
let requester = auth.access.credentials.unwrap().did.unwrap();
let availability_flags = AvailabilityFlags {
include_taken_down: Some(true),
include_deactivated: Some(true),
};
let account = AccountManager::get_account(&requester, Some(availability_flags))
.await?
.expect("Account not found despite valid access");

let token =
match AccountManager::create_email_token(&requester, EmailTokenPurpose::PlcOperation).await
{
Ok(res) => res,
Err(error) => {
tracing::error!("Failed to create plc operation token\n{error}");
return Err(ApiError::RuntimeError);
}
};

match send_plc_operation(account.email.unwrap(), TokenParam { token }).await {
Ok(_) => {
tracing::info!("Successfully sent PLC Operation Email");
}
Err(error) => {
tracing::error!("Failed to send PLC Operation Token Email\n{error}");
return Err(ApiError::RuntimeError);
}
}

Ok(())
}
1 change: 1 addition & 0 deletions rsky-pds/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ async fn rocket() -> _ {
com::atproto::identity::update_handle::update_handle,
com::atproto::identity::get_recommended_did_credentials::get_recommended_did_credentials,
com::atproto::identity::sign_plc_operation::sign_plc_operation,
com::atproto::identity::request_plc_operation_signature::request_plc_operation_signature,
com::atproto::repo::apply_writes::apply_writes,
com::atproto::repo::create_record::create_record,
com::atproto::repo::delete_record::delete_record,
Expand Down
Loading