Add URI /!/<public_domain>
This commit is contained in:
parent
fa48060a94
commit
8b817d50c5
@ -129,6 +129,7 @@ Then try to restart Plume.
|
|||||||
routes::comments::delete,
|
routes::comments::delete,
|
||||||
routes::comments::activity_pub,
|
routes::comments::activity_pub,
|
||||||
routes::instance::index,
|
routes::instance::index,
|
||||||
|
routes::instance::activity_details,
|
||||||
routes::instance::admin,
|
routes::instance::admin,
|
||||||
routes::instance::admin_mod,
|
routes::instance::admin_mod,
|
||||||
routes::instance::admin_instances,
|
routes::instance::admin_instances,
|
||||||
|
@ -11,7 +11,7 @@ use validator::{Validate, ValidationErrors};
|
|||||||
use crate::inbox;
|
use crate::inbox;
|
||||||
use crate::routes::{errors::ErrorPage, rocket_uri_macro_static_files, Page, RespondOrRedirect};
|
use crate::routes::{errors::ErrorPage, rocket_uri_macro_static_files, Page, RespondOrRedirect};
|
||||||
use crate::template_utils::{IntoContext, Ructe};
|
use crate::template_utils::{IntoContext, Ructe};
|
||||||
use plume_common::activity_pub::{broadcast, inbox::FromId};
|
use plume_common::activity_pub::{broadcast, inbox::FromId, ActivityStream, ApRequest};
|
||||||
use plume_models::{
|
use plume_models::{
|
||||||
admin::*,
|
admin::*,
|
||||||
blocklisted_emails::*,
|
blocklisted_emails::*,
|
||||||
@ -49,6 +49,36 @@ pub fn index(conn: DbConn, rockets: PlumeRocket) -> Result<Ructe, ErrorPage> {
|
|||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Experimental
|
||||||
|
/// "!" might be change in the future
|
||||||
|
///
|
||||||
|
/// This exists for communication with Mastodon.
|
||||||
|
/// Secure mode Mastodon requires HTTP signature for event GET requests.
|
||||||
|
/// To sign requests, public key of request sender is required. We decided
|
||||||
|
/// the sender is local instance.
|
||||||
|
#[get("/!/<public_domain>")]
|
||||||
|
pub fn activity_details(
|
||||||
|
public_domain: String,
|
||||||
|
conn: DbConn,
|
||||||
|
_ap: ApRequest,
|
||||||
|
) -> Option<ActivityStream<CustomService>> {
|
||||||
|
if let Ok(instance) = Instance::find_by_domain(&conn, &public_domain) {
|
||||||
|
if !instance.local {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
match instance.to_activity() {
|
||||||
|
Ok(activity) => Some(ActivityStream::new(activity)),
|
||||||
|
Err(plume_models::Error::NotFound) => None,
|
||||||
|
Err(err) => {
|
||||||
|
tracing::error!("{:?}", err);
|
||||||
|
panic!();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[get("/admin")]
|
#[get("/admin")]
|
||||||
pub fn admin(_admin: Admin, conn: DbConn, rockets: PlumeRocket) -> Result<Ructe, ErrorPage> {
|
pub fn admin(_admin: Admin, conn: DbConn, rockets: PlumeRocket) -> Result<Ructe, ErrorPage> {
|
||||||
let local_inst = Instance::get_local()?;
|
let local_inst = Instance::get_local()?;
|
||||||
|
Loading…
Reference in New Issue
Block a user