In activity table, remove user_id column and add activity_id

This commit is contained in:
Felix Ableitner 2020-09-14 16:02:07 +02:00
parent 934a26f1ef
commit 4e098e6fc6
22 changed files with 136 additions and 161 deletions

View file

@ -1,7 +1,7 @@
use crate::{schema::activity, Crud};
use diesel::{dsl::*, result::Error, *};
use log::debug;
use serde::{Serialize};
use serde::Serialize;
use serde_json::Value;
use std::{
fmt::Debug,
@ -12,7 +12,7 @@ use std::{
#[table_name = "activity"]
pub struct Activity {
pub id: i32,
pub user_id: i32,
pub activity_id: String,
pub data: Value,
pub local: bool,
pub published: chrono::NaiveDateTime,
@ -22,16 +22,16 @@ pub struct Activity {
#[derive(Insertable, AsChangeset)]
#[table_name = "activity"]
pub struct ActivityForm {
pub user_id: i32,
pub activity_id: String,
pub data: Value,
pub local: bool,
pub updated: Option<chrono::NaiveDateTime>,
}
impl Crud<ActivityForm> for Activity {
fn read(conn: &PgConnection, activity_id: i32) -> Result<Self, Error> {
fn read(conn: &PgConnection, aid: i32) -> Result<Self, Error> {
use crate::schema::activity::dsl::*;
activity.find(activity_id).first::<Self>(conn)
activity.find(aid).first::<Self>(conn)
}
fn create(conn: &PgConnection, new_activity: &ActivityForm) -> Result<Self, Error> {
@ -42,29 +42,27 @@ impl Crud<ActivityForm> for Activity {
}
fn update(
conn: &PgConnection,
activity_id: i32,
new_activity: &ActivityForm,
_conn: &PgConnection,
_activity_id: i32,
_new_activity: &ActivityForm,
) -> Result<Self, Error> {
use crate::schema::activity::dsl::*;
diesel::update(activity.find(activity_id))
.set(new_activity)
.get_result::<Self>(conn)
unimplemented!()
}
}
impl Activity {
pub fn do_insert_activity<T>(
conn: &PgConnection,
user_id: i32,
activity_id: String,
data: &T,
local: bool,
) -> Result<Activity, IoError>
where
T: Serialize + Debug,
{
debug!("inserting activity for user {}, data {:?}", user_id, &data);
debug!("inserting activity {} with data {:?}", activity_id, &data);
let activity_form = ActivityForm {
user_id,
activity_id,
data: serde_json::to_value(&data)?,
local,
updated: None,
@ -79,6 +77,14 @@ where
}
}
pub fn read_from_activity_id(conn: &PgConnection, object_id: String) -> Result<Activity, Error> {
use crate::schema::activity::dsl::*;
activity
.filter(activity_id.eq(object_id))
.first::<Self>(conn)
}
}
#[cfg(test)]
mod tests {
use crate::{
@ -95,34 +101,7 @@ mod tests {
fn test_crud() {
let conn = establish_unpooled_connection();
let creator_form = UserForm {
name: "activity_creator_pm".into(),
preferred_username: None,
password_encrypted: "nope".into(),
email: None,
matrix_user_id: None,
avatar: None,
banner: None,
admin: false,
banned: false,
updated: None,
show_nsfw: false,
theme: "darkly".into(),
default_sort_type: SortType::Hot as i16,
default_listing_type: ListingType::Subscribed as i16,
lang: "browser".into(),
show_avatars: true,
send_notifications_to_email: false,
actor_id: None,
bio: None,
local: true,
private_key: None,
public_key: None,
last_refreshed_at: None,
};
let inserted_creator = User_::create(&conn, &creator_form).unwrap();
let test_activity_id = "http://localhost/activities/123";
let test_json: Value = serde_json::from_str(
r#"{
"street": "Article Circle Expressway 1",
@ -133,7 +112,7 @@ mod tests {
)
.unwrap();
let activity_form = ActivityForm {
user_id: inserted_creator.id,
activity_id: test_activity_id.to_string(),
data: test_json.to_owned(),
local: true,
updated: None,
@ -143,15 +122,15 @@ mod tests {
let expected_activity = Activity {
id: inserted_activity.id,
user_id: inserted_creator.id,
activity_id: test_activity_id.to_string(),
data: test_json,
local: true,
published: inserted_activity.published,
updated: None,
};
let read_activity = Activity::read(&conn, inserted_activity.id).unwrap();
User_::delete(&conn, inserted_creator.id).unwrap();
let read_activity =
Activity::read_from_activity_id(&conn, inserted_activity.activity_id).unwrap();
assert_eq!(expected_activity, read_activity);
assert_eq!(expected_activity, inserted_activity);

View file

@ -3,7 +3,7 @@ use crate::{
Crud,
};
use diesel::{dsl::*, result::Error, *};
use serde::{Serialize};
use serde::Serialize;
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize)]
#[table_name = "category"]

View file

@ -84,9 +84,7 @@ table! {
}
}
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone,
)]
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
#[table_name = "comment_fast_view"]
pub struct CommentView {
pub id: i32,

View file

@ -123,9 +123,7 @@ table! {
}
}
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone,
)]
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
#[table_name = "community_fast_view"]
pub struct CommunityView {
pub id: i32,

View file

@ -1,6 +1,6 @@
use crate::limit_and_offset;
use diesel::{result::Error, *};
use serde::{Serialize};
use serde::Serialize;
table! {
mod_remove_post_view (id) {
@ -17,9 +17,7 @@ table! {
}
}
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone,
)]
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
#[table_name = "mod_remove_post_view"]
pub struct ModRemovePostView {
pub id: i32,
@ -77,9 +75,7 @@ table! {
}
}
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone,
)]
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
#[table_name = "mod_lock_post_view"]
pub struct ModLockPostView {
pub id: i32,
@ -136,9 +132,7 @@ table! {
}
}
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone,
)]
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
#[table_name = "mod_sticky_post_view"]
pub struct ModStickyPostView {
pub id: i32,
@ -200,9 +194,7 @@ table! {
}
}
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone,
)]
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
#[table_name = "mod_remove_comment_view"]
pub struct ModRemoveCommentView {
pub id: i32,
@ -264,9 +256,7 @@ table! {
}
}
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone,
)]
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
#[table_name = "mod_remove_community_view"]
pub struct ModRemoveCommunityView {
pub id: i32,
@ -320,9 +310,7 @@ table! {
}
}
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone,
)]
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
#[table_name = "mod_ban_from_community_view"]
pub struct ModBanFromCommunityView {
pub id: i32,
@ -381,9 +369,7 @@ table! {
}
}
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone,
)]
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
#[table_name = "mod_ban_view"]
pub struct ModBanView {
pub id: i32,
@ -435,9 +421,7 @@ table! {
}
}
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone,
)]
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
#[table_name = "mod_add_community_view"]
pub struct ModAddCommunityView {
pub id: i32,
@ -492,9 +476,7 @@ table! {
}
}
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone,
)]
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
#[table_name = "mod_add_view"]
pub struct ModAddView {
pub id: i32,

View file

@ -1,7 +1,7 @@
use super::post_view::post_fast_view::BoxedQuery;
use crate::{fuzzy_search, limit_and_offset, ListingType, MaybeOptional, SortType};
use diesel::{dsl::*, pg::Pg, result::Error, *};
use serde::{Serialize};
use serde::Serialize;
// The faked schema since diesel doesn't do views
table! {
@ -106,9 +106,7 @@ table! {
}
}
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone,
)]
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
#[table_name = "post_fast_view"]
pub struct PostView {
pub id: i32,

View file

@ -1,6 +1,6 @@
use crate::{limit_and_offset, MaybeOptional};
use diesel::{pg::Pg, result::Error, *};
use serde::{Serialize};
use serde::Serialize;
// The faked schema since diesel doesn't do views
table! {
@ -28,9 +28,7 @@ table! {
}
}
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone,
)]
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
#[table_name = "private_message_view"]
pub struct PrivateMessageView {
pub id: i32,

View file

@ -1,11 +1,11 @@
table! {
activity (id) {
id -> Int4,
user_id -> Int4,
data -> Jsonb,
local -> Bool,
published -> Timestamp,
updated -> Nullable<Timestamp>,
activity_id -> Nullable<Text>,
}
}
@ -480,7 +480,6 @@ table! {
}
}
joinable!(activity -> user_ (user_id));
joinable!(comment -> post (post_id));
joinable!(comment -> user_ (creator_id));
joinable!(comment_like -> comment (comment_id));

