Implement AsObject07<User, Announce07, &DbConn> for Post
This commit is contained in:
parent
d78a57ce47
commit
e2702a187b
@ -7,7 +7,7 @@ use activitystreams::{activity::Announce as Announce07, iri_string::types::IriSt
|
|||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
|
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||||
use plume_common::activity_pub::{
|
use plume_common::activity_pub::{
|
||||||
inbox::{AsActor, AsObject, FromId},
|
inbox::{AsActor, AsObject, AsObject07, FromId},
|
||||||
sign::Signer,
|
sign::Signer,
|
||||||
Id, IntoId, PUBLIC_VISIBILITY,
|
Id, IntoId, PUBLIC_VISIBILITY,
|
||||||
};
|
};
|
||||||
@ -145,6 +145,27 @@ impl AsObject<User, Announce, &DbConn> for Post {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AsObject07<User, Announce07, &DbConn> for Post {
|
||||||
|
type Error = Error;
|
||||||
|
type Output = Reshare;
|
||||||
|
|
||||||
|
fn activity07(self, conn: &DbConn, actor: User, id: &str) -> Result<Reshare> {
|
||||||
|
let conn = conn;
|
||||||
|
let reshare = Reshare::insert(
|
||||||
|
conn,
|
||||||
|
NewReshare {
|
||||||
|
post_id: self.id,
|
||||||
|
user_id: actor.id,
|
||||||
|
ap_url: id.to_string(),
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
reshare.notify(conn)?;
|
||||||
|
|
||||||
|
Timeline::add_to_all_timelines(conn, &self, Kind::Reshare(&actor))?;
|
||||||
|
Ok(reshare)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FromId<DbConn> for Reshare {
|
impl FromId<DbConn> for Reshare {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
type Object = Announce;
|
type Object = Announce;
|
||||||
|
Loading…
Reference in New Issue
Block a user