mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-14 00:14:03 +00:00
Add helper function for Activity::create()
This commit is contained in:
parent
a1ad21ec56
commit
11acc7225e
10 changed files with 82 additions and 466 deletions
|
@ -113,14 +113,7 @@ impl ApubObjectType for Comment {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(note)?;
|
.set_object_base_box(note)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, creator.id, &create, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: creator.id,
|
|
||||||
data: serde_json::to_value(&create)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&create,
|
&create,
|
||||||
|
@ -149,14 +142,7 @@ impl ApubObjectType for Comment {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(note)?;
|
.set_object_base_box(note)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, creator.id, &update, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: creator.id,
|
|
||||||
data: serde_json::to_value(&update)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&update,
|
&update,
|
||||||
|
@ -185,14 +171,7 @@ impl ApubObjectType for Comment {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(note)?;
|
.set_object_base_box(note)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, creator.id, &delete, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: creator.id,
|
|
||||||
data: serde_json::to_value(&delete)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&delete,
|
&delete,
|
||||||
|
@ -239,14 +218,7 @@ impl ApubObjectType for Comment {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(delete)?;
|
.set_object_base_box(delete)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, creator.id, &undo, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: creator.id,
|
|
||||||
data: serde_json::to_value(&undo)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&undo,
|
&undo,
|
||||||
|
@ -275,14 +247,7 @@ impl ApubObjectType for Comment {
|
||||||
.set_actor_xsd_any_uri(mod_.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(mod_.actor_id.to_owned())?
|
||||||
.set_object_base_box(note)?;
|
.set_object_base_box(note)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, mod_.id, &remove, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: mod_.id,
|
|
||||||
data: serde_json::to_value(&remove)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&remove,
|
&remove,
|
||||||
|
@ -328,14 +293,7 @@ impl ApubObjectType for Comment {
|
||||||
.set_actor_xsd_any_uri(mod_.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(mod_.actor_id.to_owned())?
|
||||||
.set_object_base_box(remove)?;
|
.set_object_base_box(remove)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, mod_.id, &undo, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: mod_.id,
|
|
||||||
data: serde_json::to_value(&undo)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&undo,
|
&undo,
|
||||||
|
@ -361,14 +319,7 @@ impl ApubLikeableType for Comment {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(note)?;
|
.set_object_base_box(note)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, creator.id, &like, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: creator.id,
|
|
||||||
data: serde_json::to_value(&like)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&like,
|
&like,
|
||||||
|
@ -396,14 +347,7 @@ impl ApubLikeableType for Comment {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(note)?;
|
.set_object_base_box(note)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, creator.id, &dislike, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: creator.id,
|
|
||||||
data: serde_json::to_value(&dislike)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&dislike,
|
&dislike,
|
||||||
|
@ -443,14 +387,7 @@ impl ApubLikeableType for Comment {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(like)?;
|
.set_object_base_box(like)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, creator.id, &undo, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: creator.id,
|
|
||||||
data: serde_json::to_value(&undo)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&undo,
|
&undo,
|
||||||
|
|
|
@ -100,14 +100,7 @@ impl ActorType for Community {
|
||||||
.set_object_base_box(BaseBox::from_concrete(follow.clone())?)?;
|
.set_object_base_box(BaseBox::from_concrete(follow.clone())?)?;
|
||||||
let to = format!("{}/inbox", actor_uri);
|
let to = format!("{}/inbox", actor_uri);
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, self.creator_id, &accept, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: self.creator_id,
|
|
||||||
data: serde_json::to_value(&accept)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&accept,
|
&accept,
|
||||||
|
@ -130,14 +123,7 @@ impl ActorType for Community {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(group)?;
|
.set_object_base_box(group)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, self.creator_id, &delete, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: self.creator_id,
|
|
||||||
data: serde_json::to_value(&delete)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
// Note: For an accept, since it was automatic, no one pushed a button,
|
// Note: For an accept, since it was automatic, no one pushed a button,
|
||||||
// the community was the actor.
|
// the community was the actor.
|
||||||
|
@ -175,14 +161,7 @@ impl ActorType for Community {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(delete)?;
|
.set_object_base_box(delete)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, self.creator_id, &undo, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: self.creator_id,
|
|
||||||
data: serde_json::to_value(&undo)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
// Note: For an accept, since it was automatic, no one pushed a button,
|
// Note: For an accept, since it was automatic, no one pushed a button,
|
||||||
// the community was the actor.
|
// the community was the actor.
|
||||||
|
@ -208,14 +187,7 @@ impl ActorType for Community {
|
||||||
.set_actor_xsd_any_uri(mod_.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(mod_.actor_id.to_owned())?
|
||||||
.set_object_base_box(group)?;
|
.set_object_base_box(group)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, mod_.id, &remove, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: mod_.id,
|
|
||||||
data: serde_json::to_value(&remove)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
// Note: For an accept, since it was automatic, no one pushed a button,
|
// Note: For an accept, since it was automatic, no one pushed a button,
|
||||||
// the community was the actor.
|
// the community was the actor.
|
||||||
|
@ -252,14 +224,7 @@ impl ActorType for Community {
|
||||||
.set_actor_xsd_any_uri(mod_.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(mod_.actor_id.to_owned())?
|
||||||
.set_object_base_box(remove)?;
|
.set_object_base_box(remove)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, mod_.id, &undo, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: mod_.id,
|
|
||||||
data: serde_json::to_value(&undo)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
// Note: For an accept, since it was automatic, no one pushed a button,
|
// Note: For an accept, since it was automatic, no one pushed a button,
|
||||||
// the community was the actor.
|
// the community was the actor.
|
||||||
|
|
|
@ -59,14 +59,7 @@ fn handle_follow(
|
||||||
|
|
||||||
verify(&request, &user.public_key.unwrap())?;
|
verify(&request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &follow, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&follow)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let community_follower_form = CommunityFollowerForm {
|
let community_follower_form = CommunityFollowerForm {
|
||||||
community_id: community.id,
|
community_id: community.id,
|
||||||
|
@ -115,14 +108,7 @@ fn handle_undo_follow(
|
||||||
|
|
||||||
verify(&request, &user.public_key.unwrap())?;
|
verify(&request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &follow, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&follow)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let community_follower_form = CommunityFollowerForm {
|
let community_follower_form = CommunityFollowerForm {
|
||||||
community_id: community.id,
|
community_id: community.id,
|
||||||
|
|
|
@ -11,6 +11,7 @@ pub mod user;
|
||||||
pub mod user_inbox;
|
pub mod user_inbox;
|
||||||
|
|
||||||
use crate::api::community::CommunityResponse;
|
use crate::api::community::CommunityResponse;
|
||||||
|
use crate::db::activity::insert_activity;
|
||||||
use crate::websocket::server::SendCommunityRoomMessage;
|
use crate::websocket::server::SendCommunityRoomMessage;
|
||||||
use activitystreams::object::kind::{NoteType, PageType};
|
use activitystreams::object::kind::{NoteType, PageType};
|
||||||
use activitystreams::{
|
use activitystreams::{
|
||||||
|
@ -54,7 +55,7 @@ use crate::db::private_message::{PrivateMessage, PrivateMessageForm};
|
||||||
use crate::db::private_message_view::PrivateMessageView;
|
use crate::db::private_message_view::PrivateMessageView;
|
||||||
use crate::db::user::{UserForm, User_};
|
use crate::db::user::{UserForm, User_};
|
||||||
use crate::db::user_view::UserView;
|
use crate::db::user_view::UserView;
|
||||||
use crate::db::{activity, Crud, Followable, Joinable, Likeable, SearchType};
|
use crate::db::{Crud, Followable, Joinable, Likeable, SearchType};
|
||||||
use crate::routes::nodeinfo::{NodeInfo, NodeInfoWellKnown};
|
use crate::routes::nodeinfo::{NodeInfo, NodeInfoWellKnown};
|
||||||
use crate::routes::{ChatServerParam, DbPoolParam};
|
use crate::routes::{ChatServerParam, DbPoolParam};
|
||||||
use crate::websocket::{
|
use crate::websocket::{
|
||||||
|
|
|
@ -132,14 +132,7 @@ impl ApubObjectType for Post {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(page)?;
|
.set_object_base_box(page)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, creator.id, &create, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: creator.id,
|
|
||||||
data: serde_json::to_value(&create)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&create,
|
&create,
|
||||||
|
@ -167,14 +160,7 @@ impl ApubObjectType for Post {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(page)?;
|
.set_object_base_box(page)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, creator.id, &update, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: creator.id,
|
|
||||||
data: serde_json::to_value(&update)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&update,
|
&update,
|
||||||
|
@ -202,14 +188,7 @@ impl ApubObjectType for Post {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(page)?;
|
.set_object_base_box(page)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, self.creator_id, &delete, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: self.creator_id,
|
|
||||||
data: serde_json::to_value(&delete)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let community = Community::read(conn, self.community_id)?;
|
let community = Community::read(conn, self.community_id)?;
|
||||||
send_activity(
|
send_activity(
|
||||||
|
@ -254,14 +233,7 @@ impl ApubObjectType for Post {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(delete)?;
|
.set_object_base_box(delete)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, self.creator_id, &undo, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: self.creator_id,
|
|
||||||
data: serde_json::to_value(&undo)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let community = Community::read(conn, self.community_id)?;
|
let community = Community::read(conn, self.community_id)?;
|
||||||
send_activity(
|
send_activity(
|
||||||
|
@ -290,14 +262,7 @@ impl ApubObjectType for Post {
|
||||||
.set_actor_xsd_any_uri(mod_.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(mod_.actor_id.to_owned())?
|
||||||
.set_object_base_box(page)?;
|
.set_object_base_box(page)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, mod_.id, &remove, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: mod_.id,
|
|
||||||
data: serde_json::to_value(&remove)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let community = Community::read(conn, self.community_id)?;
|
let community = Community::read(conn, self.community_id)?;
|
||||||
send_activity(
|
send_activity(
|
||||||
|
@ -340,14 +305,7 @@ impl ApubObjectType for Post {
|
||||||
.set_actor_xsd_any_uri(mod_.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(mod_.actor_id.to_owned())?
|
||||||
.set_object_base_box(remove)?;
|
.set_object_base_box(remove)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, mod_.id, &undo, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: mod_.id,
|
|
||||||
data: serde_json::to_value(&undo)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let community = Community::read(conn, self.community_id)?;
|
let community = Community::read(conn, self.community_id)?;
|
||||||
send_activity(
|
send_activity(
|
||||||
|
@ -373,14 +331,7 @@ impl ApubLikeableType for Post {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(page)?;
|
.set_object_base_box(page)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, creator.id, &like, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: creator.id,
|
|
||||||
data: serde_json::to_value(&like)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&like,
|
&like,
|
||||||
|
@ -407,14 +358,7 @@ impl ApubLikeableType for Post {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(page)?;
|
.set_object_base_box(page)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, creator.id, &dislike, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: creator.id,
|
|
||||||
data: serde_json::to_value(&dislike)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&dislike,
|
&dislike,
|
||||||
|
@ -453,14 +397,7 @@ impl ApubLikeableType for Post {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(like)?;
|
.set_object_base_box(like)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, creator.id, &undo, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: creator.id,
|
|
||||||
data: serde_json::to_value(&undo)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&undo,
|
&undo,
|
||||||
|
|
|
@ -85,14 +85,7 @@ impl ApubObjectType for PrivateMessage {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(note)?;
|
.set_object_base_box(note)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, creator.id, &create, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: creator.id,
|
|
||||||
data: serde_json::to_value(&create)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&create,
|
&create,
|
||||||
|
@ -121,14 +114,7 @@ impl ApubObjectType for PrivateMessage {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(note)?;
|
.set_object_base_box(note)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, creator.id, &update, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: creator.id,
|
|
||||||
data: serde_json::to_value(&update)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&update,
|
&update,
|
||||||
|
@ -156,14 +142,7 @@ impl ApubObjectType for PrivateMessage {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(note)?;
|
.set_object_base_box(note)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, creator.id, &delete, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: creator.id,
|
|
||||||
data: serde_json::to_value(&delete)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&delete,
|
&delete,
|
||||||
|
@ -206,14 +185,7 @@ impl ApubObjectType for PrivateMessage {
|
||||||
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(creator.actor_id.to_owned())?
|
||||||
.set_object_base_box(delete)?;
|
.set_object_base_box(delete)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, creator.id, &undo, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: creator.id,
|
|
||||||
data: serde_json::to_value(&undo)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&undo,
|
&undo,
|
||||||
|
|
|
@ -121,14 +121,7 @@ fn receive_create_post(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &create, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&create)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let post = PostForm::from_apub(&page, &conn)?;
|
let post = PostForm::from_apub(&page, &conn)?;
|
||||||
let inserted_post = Post::create(conn, &post)?;
|
let inserted_post = Post::create(conn, &post)?;
|
||||||
|
@ -170,14 +163,7 @@ fn receive_create_comment(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &create, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&create)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let comment = CommentForm::from_apub(¬e, &conn)?;
|
let comment = CommentForm::from_apub(¬e, &conn)?;
|
||||||
let inserted_comment = Comment::create(conn, &comment)?;
|
let inserted_comment = Comment::create(conn, &comment)?;
|
||||||
|
@ -224,14 +210,7 @@ fn receive_update_post(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &update, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&update)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let post = PostForm::from_apub(&page, conn)?;
|
let post = PostForm::from_apub(&page, conn)?;
|
||||||
let post_id = Post::read_from_apub_id(conn, &post.ap_id)?.id;
|
let post_id = Post::read_from_apub_id(conn, &post.ap_id)?.id;
|
||||||
|
@ -270,14 +249,7 @@ fn receive_like_post(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &like, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&like)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let post = PostForm::from_apub(&page, conn)?;
|
let post = PostForm::from_apub(&page, conn)?;
|
||||||
let post_id = Post::read_from_apub_id(conn, &post.ap_id)?.id;
|
let post_id = Post::read_from_apub_id(conn, &post.ap_id)?.id;
|
||||||
|
@ -327,14 +299,7 @@ fn receive_dislike_post(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &dislike, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&dislike)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let post = PostForm::from_apub(&page, conn)?;
|
let post = PostForm::from_apub(&page, conn)?;
|
||||||
let post_id = Post::read_from_apub_id(conn, &post.ap_id)?.id;
|
let post_id = Post::read_from_apub_id(conn, &post.ap_id)?.id;
|
||||||
|
@ -384,14 +349,7 @@ fn receive_update_comment(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &update, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&update)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let comment = CommentForm::from_apub(¬e, &conn)?;
|
let comment = CommentForm::from_apub(¬e, &conn)?;
|
||||||
let comment_id = Comment::read_from_apub_id(conn, &comment.ap_id)?.id;
|
let comment_id = Comment::read_from_apub_id(conn, &comment.ap_id)?.id;
|
||||||
|
@ -435,14 +393,7 @@ fn receive_like_comment(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &like, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&like)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let comment = CommentForm::from_apub(¬e, &conn)?;
|
let comment = CommentForm::from_apub(¬e, &conn)?;
|
||||||
let comment_id = Comment::read_from_apub_id(conn, &comment.ap_id)?.id;
|
let comment_id = Comment::read_from_apub_id(conn, &comment.ap_id)?.id;
|
||||||
|
@ -497,14 +448,7 @@ fn receive_dislike_comment(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &dislike, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&dislike)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let comment = CommentForm::from_apub(¬e, &conn)?;
|
let comment = CommentForm::from_apub(¬e, &conn)?;
|
||||||
let comment_id = Comment::read_from_apub_id(conn, &comment.ap_id)?.id;
|
let comment_id = Comment::read_from_apub_id(conn, &comment.ap_id)?.id;
|
||||||
|
@ -559,14 +503,7 @@ fn receive_delete_community(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &delete, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&delete)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let community_actor_id = CommunityForm::from_apub(&group, &conn)?.actor_id;
|
let community_actor_id = CommunityForm::from_apub(&group, &conn)?.actor_id;
|
||||||
let community = Community::read_from_actor_id(conn, &community_actor_id)?;
|
let community = Community::read_from_actor_id(conn, &community_actor_id)?;
|
||||||
|
@ -628,14 +565,7 @@ fn receive_remove_community(
|
||||||
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, &conn)?;
|
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, &conn)?;
|
||||||
verify(request, &mod_.public_key.unwrap())?;
|
verify(request, &mod_.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, mod_.id, &remove, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: mod_.id,
|
|
||||||
data: serde_json::to_value(&remove)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let community_actor_id = CommunityForm::from_apub(&group, &conn)?.actor_id;
|
let community_actor_id = CommunityForm::from_apub(&group, &conn)?.actor_id;
|
||||||
let community = Community::read_from_actor_id(conn, &community_actor_id)?;
|
let community = Community::read_from_actor_id(conn, &community_actor_id)?;
|
||||||
|
@ -697,14 +627,7 @@ fn receive_delete_post(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &delete, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&delete)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let post_ap_id = PostForm::from_apub(&page, conn)?.ap_id;
|
let post_ap_id = PostForm::from_apub(&page, conn)?.ap_id;
|
||||||
let post = Post::read_from_apub_id(conn, &post_ap_id)?;
|
let post = Post::read_from_apub_id(conn, &post_ap_id)?;
|
||||||
|
@ -768,14 +691,7 @@ fn receive_remove_post(
|
||||||
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, &conn)?;
|
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, &conn)?;
|
||||||
verify(request, &mod_.public_key.unwrap())?;
|
verify(request, &mod_.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, mod_.id, &remove, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: mod_.id,
|
|
||||||
data: serde_json::to_value(&remove)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let post_ap_id = PostForm::from_apub(&page, conn)?.ap_id;
|
let post_ap_id = PostForm::from_apub(&page, conn)?.ap_id;
|
||||||
let post = Post::read_from_apub_id(conn, &post_ap_id)?;
|
let post = Post::read_from_apub_id(conn, &post_ap_id)?;
|
||||||
|
@ -839,14 +755,7 @@ fn receive_delete_comment(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &delete, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&delete)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let comment_ap_id = CommentForm::from_apub(¬e, &conn)?.ap_id;
|
let comment_ap_id = CommentForm::from_apub(¬e, &conn)?.ap_id;
|
||||||
let comment = Comment::read_from_apub_id(conn, &comment_ap_id)?;
|
let comment = Comment::read_from_apub_id(conn, &comment_ap_id)?;
|
||||||
|
@ -907,14 +816,7 @@ fn receive_remove_comment(
|
||||||
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, &conn)?;
|
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, &conn)?;
|
||||||
verify(request, &mod_.public_key.unwrap())?;
|
verify(request, &mod_.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, mod_.id, &remove, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: mod_.id,
|
|
||||||
data: serde_json::to_value(&remove)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let comment_ap_id = CommentForm::from_apub(¬e, &conn)?.ap_id;
|
let comment_ap_id = CommentForm::from_apub(¬e, &conn)?.ap_id;
|
||||||
let comment = Comment::read_from_apub_id(conn, &comment_ap_id)?;
|
let comment = Comment::read_from_apub_id(conn, &comment_ap_id)?;
|
||||||
|
@ -1035,14 +937,7 @@ fn receive_undo_delete_comment(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &delete, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&delete)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let comment_ap_id = CommentForm::from_apub(¬e, &conn)?.ap_id;
|
let comment_ap_id = CommentForm::from_apub(¬e, &conn)?.ap_id;
|
||||||
let comment = Comment::read_from_apub_id(conn, &comment_ap_id)?;
|
let comment = Comment::read_from_apub_id(conn, &comment_ap_id)?;
|
||||||
|
@ -1103,14 +998,7 @@ fn receive_undo_remove_comment(
|
||||||
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, &conn)?;
|
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, &conn)?;
|
||||||
verify(request, &mod_.public_key.unwrap())?;
|
verify(request, &mod_.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, mod_.id, &remove, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: mod_.id,
|
|
||||||
data: serde_json::to_value(&remove)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let comment_ap_id = CommentForm::from_apub(¬e, &conn)?.ap_id;
|
let comment_ap_id = CommentForm::from_apub(¬e, &conn)?.ap_id;
|
||||||
let comment = Comment::read_from_apub_id(conn, &comment_ap_id)?;
|
let comment = Comment::read_from_apub_id(conn, &comment_ap_id)?;
|
||||||
|
@ -1171,14 +1059,7 @@ fn receive_undo_delete_post(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &delete, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&delete)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let post_ap_id = PostForm::from_apub(&page, conn)?.ap_id;
|
let post_ap_id = PostForm::from_apub(&page, conn)?.ap_id;
|
||||||
let post = Post::read_from_apub_id(conn, &post_ap_id)?;
|
let post = Post::read_from_apub_id(conn, &post_ap_id)?;
|
||||||
|
@ -1242,14 +1123,7 @@ fn receive_undo_remove_post(
|
||||||
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, &conn)?;
|
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, &conn)?;
|
||||||
verify(request, &mod_.public_key.unwrap())?;
|
verify(request, &mod_.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, mod_.id, &remove, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: mod_.id,
|
|
||||||
data: serde_json::to_value(&remove)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let post_ap_id = PostForm::from_apub(&page, conn)?.ap_id;
|
let post_ap_id = PostForm::from_apub(&page, conn)?.ap_id;
|
||||||
let post = Post::read_from_apub_id(conn, &post_ap_id)?;
|
let post = Post::read_from_apub_id(conn, &post_ap_id)?;
|
||||||
|
@ -1313,14 +1187,7 @@ fn receive_undo_delete_community(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &delete, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&delete)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let community_actor_id = CommunityForm::from_apub(&group, &conn)?.actor_id;
|
let community_actor_id = CommunityForm::from_apub(&group, &conn)?.actor_id;
|
||||||
let community = Community::read_from_actor_id(conn, &community_actor_id)?;
|
let community = Community::read_from_actor_id(conn, &community_actor_id)?;
|
||||||
|
@ -1382,14 +1249,7 @@ fn receive_undo_remove_community(
|
||||||
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, &conn)?;
|
let mod_ = get_or_fetch_and_upsert_remote_user(&mod_uri, &conn)?;
|
||||||
verify(request, &mod_.public_key.unwrap())?;
|
verify(request, &mod_.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, mod_.id, &remove, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: mod_.id,
|
|
||||||
data: serde_json::to_value(&remove)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let community_actor_id = CommunityForm::from_apub(&group, &conn)?.actor_id;
|
let community_actor_id = CommunityForm::from_apub(&group, &conn)?.actor_id;
|
||||||
let community = Community::read_from_actor_id(conn, &community_actor_id)?;
|
let community = Community::read_from_actor_id(conn, &community_actor_id)?;
|
||||||
|
@ -1476,14 +1336,7 @@ fn receive_undo_like_comment(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &like, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&like)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let comment = CommentForm::from_apub(¬e, &conn)?;
|
let comment = CommentForm::from_apub(¬e, &conn)?;
|
||||||
let comment_id = Comment::read_from_apub_id(conn, &comment.ap_id)?.id;
|
let comment_id = Comment::read_from_apub_id(conn, &comment.ap_id)?.id;
|
||||||
|
@ -1533,14 +1386,7 @@ fn receive_undo_like_post(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &like, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&like)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let post = PostForm::from_apub(&page, conn)?;
|
let post = PostForm::from_apub(&page, conn)?;
|
||||||
let post_id = Post::read_from_apub_id(conn, &post.ap_id)?.id;
|
let post_id = Post::read_from_apub_id(conn, &post.ap_id)?.id;
|
||||||
|
|
|
@ -73,14 +73,7 @@ impl ActorType for User_ {
|
||||||
.set_object_xsd_any_uri(follow_actor_id)?;
|
.set_object_xsd_any_uri(follow_actor_id)?;
|
||||||
let to = format!("{}/inbox", follow_actor_id);
|
let to = format!("{}/inbox", follow_actor_id);
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, self.id, &follow, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: self.id,
|
|
||||||
data: serde_json::to_value(&follow)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&follow,
|
&follow,
|
||||||
|
@ -121,14 +114,7 @@ impl ActorType for User_ {
|
||||||
.set_actor_xsd_any_uri(self.actor_id.to_owned())?
|
.set_actor_xsd_any_uri(self.actor_id.to_owned())?
|
||||||
.set_object_base_box(follow)?;
|
.set_object_base_box(follow)?;
|
||||||
|
|
||||||
// Insert the sent activity into the activity table
|
insert_activity(&conn, self.id, &undo, true)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: self.id,
|
|
||||||
data: serde_json::to_value(&undo)?,
|
|
||||||
local: true,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
send_activity(
|
send_activity(
|
||||||
&undo,
|
&undo,
|
||||||
|
|
|
@ -59,14 +59,7 @@ fn receive_accept(
|
||||||
|
|
||||||
let user = User_::read_from_name(&conn, username)?;
|
let user = User_::read_from_name(&conn, username)?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, community.creator_id, &accept, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: community.creator_id,
|
|
||||||
data: serde_json::to_value(&accept)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
// Now you need to add this to the community follower
|
// Now you need to add this to the community follower
|
||||||
let community_follower_form = CommunityFollowerForm {
|
let community_follower_form = CommunityFollowerForm {
|
||||||
|
@ -104,14 +97,7 @@ fn receive_create_private_message(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &create, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&create)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let private_message = PrivateMessageForm::from_apub(¬e, &conn)?;
|
let private_message = PrivateMessageForm::from_apub(¬e, &conn)?;
|
||||||
let inserted_private_message = PrivateMessage::create(&conn, &private_message)?;
|
let inserted_private_message = PrivateMessage::create(&conn, &private_message)?;
|
||||||
|
@ -155,14 +141,7 @@ fn receive_update_private_message(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &update, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&update)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let private_message = PrivateMessageForm::from_apub(¬e, &conn)?;
|
let private_message = PrivateMessageForm::from_apub(¬e, &conn)?;
|
||||||
let private_message_id = PrivateMessage::read_from_apub_id(&conn, &private_message.ap_id)?.id;
|
let private_message_id = PrivateMessage::read_from_apub_id(&conn, &private_message.ap_id)?.id;
|
||||||
|
@ -207,14 +186,7 @@ fn receive_delete_private_message(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &delete, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&delete)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let private_message = PrivateMessageForm::from_apub(¬e, &conn)?;
|
let private_message = PrivateMessageForm::from_apub(¬e, &conn)?;
|
||||||
let private_message_id = PrivateMessage::read_from_apub_id(&conn, &private_message.ap_id)?.id;
|
let private_message_id = PrivateMessage::read_from_apub_id(&conn, &private_message.ap_id)?.id;
|
||||||
|
@ -278,14 +250,7 @@ fn receive_undo_delete_private_message(
|
||||||
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
let user = get_or_fetch_and_upsert_remote_user(&user_uri, &conn)?;
|
||||||
verify(request, &user.public_key.unwrap())?;
|
verify(request, &user.public_key.unwrap())?;
|
||||||
|
|
||||||
// Insert the received activity into the activity table
|
insert_activity(&conn, user.id, &delete, false)?;
|
||||||
let activity_form = activity::ActivityForm {
|
|
||||||
user_id: user.id,
|
|
||||||
data: serde_json::to_value(&delete)?,
|
|
||||||
local: false,
|
|
||||||
updated: None,
|
|
||||||
};
|
|
||||||
activity::Activity::create(&conn, &activity_form)?;
|
|
||||||
|
|
||||||
let private_message = PrivateMessageForm::from_apub(¬e, &conn)?;
|
let private_message = PrivateMessageForm::from_apub(¬e, &conn)?;
|
||||||
let private_message_id = PrivateMessage::read_from_apub_id(&conn, &private_message.ap_id)?.id;
|
let private_message_id = PrivateMessage::read_from_apub_id(&conn, &private_message.ap_id)?.id;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::schema::activity;
|
use crate::schema::activity;
|
||||||
use crate::schema::activity::dsl::*;
|
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
#[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize)]
|
||||||
|
@ -25,14 +24,17 @@ pub struct ActivityForm {
|
||||||
|
|
||||||
impl Crud<ActivityForm> for Activity {
|
impl Crud<ActivityForm> for Activity {
|
||||||
fn read(conn: &PgConnection, activity_id: i32) -> Result<Self, Error> {
|
fn read(conn: &PgConnection, activity_id: i32) -> Result<Self, Error> {
|
||||||
|
use crate::schema::activity::dsl::*;
|
||||||
activity.find(activity_id).first::<Self>(conn)
|
activity.find(activity_id).first::<Self>(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delete(conn: &PgConnection, activity_id: i32) -> Result<usize, Error> {
|
fn delete(conn: &PgConnection, activity_id: i32) -> Result<usize, Error> {
|
||||||
|
use crate::schema::activity::dsl::*;
|
||||||
diesel::delete(activity.find(activity_id)).execute(conn)
|
diesel::delete(activity.find(activity_id)).execute(conn)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(conn: &PgConnection, new_activity: &ActivityForm) -> Result<Self, Error> {
|
fn create(conn: &PgConnection, new_activity: &ActivityForm) -> Result<Self, Error> {
|
||||||
|
use crate::schema::activity::dsl::*;
|
||||||
insert_into(activity)
|
insert_into(activity)
|
||||||
.values(new_activity)
|
.values(new_activity)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
|
@ -43,12 +45,31 @@ impl Crud<ActivityForm> for Activity {
|
||||||
activity_id: i32,
|
activity_id: i32,
|
||||||
new_activity: &ActivityForm,
|
new_activity: &ActivityForm,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
|
use crate::schema::activity::dsl::*;
|
||||||
diesel::update(activity.find(activity_id))
|
diesel::update(activity.find(activity_id))
|
||||||
.set(new_activity)
|
.set(new_activity)
|
||||||
.get_result::<Self>(conn)
|
.get_result::<Self>(conn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn insert_activity<T>(
|
||||||
|
conn: &PgConnection,
|
||||||
|
user_id: i32,
|
||||||
|
data: &T,
|
||||||
|
local: bool,
|
||||||
|
) -> Result<Activity, failure::Error>
|
||||||
|
where
|
||||||
|
T: Serialize,
|
||||||
|
{
|
||||||
|
let activity_form = ActivityForm {
|
||||||
|
user_id,
|
||||||
|
data: serde_json::to_value(&data)?,
|
||||||
|
local,
|
||||||
|
updated: None,
|
||||||
|
};
|
||||||
|
Ok(Activity::create(&conn, &activity_form)?)
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::super::user::*;
|
use super::super::user::*;
|
||||||
|
|
Loading…
Reference in a new issue