# It is not intended for manual editing.
[[package]]
name = "activitystreams"
-version = "0.7.0-alpha.6"
+version = "0.7.0-alpha.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0b1afe32371e466a791ced0d6ef6e6b97822bb1a279ee4cc41c4324e61cd0b2b"
+checksum = "5e9fedbe571e267d9b93d071bdc4493f944022c6cce717ebb27d352026fc81c4"
dependencies = [
"chrono",
"mime",
#!/bin/bash
set -e
-sudo docker build ../../ --file ../dev/Dockerfile -t lemmy-federation:latest
+sudo docker build ../../ --file ../dev/volume_mount.dockerfile -t lemmy-federation:latest
for Item in alpha beta gamma delta epsilon ; do
sudo mkdir -p volumes/pictrs_$Item
lemmy_structs = { path = "../lemmy_structs" }
lemmy_websocket = { path = "../lemmy_websocket" }
diesel = "1.4"
-activitystreams = "0.7.0-alpha.6"
+activitystreams = "0.7.0-alpha.7"
activitystreams-ext = "0.1.0-alpha.2"
bcrypt = "0.8"
chrono = { version = "0.4", features = ["serde"] }
use crate::{
activities::send::generate_activity_id,
activity_queue::{send_comment_mentions, send_to_community},
+ extensions::context::lemmy_context,
fetcher::get_or_fetch_and_upsert_user,
ActorType,
ApubLikeableType,
let mut create = Create::new(creator.actor_id.to_owned(), note.into_any_base()?);
create
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(CreateType::Create)?)
.set_to(public())
.set_many_ccs(ccs)
let mut update = Update::new(creator.actor_id.to_owned(), note.into_any_base()?);
update
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(UpdateType::Update)?)
.set_to(public())
.set_many_ccs(ccs)
let mut delete = Delete::new(creator.actor_id.to_owned(), Url::parse(&self.ap_id)?);
delete
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(DeleteType::Delete)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
// Generate a fake delete activity, with the correct object
let mut delete = Delete::new(creator.actor_id.to_owned(), Url::parse(&self.ap_id)?);
delete
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(DeleteType::Delete)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
// Undo that fake activity
let mut undo = Undo::new(creator.actor_id.to_owned(), delete.into_any_base()?);
undo
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(UndoType::Undo)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
let mut remove = Remove::new(mod_.actor_id.to_owned(), Url::parse(&self.ap_id)?);
remove
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(RemoveType::Remove)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
// Generate a fake delete activity, with the correct object
let mut remove = Remove::new(mod_.actor_id.to_owned(), Url::parse(&self.ap_id)?);
remove
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(RemoveType::Remove)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
// Undo that fake activity
let mut undo = Undo::new(mod_.actor_id.to_owned(), remove.into_any_base()?);
undo
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(UndoType::Undo)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
let mut like = Like::new(creator.actor_id.to_owned(), note.into_any_base()?);
like
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(LikeType::Like)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
let mut dislike = Dislike::new(creator.actor_id.to_owned(), note.into_any_base()?);
dislike
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(DislikeType::Dislike)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
let mut like = Like::new(creator.actor_id.to_owned(), note.into_any_base()?);
like
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(DislikeType::Dislike)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
// Undo that fake activity
let mut undo = Undo::new(creator.actor_id.to_owned(), like.into_any_base()?);
undo
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(UndoType::Undo)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
activities::send::generate_activity_id,
activity_queue::{send_activity_single_dest, send_to_community_followers},
check_is_apub_id_valid,
+ extensions::context::lemmy_context,
fetcher::get_or_fetch_and_upsert_user,
ActorType,
};
let mut accept = Accept::new(self.actor_id.to_owned(), follow.into_any_base()?);
accept
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(AcceptType::Accept)?)
.set_to(user.actor_id()?);
async fn send_delete(&self, context: &LemmyContext) -> Result<(), LemmyError> {
let mut delete = Delete::new(self.actor_id()?, self.actor_id()?);
delete
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(DeleteType::Delete)?)
.set_to(public())
.set_many_ccs(vec![self.get_followers_url()?]);
async fn send_undo_delete(&self, context: &LemmyContext) -> Result<(), LemmyError> {
let mut delete = Delete::new(self.actor_id()?, self.actor_id()?);
delete
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(DeleteType::Delete)?)
.set_to(public())
.set_many_ccs(vec![self.get_followers_url()?]);
let mut undo = Undo::new(self.actor_id()?, delete.into_any_base()?);
undo
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(UndoType::Undo)?)
.set_to(public())
.set_many_ccs(vec![self.get_followers_url()?]);
async fn send_remove(&self, context: &LemmyContext) -> Result<(), LemmyError> {
let mut remove = Remove::new(self.actor_id()?, self.actor_id()?);
remove
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(RemoveType::Remove)?)
.set_to(public())
.set_many_ccs(vec![self.get_followers_url()?]);
async fn send_undo_remove(&self, context: &LemmyContext) -> Result<(), LemmyError> {
let mut remove = Remove::new(self.actor_id()?, self.actor_id()?);
remove
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(RemoveType::Remove)?)
.set_to(public())
.set_many_ccs(vec![self.get_followers_url()?]);
// Undo that fake activity
let mut undo = Undo::new(self.actor_id()?, remove.into_any_base()?);
undo
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(LikeType::Like)?)
.set_to(public())
.set_many_ccs(vec![self.get_followers_url()?]);
) -> Result<(), LemmyError> {
let mut announce = Announce::new(self.actor_id.to_owned(), activity);
announce
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(AnnounceType::Announce)?)
.set_to(public())
.set_many_ccs(vec![self.get_followers_url()?]);
use crate::{
activities::send::generate_activity_id,
activity_queue::send_to_community,
+ extensions::context::lemmy_context,
ActorType,
ApubLikeableType,
ApubObjectType,
let mut create = Create::new(creator.actor_id.to_owned(), page.into_any_base()?);
create
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(CreateType::Create)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
let mut update = Update::new(creator.actor_id.to_owned(), page.into_any_base()?);
update
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(UpdateType::Update)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
let mut delete = Delete::new(creator.actor_id.to_owned(), Url::parse(&self.ap_id)?);
delete
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(DeleteType::Delete)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
let mut delete = Delete::new(creator.actor_id.to_owned(), Url::parse(&self.ap_id)?);
delete
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(DeleteType::Delete)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
// Undo that fake activity
let mut undo = Undo::new(creator.actor_id.to_owned(), delete.into_any_base()?);
undo
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(UndoType::Undo)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
let mut remove = Remove::new(mod_.actor_id.to_owned(), Url::parse(&self.ap_id)?);
remove
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(RemoveType::Remove)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
let mut remove = Remove::new(mod_.actor_id.to_owned(), Url::parse(&self.ap_id)?);
remove
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(RemoveType::Remove)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
// Undo that fake activity
let mut undo = Undo::new(mod_.actor_id.to_owned(), remove.into_any_base()?);
undo
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(UndoType::Undo)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
let mut like = Like::new(creator.actor_id.to_owned(), page.into_any_base()?);
like
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(LikeType::Like)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
let mut dislike = Dislike::new(creator.actor_id.to_owned(), page.into_any_base()?);
dislike
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(DislikeType::Dislike)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
let mut like = Like::new(creator.actor_id.to_owned(), page.into_any_base()?);
like
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(LikeType::Like)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
// Undo that fake activity
let mut undo = Undo::new(creator.actor_id.to_owned(), like.into_any_base()?);
undo
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(UndoType::Undo)?)
.set_to(public())
.set_many_ccs(vec![community.actor_id()?]);
use crate::{
activities::send::generate_activity_id,
activity_queue::send_activity_single_dest,
+ extensions::context::lemmy_context,
ActorType,
ApubObjectType,
ToApub,
let mut create = Create::new(creator.actor_id.to_owned(), note.into_any_base()?);
create
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(CreateType::Create)?)
.set_to(recipient.actor_id()?);
let mut update = Update::new(creator.actor_id.to_owned(), note.into_any_base()?);
update
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(UpdateType::Update)?)
.set_to(recipient.actor_id()?);
let mut delete = Delete::new(creator.actor_id.to_owned(), Url::parse(&self.ap_id)?);
delete
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(DeleteType::Delete)?)
.set_to(recipient.actor_id()?);
let mut delete = Delete::new(creator.actor_id.to_owned(), Url::parse(&self.ap_id)?);
delete
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(DeleteType::Delete)?)
.set_to(recipient.actor_id()?);
// Undo that fake activity
let mut undo = Undo::new(creator.actor_id.to_owned(), delete.into_any_base()?);
undo
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(UndoType::Undo)?)
.set_to(recipient.actor_id()?);
use crate::{
activities::send::generate_activity_id,
activity_queue::send_activity_single_dest,
+ extensions::context::lemmy_context,
ActorType,
};
use activitystreams::{
let mut follow = Follow::new(self.actor_id.to_owned(), community.actor_id()?);
follow
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(FollowType::Follow)?)
.set_to(community.actor_id()?);
let mut follow = Follow::new(self.actor_id.to_owned(), community.actor_id()?);
follow
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(FollowType::Follow)?)
.set_to(community.actor_id()?);
// Undo that fake activity
let mut undo = Undo::new(Url::parse(&self.actor_id)?, follow.into_any_base()?);
undo
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(generate_activity_id(UndoType::Undo)?)
.set_to(community.actor_id()?);
--- /dev/null
+use activitystreams::{base::AnyBase, context};
+use lemmy_utils::LemmyError;
+use serde_json::json;
+
+pub(crate) fn lemmy_context() -> Result<Vec<AnyBase>, LemmyError> {
+ let context_ext = AnyBase::from_arbitrary_json(json!(
+ {
+ "sc": "http://schema.org#",
+ "category": "sc:category",
+ "sensitive": "as:sensitive",
+ "stickied": "as:stickied",
+ "comments_enabled": {
+ "kind": "sc:Boolean",
+ "id": "pt:commentsEnabled"
+ }
+ }))?;
+ Ok(vec![AnyBase::from(context()), context_ext])
+}
+pub(crate) mod context;
pub(crate) mod group_extensions;
pub(crate) mod page_extension;
pub(crate) mod signatures;
use crate::{
+ extensions::context::lemmy_context,
http::{create_apub_response, create_apub_tombstone_response},
ActorType,
ToApub,
let mut collection = UnorderedCollection::new();
collection
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(community.get_followers_url()?)
.set_total_items(community_followers.len() as u64);
Ok(create_apub_response(&collection))
let mut collection = OrderedCollection::new();
collection
.set_many_items(pages)
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(community.get_outbox_url()?)
.set_total_items(len as u64);
Ok(create_apub_response(&collection))
-use crate::{http::create_apub_response, ActorType, ToApub};
+use crate::{extensions::context::lemmy_context, http::create_apub_response, ActorType, ToApub};
use activitystreams::{
base::BaseExt,
collection::{CollectionExt, OrderedCollection},
let mut collection = OrderedCollection::new();
collection
.set_many_items(Vec::<Url>::new())
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(user.get_outbox_url()?)
.set_total_items(0_u64);
Ok(create_apub_response(&collection))
use crate::{
+ extensions::context::lemmy_context,
fetcher::{
get_or_fetch_and_insert_comment,
get_or_fetch_and_insert_post,
comment
// Not needed when the Post is embedded in a collection (like for community outbox)
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(Url::parse(&self.ap_id)?)
.set_published(convert_datetime(self.published))
.set_to(community.actor_id)
use crate::{
- extensions::group_extensions::GroupExtension,
+ extensions::{context::lemmy_context, group_extensions::GroupExtension},
fetcher::get_or_fetch_and_upsert_user,
objects::{
check_object_domain,
let mut group = ApObject::new(Group::new());
group
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(Url::parse(&self.actor_id)?)
.set_name(self.title.to_owned())
.set_published(convert_datetime(self.published))
use crate::{
- extensions::page_extension::PageExtension,
+ extensions::{context::lemmy_context, page_extension::PageExtension},
fetcher::{get_or_fetch_and_upsert_community, get_or_fetch_and_upsert_user},
objects::{
check_object_domain,
// Not needed when the Post is embedded in a collection (like for community outbox)
// TODO: need to set proper context defining sensitive/commentsEnabled fields
// https://git.asonix.dog/Aardwolf/activitystreams/issues/5
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(self.ap_id.parse::<Url>()?)
// Use summary field to be consistent with mastodon content warning.
// https://mastodon.xyz/@Louisa/103987265222901387.json
use crate::{
check_is_apub_id_valid,
+ extensions::context::lemmy_context,
fetcher::get_or_fetch_and_upsert_user,
objects::{
check_object_domain,
let recipient = blocking(pool, move |conn| User_::read(conn, recipient_id)).await??;
private_message
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(Url::parse(&self.ap_id.to_owned())?)
.set_published(convert_datetime(self.published))
.set_to(recipient.actor_id)
use crate::{
+ extensions::context::lemmy_context,
objects::{check_object_domain, get_source_markdown_value, set_content_and_source},
ActorType,
FromApub,
async fn to_apub(&self, _pool: &DbPool) -> Result<PersonExt, LemmyError> {
let mut person = ApObject::new(Person::new());
person
- .set_context(activitystreams::context())
+ .set_many_contexts(lemmy_context()?)
.set_id(Url::parse(&self.actor_id)?)
.set_published(convert_datetime(self.published));