View file

@ -1,5 +1,5 @@
use diesel::{result::Error, *};
use serde::{Serialize};
use serde::Serialize;
table! {
site_view (id) {
@ -24,9 +24,7 @@ table! {
}
}
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone,
)]
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
#[table_name = "site_view"]
pub struct SiteView {
pub id: i32,

View file

@ -6,7 +6,7 @@ use crate::{
};
use bcrypt::{hash, DEFAULT_COST};
use diesel::{dsl::*, result::Error, *};
use serde::{Serialize};
use serde::Serialize;
#[derive(Clone, Queryable, Identifiable, PartialEq, Debug, Serialize)]
#[table_name = "user_"]

View file

@ -1,6 +1,6 @@
use crate::{limit_and_offset, MaybeOptional, SortType};
use diesel::{dsl::*, pg::Pg, result::Error, *};
use serde::{Serialize};
use serde::Serialize;
// The faked schema since diesel doesn't do views
table! {
@ -83,9 +83,7 @@ table! {
}
}
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone,
)]
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
#[table_name = "user_mention_fast_view"]
pub struct UserMentionView {
pub id: i32,

View file

@ -1,7 +1,7 @@
use super::user_view::user_fast::BoxedQuery;
use crate::{fuzzy_search, limit_and_offset, MaybeOptional, SortType};
use diesel::{dsl::*, pg::Pg, result::Error, *};
use serde::{Serialize};
use serde::Serialize;
table! {
user_view (id) {
@ -51,9 +51,7 @@ table! {
}
}
#[derive(
Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone,
)]
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
#[table_name = "user_fast"]
pub struct UserView {
pub id: i32,

View file

@ -0,0 +1,3 @@
-- Recreate user_id and remove activity_id
ALTER TABLE activity DROP COLUMN activity_id;
ALTER TABLE activity ADD COLUMN user_id Int4;

View file

@ -0,0 +1,4 @@
-- For activity table, remove the user_id column and add activity_id
ALTER TABLE activity ADD COLUMN activity_id Text;
ALTER TABLE activity DROP COLUMN user_id;

View file

@ -3,11 +3,12 @@ use crate::{
LemmyContext,
};
use activitystreams::{
base::{Extends, ExtendsExt},
base::{AsBase, BaseExt, Extends, ExtendsExt},
object::AsObject,
};
use anyhow::Context;
use lemmy_db::{community::Community, user::User_};
use lemmy_utils::{get_apub_protocol_string, settings::Settings, LemmyError};
use lemmy_utils::{get_apub_protocol_string, location_info, settings::Settings, LemmyError};
use serde::{export::fmt::Debug, Serialize};
use url::{ParseError, Url};
use uuid::Uuid;
@ -20,12 +21,12 @@ pub async fn send_activity_to_community<T, Kind>(
context: &LemmyContext,
) -> Result<(), LemmyError>
where
T: AsObject<Kind> + Extends<Kind> + Serialize + Debug + Send + Clone + 'static,
T: AsObject<Kind> + Extends<Kind> + AsBase<Kind> + Serialize + Debug + Send + Clone + 'static,
Kind: Serialize,
<T as Extends<Kind>>::Error: From<serde_json::Error> + Send + Sync + 'static,
{
// TODO: looks like call this sometimes with activity, and sometimes with any_base
insert_activity(creator.id, activity.clone(), true, context.pool()).await?;
let id = activity.id_unchecked().context(location_info!())?;
insert_activity(id, activity.clone(), true, context.pool()).await?;
// if this is a local community, we need to do an announce from the community instead
if community.local {

View file

@ -148,12 +148,13 @@ impl ActorType for Community {
let mut accept = Accept::new(self.actor_id.to_owned(), follow.into_any_base()?);
let to = actor.get_inbox_url()?;
let id = &generate_activity_id(AcceptType::Accept)?;
accept
.set_context(activitystreams::context())
.set_id(generate_activity_id(AcceptType::Accept)?)
.set_id(id.to_owned())
.set_to(to.clone());
insert_activity(self.creator_id, accept.clone(), true, context.pool()).await?;
insert_activity(id, accept.clone(), true, context.pool()).await?;
send_activity(context.activity_queue(), accept, self, vec![to])?;
Ok(())
@ -163,13 +164,14 @@ impl ActorType for Community {
let group = self.to_apub(context.pool()).await?;
let mut delete = Delete::new(creator.actor_id.to_owned(), group.into_any_base()?);
let id = &generate_activity_id(DeleteType::Delete)?;
delete
.set_context(activitystreams::context())
.set_id(generate_activity_id(DeleteType::Delete)?)
.set_id(id.to_owned())
.set_to(public())
.set_many_ccs(vec![self.get_followers_url()?]);
insert_activity(self.creator_id, delete.clone(), true, context.pool()).await?;
insert_activity(id, delete.clone(), true, context.pool()).await?;
let inboxes = self.get_follower_inboxes(context.pool()).await?;
@ -195,13 +197,14 @@ impl ActorType for Community {
.set_many_ccs(vec![self.get_followers_url()?]);
let mut undo = Undo::new(creator.actor_id.to_owned(), delete.into_any_base()?);
let id = &generate_activity_id(UndoType::Undo)?;
undo
.set_context(activitystreams::context())
.set_id(generate_activity_id(UndoType::Undo)?)
.set_id(id.to_owned())
.set_to(public())
.set_many_ccs(vec![self.get_followers_url()?]);
insert_activity(self.creator_id, undo.clone(), true, context.pool()).await?;
insert_activity(id, undo.clone(), true, context.pool()).await?;
let inboxes = self.get_follower_inboxes(context.pool()).await?;
@ -216,13 +219,14 @@ impl ActorType for Community {
let group = self.to_apub(context.pool()).await?;
let mut remove = Remove::new(mod_.actor_id.to_owned(), group.into_any_base()?);
let id = &generate_activity_id(RemoveType::Remove)?;
remove
.set_context(activitystreams::context())
.set_id(generate_activity_id(RemoveType::Remove)?)
.set_id(id.to_owned())
.set_to(public())
.set_many_ccs(vec![self.get_followers_url()?]);
insert_activity(mod_.id, remove.clone(), true, context.pool()).await?;
insert_activity(id, remove.clone(), true, context.pool()).await?;
let inboxes = self.get_follower_inboxes(context.pool()).await?;
@ -245,13 +249,14 @@ impl ActorType for Community {
// Undo that fake activity
let mut undo = Undo::new(mod_.actor_id.to_owned(), remove.into_any_base()?);
let id = &generate_activity_id(LikeType::Like)?;
undo
.set_context(activitystreams::context())
.set_id(generate_activity_id(LikeType::Like)?)
.set_id(id.to_owned())
.set_to(public())
.set_many_ccs(vec![self.get_followers_url()?]);
insert_activity(mod_.id, undo.clone(), true, context.pool()).await?;
insert_activity(id, undo.clone(), true, context.pool()).await?;
let inboxes = self.get_follower_inboxes(context.pool()).await?;
@ -493,13 +498,14 @@ pub async fn do_announce(
context: &LemmyContext,
) -> Result<(), LemmyError> {
let mut announce = Announce::new(community.actor_id.to_owned(), activity);
let id = &generate_activity_id(AnnounceType::Announce)?;
announce
.set_context(activitystreams::context())
.set_id(generate_activity_id(AnnounceType::Announce)?)
.set_id(id.to_owned())
.set_to(public())
.set_many_ccs(vec![community.get_followers_url()?]);
insert_activity(community.creator_id, announce.clone(), true, context.pool()).await?;
insert_activity(id, announce.clone(), true, context.pool()).await?;
let mut to: Vec<Url> = community.get_follower_inboxes(context.pool()).await?;

View file

@ -75,13 +75,15 @@ pub async fn community_inbox(
let any_base = activity.clone().into_any_base()?;
let kind = activity.kind().context(location_info!())?;
let user_id = user.id;
let res = match kind {
ValidTypes::Follow => handle_follow(any_base, user, community, &context).await,
ValidTypes::Undo => handle_undo_follow(any_base, user, community, &context).await,
};
insert_activity(user_id, activity.clone(), false, context.pool()).await?;
let id = activity
.id(sender.domain().context(location_info!())?)?
.context(location_info!())?;
insert_activity(id, activity.clone(), false, context.pool()).await?;
res
}

View file

@ -93,7 +93,10 @@ pub async fn shared_inbox(
ValidTypes::Undo => receive_undo(any_base, &context).await,
};
insert_activity(actor.user_id(), activity.clone(), false, context.pool()).await?;
let id = activity
.id(sender.domain().context(location_info!())?)?
.context(location_info!())?;
insert_activity(id, activity.clone(), false, context.pool()).await?;
res
}

View file

@ -76,7 +76,10 @@ pub async fn user_inbox(
ValidTypes::Undo => receive_undo_delete_private_message(any_base, &context).await,
};
insert_activity(actor.user_id(), activity.clone(), false, context.pool()).await?;
let id = activity
.id(sender.domain().context(location_info!())?)?
.context(location_info!())?;
insert_activity(id, activity.clone(), false, context.pool()).await?;
res
}

View file

@ -33,7 +33,7 @@ use activitystreams_ext::{Ext1, Ext2};
use actix_web::{body::Body, HttpResponse};
use anyhow::{anyhow, Context};
use chrono::NaiveDateTime;
use lemmy_db::{activity::do_insert_activity, user::User_};
use lemmy_db::{activity::Activity, user::User_};
use lemmy_utils::{
convert_datetime,
get_apub_protocol_string,
@ -349,7 +349,7 @@ pub async fn fetch_webfinger_url(
}
pub async fn insert_activity<T>(
user_id: i32,
activity_id: &Url,
data: T,
local: bool,
pool: &DbPool,
@ -357,8 +357,9 @@ pub async fn insert_activity<T>(
where
T: Serialize + std::fmt::Debug + Send + 'static,
{
let activity_id = activity_id.to_string();
blocking(pool, move |conn| {
do_insert_activity(conn, user_id, &data, local)
Activity::do_insert_activity(conn, activity_id, &data, local)
})
.await??;
Ok(())

View file

@ -127,12 +127,13 @@ impl ApubObjectType for PrivateMessage {
let mut create = Create::new(creator.actor_id.to_owned(), note.into_any_base()?);
let to = recipient.get_inbox_url()?;
let id = &generate_activity_id(CreateType::Create)?;
create
.set_context(activitystreams::context())
.set_id(generate_activity_id(CreateType::Create)?)
.set_id(id.to_owned())
.set_to(to.clone());
insert_activity(creator.id, create.clone(), true, context.pool()).await?;
insert_activity(id, create.clone(), true, context.pool()).await?;
send_activity(context.activity_queue(), create, creator, vec![to])?;
Ok(())
@ -147,12 +148,13 @@ impl ApubObjectType for PrivateMessage {
let mut update = Update::new(creator.actor_id.to_owned(), note.into_any_base()?);
let to = recipient.get_inbox_url()?;
let id = &generate_activity_id(UpdateType::Update)?;
update
.set_context(activitystreams::context())
.set_id(generate_activity_id(UpdateType::Update)?)
.set_id(id.to_owned())
.set_to(to.clone());
insert_activity(creator.id, update.clone(), true, context.pool()).await?;
insert_activity(id, update.clone(), true, context.pool()).await?;
send_activity(context.activity_queue(), update, creator, vec![to])?;
Ok(())
@ -166,12 +168,13 @@ impl ApubObjectType for PrivateMessage {
let mut delete = Delete::new(creator.actor_id.to_owned(), note.into_any_base()?);
let to = recipient.get_inbox_url()?;
let id = &generate_activity_id(DeleteType::Delete)?;
delete
.set_context(activitystreams::context())
.set_id(generate_activity_id(DeleteType::Delete)?)
.set_id(id.to_owned())
.set_to(to.clone());
insert_activity(creator.id, delete.clone(), true, context.pool()).await?;
insert_activity(id, delete.clone(), true, context.pool()).await?;
send_activity(context.activity_queue(), delete, creator, vec![to])?;
Ok(())
@ -196,12 +199,13 @@ impl ApubObjectType for PrivateMessage {
// Undo that fake activity
let mut undo = Undo::new(creator.actor_id.to_owned(), delete.into_any_base()?);
let id = &generate_activity_id(UndoType::Undo)?;
undo
.set_context(activitystreams::context())
.set_id(generate_activity_id(UndoType::Undo)?)
.set_id(id.to_owned())
.set_to(to.clone());
insert_activity(creator.id, undo.clone(), true, context.pool()).await?;
insert_activity(id, undo.clone(), true, context.pool()).await?;
send_activity(context.activity_queue(), undo, creator, vec![to])?;
Ok(())

View file

@ -119,13 +119,14 @@ impl ActorType for User_ {
context: &LemmyContext,
) -> Result<(), LemmyError> {
let mut follow = Follow::new(self.actor_id.to_owned(), follow_actor_id.as_str());
let id = &generate_activity_id(FollowType::Follow)?;
follow
.set_context(activitystreams::context())
.set_id(generate_activity_id(FollowType::Follow)?);
.set_id(id.to_owned());
let follow_actor = get_or_fetch_and_upsert_actor(follow_actor_id, context).await?;
let to = follow_actor.get_inbox_url()?;
insert_activity(self.id, follow.clone(), true, context.pool()).await?;
insert_activity(id, follow.clone(), true, context.pool()).await?;
send_activity(context.activity_queue(), follow, self, vec![to])?;
Ok(())
@ -146,11 +147,12 @@ impl ActorType for User_ {
// Undo that fake activity
let mut undo = Undo::new(Url::parse(&self.actor_id)?, follow.into_any_base()?);
let id = &generate_activity_id(UndoType::Undo)?;
undo
.set_context(activitystreams::context())
.set_id(generate_activity_id(UndoType::Undo)?);
.set_id(id.to_owned());
insert_activity(self.id, undo.clone(), true, context.pool()).await?;
insert_activity(id, undo.clone(), true, context.pool()).await?;
send_activity(context.activity_queue(), undo, self, vec![to])?;
Ok(())