Follow activitystreams API change
This commit is contained in:
parent
28ec7c665f
commit
50a91ed678
@ -14,11 +14,11 @@ use crate::{
|
||||
use activitystreams::{
|
||||
activity::{Create, Delete},
|
||||
base::{AnyBase, Base},
|
||||
link,
|
||||
iri, link,
|
||||
object::{Note, ObjectExt},
|
||||
prelude::*,
|
||||
primitives::OneOrMany,
|
||||
public, uri as as_uri,
|
||||
public,
|
||||
};
|
||||
use chrono::{self, NaiveDateTime};
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl};
|
||||
@ -152,8 +152,8 @@ impl Comment {
|
||||
let note = self.to_activity(&*conn)?;
|
||||
let base = Base::retract(note)?.into_generic()?;
|
||||
let any_base = AnyBase::from_base(base);
|
||||
let act = Create::new::<url::Url, OneOrMany<AnyBase>>(
|
||||
as_uri!(author.ap_url),
|
||||
let act = Create::new::<_, OneOrMany<AnyBase>>(
|
||||
iri!(author.ap_url),
|
||||
OneOrMany::from_one(any_base),
|
||||
);
|
||||
// let mut act = Create::default();
|
||||
@ -195,7 +195,7 @@ impl Comment {
|
||||
let base = Base::retract(comment)?.into_generic()?;
|
||||
let any_base = AnyBase::from_base(base);
|
||||
let act = Delete::new(
|
||||
as_uri!(User::get(conn, self.author_id)?.ap_url), // FIXME
|
||||
iri!(User::get(conn, self.author_id)?.ap_url), // FIXME
|
||||
OneOrMany::from_one(any_base),
|
||||
);
|
||||
// let mut act = Delete::default();
|
||||
@ -278,10 +278,7 @@ impl FromId<DbConn> for Comment {
|
||||
.to_string()
|
||||
})
|
||||
.unwrap_or_default(),
|
||||
ap_url: note
|
||||
.id(&Instance::get_local()?.public_domain)
|
||||
.expect("authorized domain")
|
||||
.map(|url| url.to_string()),
|
||||
ap_url: note.id().map(|url| url.to_string()),
|
||||
in_response_to_id: previous_comment.iter().map(|c| c.id).next(),
|
||||
post_id: previous_comment.map(|c| c.post_id).or_else(|_| {
|
||||
Ok(Post::find_by_ap_url(conn, previous_url)?.id) as Result<i32>
|
||||
|
@ -5,8 +5,8 @@ use crate::{
|
||||
use activitystreams::{
|
||||
activity::{Accept, ActivityExt, ActorAndObjectRefExt, AsActivity, Follow as FollowAct, Undo},
|
||||
base::AnyBase,
|
||||
iri,
|
||||
primitives::OneOrMany,
|
||||
uri as as_uri,
|
||||
};
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl};
|
||||
use plume_common::activity_pub::{
|
||||
@ -60,8 +60,8 @@ impl Follow {
|
||||
let target = User::get(conn, self.following_id)?;
|
||||
|
||||
let act = FollowAct::new(
|
||||
as_uri!(user.ap_url), // FIXME: Use to_activity()
|
||||
as_uri!(target.ap_url), // FIXME: Use to_activity()
|
||||
iri!(user.ap_url), // FIXME: Use to_activity()
|
||||
iri!(target.ap_url), // FIXME: Use to_activity()
|
||||
);
|
||||
|
||||
// let mut act = FollowAct::default();
|
||||
@ -130,8 +130,8 @@ impl Follow {
|
||||
follow: FollowAct,
|
||||
) -> Result<Accept> {
|
||||
let accept = Accept::new(
|
||||
as_uri!(target.into_id()), // FIXME: Use to_activity()
|
||||
as_uri!(from.into_id()), // FIXME: Use to_activity()
|
||||
iri!(target.into_id()), // FIXME: Use to_activity()
|
||||
iri!(from.into_id()), // FIXME: Use to_activity()
|
||||
);
|
||||
|
||||
// let mut accept = Accept::default();
|
||||
@ -157,12 +157,8 @@ impl Follow {
|
||||
|
||||
pub fn build_undo(&self, conn: &Connection) -> Result<Undo> {
|
||||
let follow = self.to_activity(conn)?;
|
||||
let undo = Undo::new::<url::Url, OneOrMany<AnyBase>>(
|
||||
*follow
|
||||
.actor()
|
||||
.expect("authorized domain")
|
||||
.as_single_id()
|
||||
.expect("exists and only"),
|
||||
let undo = Undo::new::<_, OneOrMany<AnyBase>>(
|
||||
*follow.actor().as_single_id().expect("exists and only"),
|
||||
*follow.result().expect("exists"),
|
||||
);
|
||||
// let mut undo = Undo::default();
|
||||
@ -187,7 +183,7 @@ impl AsObject<User, FollowAct, &DbConn> for User {
|
||||
fn activity(self, conn: &DbConn, actor: User, id: &str) -> Result<Follow> {
|
||||
// Mastodon (at least) requires the full Follow object when accepting it,
|
||||
// so we rebuilt it here
|
||||
let follow = FollowAct::new(as_uri!(actor.ap_url), as_uri!(id));
|
||||
let follow = FollowAct::new(iri!(actor.ap_url), iri!(id));
|
||||
// let mut follow = FollowAct::default();
|
||||
// follow.object_props.set_id_string(id.to_string())?;
|
||||
// follow
|
||||
@ -210,7 +206,6 @@ impl FromId<DbConn> for Follow {
|
||||
conn,
|
||||
&follow
|
||||
.actor()
|
||||
.expect("authorized domain")
|
||||
.as_single_id()
|
||||
.expect("exists and only")
|
||||
.as_str(),
|
||||
|
@ -5,8 +5,8 @@ use crate::{
|
||||
use activitystreams::{
|
||||
activity::{self, ActivityExt, ActorAndObjectRefExt},
|
||||
base::AnyBase,
|
||||
iri,
|
||||
primitives::OneOrMany,
|
||||
uri as as_uri,
|
||||
};
|
||||
|
||||
use chrono::NaiveDateTime;
|
||||
@ -41,8 +41,8 @@ impl Like {
|
||||
|
||||
pub fn to_activity(&self, conn: &Connection) -> Result<activity::Like> {
|
||||
let act = activity::Like::new(
|
||||
as_uri!(User::get(conn, self.user_id)?.ap_url), // FIXME: use to_activity()
|
||||
as_uri!(Post::get(conn, self.post_id)?.ap_url), // FIXME: use to_activity()
|
||||
iri!(User::get(conn, self.user_id)?.ap_url), // FIXME: use to_activity()
|
||||
iri!(Post::get(conn, self.post_id)?.ap_url), // FIXME: use to_activity()
|
||||
);
|
||||
// let mut act = activity::Like::default();
|
||||
// act.like_props
|
||||
@ -78,12 +78,8 @@ impl Like {
|
||||
|
||||
pub fn build_undo(&self, conn: &Connection) -> Result<activity::Undo> {
|
||||
let like = self.to_activity(conn)?;
|
||||
let act = activity::Undo::new::<url::Url, OneOrMany<AnyBase>>(
|
||||
*like
|
||||
.actor()
|
||||
.expect("authorized domain")
|
||||
.as_single_id()
|
||||
.expect("exists and only"),
|
||||
let act = activity::Undo::new::<_, OneOrMany<AnyBase>>(
|
||||
*like.actor().as_single_id().expect("exists and only"),
|
||||
*like.result().expect("exists"),
|
||||
);
|
||||
|
||||
@ -145,11 +141,7 @@ impl FromId<DbConn> for Like {
|
||||
.id,
|
||||
user_id: User::from_id(
|
||||
conn,
|
||||
&act.actor()
|
||||
.expect("authorized domain")
|
||||
.as_single_id()
|
||||
.expect("exists")
|
||||
.as_str(),
|
||||
&act.actor().as_single_id().expect("exists").as_str(),
|
||||
None,
|
||||
CONFIG.proxy(),
|
||||
)
|
||||
|
@ -5,8 +5,8 @@ use crate::{
|
||||
use activitystreams::{
|
||||
activity::{ActivityExt, ActorAndObjectRefExt, Announce, Undo},
|
||||
base::AnyBase,
|
||||
iri,
|
||||
primitives::OneOrMany,
|
||||
uri as as_uri,
|
||||
};
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||
@ -66,8 +66,8 @@ impl Reshare {
|
||||
|
||||
pub fn to_activity(&self, conn: &Connection) -> Result<Announce> {
|
||||
let act = Announce::new(
|
||||
as_uri!(User::get(conn, self.user_id)?.ap_url), // FIXME: Use to_activity()
|
||||
as_uri!(Post::get(conn, self.post_id)?.ap_url), // FIXME: Use to_activity()
|
||||
iri!(User::get(conn, self.user_id)?.ap_url), // FIXME: Use to_activity()
|
||||
iri!(Post::get(conn, self.post_id)?.ap_url), // FIXME: Use to_activity()
|
||||
);
|
||||
|
||||
// let mut act = Announce::default();
|
||||
@ -103,12 +103,8 @@ impl Reshare {
|
||||
|
||||
pub fn build_undo(&self, conn: &Connection) -> Result<Undo> {
|
||||
let announce = self.to_activity(conn)?;
|
||||
let act = Undo::new::<url::Url, OneOrMany<AnyBase>>(
|
||||
*announce
|
||||
.actor()
|
||||
.expect("authorized domain")
|
||||
.as_single_id()
|
||||
.expect("exists and only"),
|
||||
let act = Undo::new::<_, OneOrMany<AnyBase>>(
|
||||
*announce.actor().as_single_id().expect("exists and only"),
|
||||
*announce.result().expect("exists"),
|
||||
);
|
||||
|
||||
@ -173,11 +169,7 @@ impl FromId<DbConn> for Reshare {
|
||||
.id,
|
||||
user_id: User::from_id(
|
||||
conn,
|
||||
&act.actor()
|
||||
.expect("authorized domain")
|
||||
.as_single_id()
|
||||
.expect("exists")
|
||||
.as_str(),
|
||||
&act.actor().as_single_id().expect("exists").as_str(),
|
||||
None,
|
||||
CONFIG.proxy(),
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user