forked from LemmyNet/lemmy
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from LemmyNet/main
[pull] master from LemmyNet:main
- Loading branch information
Showing
27 changed files
with
355 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ub/assets/lemmy/objects/chat_message.json → ...assets/lemmy/objects/private_message.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
crates/apub/assets/mastodon/activities/private_message.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"@context": [ | ||
"https://www.w3.org/ns/activitystreams", | ||
{ | ||
"ostatus": "http://ostatus.org#", | ||
"atomUri": "ostatus:atomUri", | ||
"inReplyToAtomUri": "ostatus:inReplyToAtomUri", | ||
"conversation": "ostatus:conversation", | ||
"sensitive": "as:sensitive", | ||
"toot": "http://joinmastodon.org/ns#", | ||
"votersCount": "toot:votersCount" | ||
} | ||
], | ||
"id": "https://mastodon.world/users/nutomic/statuses/110854468010322301", | ||
"type": "Note", | ||
"summary": null, | ||
"inReplyTo": "https://mastodon.world/users/nutomic/statuses/110854464248188528", | ||
"published": "2023-08-08T14:29:04Z", | ||
"url": "https://mastodon.world/@nutomic/110854468010322301", | ||
"attributedTo": "https://mastodon.world/users/nutomic", | ||
"to": ["https://ds9.lemmy.ml/u/nutomic"], | ||
"cc": [], | ||
"sensitive": false, | ||
"atomUri": "https://mastodon.world/users/nutomic/statuses/110854468010322301", | ||
"inReplyToAtomUri": "https://mastodon.world/users/nutomic/statuses/110854464248188528", | ||
"conversation": "tag:mastodon.world,2023-08-08:objectId=121377096:objectType=Conversation", | ||
"content": "<p><span class=\"h-card\" translate=\"no\"><a href=\"https://ds9.lemmy.ml/u/nutomic\" class=\"u-url mention\">@<span>[email protected]</span></a></span> 444</p>", | ||
"contentMap": { | ||
"es": "<p><span class=\"h-card\" translate=\"no\"><a href=\"https://ds9.lemmy.ml/u/nutomic\" class=\"u-url mention\">@<span>[email protected]</span></a></span> 444</p>" | ||
}, | ||
"attachment": [], | ||
"tag": [ | ||
{ | ||
"type": "Mention", | ||
"href": "https://ds9.lemmy.ml/u/nutomic", | ||
"name": "@[email protected]" | ||
} | ||
], | ||
"replies": { | ||
"id": "https://mastodon.world/users/nutomic/statuses/110854468010322301/replies", | ||
"type": "Collection", | ||
"first": { | ||
"type": "CollectionPage", | ||
"next": "https://mastodon.world/users/nutomic/statuses/110854468010322301/replies?only_other_accounts=true&page=true", | ||
"partOf": "https://mastodon.world/users/nutomic/statuses/110854468010322301/replies", | ||
"items": [] | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod comment; | ||
pub(crate) mod note_wrapper; | ||
pub mod post; | ||
pub mod private_message; |
66 changes: 66 additions & 0 deletions
66
crates/apub/src/activities/create_or_update/note_wrapper.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use crate::{ | ||
objects::{community::ApubCommunity, note_wrapper::is_public}, | ||
protocol::{ | ||
activities::create_or_update::{ | ||
note::CreateOrUpdateNote, | ||
note_wrapper::CreateOrUpdateNoteWrapper, | ||
private_message::CreateOrUpdatePrivateMessage, | ||
}, | ||
InCommunity, | ||
}, | ||
}; | ||
use activitypub_federation::{config::Data, traits::ActivityHandler}; | ||
use lemmy_api_common::context::LemmyContext; | ||
use lemmy_utils::error::{FederationError, LemmyError, LemmyResult}; | ||
use serde_json::{from_value, to_value}; | ||
use url::Url; | ||
|
||
#[async_trait::async_trait] | ||
impl ActivityHandler for CreateOrUpdateNoteWrapper { | ||
type DataType = LemmyContext; | ||
type Error = LemmyError; | ||
|
||
fn id(&self) -> &Url { | ||
&self.id | ||
} | ||
|
||
fn actor(&self) -> &Url { | ||
&self.actor | ||
} | ||
|
||
#[tracing::instrument(skip_all)] | ||
async fn verify(&self, context: &Data<Self::DataType>) -> LemmyResult<()> { | ||
let val = to_value(self)?; | ||
if is_public(&self.to, &self.cc) { | ||
CreateOrUpdateNote::verify(&from_value(val)?, context).await?; | ||
} else { | ||
CreateOrUpdatePrivateMessage::verify(&from_value(val)?, context).await?; | ||
} | ||
Ok(()) | ||
} | ||
|
||
#[tracing::instrument(skip_all)] | ||
async fn receive(self, context: &Data<Self::DataType>) -> LemmyResult<()> { | ||
let is_public = is_public(&self.to, &self.cc); | ||
let val = to_value(self)?; | ||
if is_public { | ||
CreateOrUpdateNote::receive(from_value(val)?, context).await?; | ||
} else { | ||
CreateOrUpdatePrivateMessage::receive(from_value(val)?, context).await?; | ||
} | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl InCommunity for CreateOrUpdateNoteWrapper { | ||
#[tracing::instrument(skip(self, context))] | ||
async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity> { | ||
if is_public(&self.to, &self.cc) { | ||
let comment: CreateOrUpdateNote = from_value(to_value(self)?)?; | ||
comment.community(context).await | ||
} else { | ||
Err(FederationError::ObjectIsNotPublic.into()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.