-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: receive
Announce
activity (#25)
* feat: received announce migration * feat: received announce schema * feat(apub/like): support announce * refactor(apub/activities): remove useless struct * feat(api_mastodon): implement reblogged_by * chore(api_mastodon): update openapi * refactor(apub): move like_or_announce type to mod * chore(apub): add activities test * fix: format code * docs: update federation
- Loading branch information
Showing
29 changed files
with
501 additions
and
131 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
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
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,62 @@ | ||
{ | ||
"@context": [ | ||
"https://www.w3.org/ns/activitystreams", | ||
{ | ||
"ostatus": "http://ostatus.org#", | ||
"atomUri": "ostatus:atomUri" | ||
} | ||
], | ||
"id": "https://mastodon.madrid/users/felix/statuses/107224289116410645/activity", | ||
"type": "Create", | ||
"actor": "https://mastodon.madrid/users/felix", | ||
"published": "2021-11-05T11:46:50Z", | ||
"to": [ | ||
"https://mastodon.madrid/users/felix/followers" | ||
], | ||
"cc": [ | ||
"https://www.w3.org/ns/activitystreams#Public", | ||
"https://mamot.fr/users/retiolus" | ||
], | ||
"object": { | ||
"id": "https://mastodon.madrid/users/felix/statuses/107224289116410645", | ||
"type": "Note", | ||
"summary": null, | ||
"inReplyTo": "https://mamot.fr/users/retiolus/statuses/107224244380204526", | ||
"published": "2021-11-05T11:46:50Z", | ||
"url": "https://mastodon.madrid/@felix/107224289116410645", | ||
"attributedTo": "https://mastodon.madrid/users/felix", | ||
"to": [ | ||
"https://mastodon.madrid/users/felix/followers" | ||
], | ||
"cc": [ | ||
"https://www.w3.org/ns/activitystreams#Public", | ||
"https://mamot.fr/users/retiolus" | ||
], | ||
"sensitive": false, | ||
"atomUri": "https://mastodon.madrid/users/felix/statuses/107224289116410645", | ||
"inReplyToAtomUri": "https://mamot.fr/users/retiolus/statuses/107224244380204526", | ||
"conversation": "tag:mamot.fr,2021-11-05:objectId=64635960:objectType=Conversation", | ||
"content": "<p><span class=\"h-card\"><a href=\"https://mamot.fr/@retiolus\" class=\"u-url mention\">@<span>retiolus</span></a></span> i have never been disappointed by a thinkpad. if you want to save money, get a model from a few years ago, there isnt a huge difference anyway.</p>", | ||
"contentMap": { | ||
"en": "<p><span class=\"h-card\"><a href=\"https://mamot.fr/@retiolus\" class=\"u-url mention\">@<span>retiolus</span></a></span> i have neverbeendisappointed by a thinkpad. if you want to save money, get a model from a few years ago, there isnt a huge difference anyway.</p>" | ||
}, | ||
"attachment": [], | ||
"tag": [ | ||
{ | ||
"type": "Mention", | ||
"href": "https://mamot.fr/users/retiolus", | ||
"name": "@[email protected]" | ||
} | ||
], | ||
"replies": { | ||
"id": "https://mastodon.madrid/users/felix/statuses/107224289116410645/replies", | ||
"type": "Collection", | ||
"first": { | ||
"type": "CollectionPage", | ||
"next": "https://mastodon.madrid/users/felix/statuses/107224289116410645/replies?only_other_accounts=true&page=true", | ||
"partOf": "https://mastodon.madrid/users/felix/statuses/107224289116410645/replies", | ||
"items": [] | ||
} | ||
} | ||
} | ||
} |
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,7 @@ | ||
{ | ||
"@context": "https://www.w3.org/ns/activitystreams", | ||
"id": "https://masto.asonix.dog/1ea87517-63c5-4118-8831-460ee641b2cf", | ||
"type": "Follow", | ||
"actor": "https://masto.asonix.dog/users/asonix", | ||
"object": "https://ds9.lemmy.ml/c/testcom" | ||
} |
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,7 @@ | ||
{ | ||
"@context": "https://www.w3.org/ns/activitystreams", | ||
"id": "https://mastodon.madrid/users/felix#likes/212340", | ||
"type": "Like", | ||
"actor": "https://mastodon.madrid/users/felix", | ||
"object": "https://ds9.lemmy.ml/post/147" | ||
} |
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,12 @@ | ||
{ | ||
"@context": "https://www.w3.org/ns/activitystreams", | ||
"id": "https://masto.asonix.dog/users/asonix#follows/449/undo", | ||
"type": "Undo", | ||
"actor": "https://masto.asonix.dog/users/asonix", | ||
"object": { | ||
"id": "https://masto.asonix.dog/1ea87517-63c5-4118-8831-460ee641b2cf", | ||
"type": "Follow", | ||
"actor": "https://masto.asonix.dog/users/asonix", | ||
"object": "https://ds9.lemmy.ml/c/testcom" | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
crates/apub/assets/mastodon/activities/undo_like_page.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,12 @@ | ||
{ | ||
"@context": "https://www.w3.org/ns/activitystreams", | ||
"id": "https://mastodon.madrid/users/felix#likes/212341/undo", | ||
"type": "Undo", | ||
"actor": "https://mastodon.madrid/users/felix", | ||
"object": { | ||
"id": "https://mastodon.madrid/users/felix#likes/212341", | ||
"type": "Like", | ||
"actor": "https://mastodon.madrid/users/felix", | ||
"object": "https://ds9.lemmy.ml/post/147" | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
crates/apub/src/activities/like_or_announce/db_received_announce.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,26 @@ | ||
use std::ops::Deref; | ||
|
||
use hatsu_db_schema::received_announce::Model as DbReceivedAnnounce; | ||
|
||
#[derive(Clone, Debug, PartialEq, Eq)] | ||
pub struct ApubReceivedAnnounce(pub(crate) DbReceivedAnnounce); | ||
|
||
impl AsRef<DbReceivedAnnounce> for ApubReceivedAnnounce { | ||
fn as_ref(&self) -> &DbReceivedAnnounce { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl Deref for ApubReceivedAnnounce { | ||
type Target = DbReceivedAnnounce; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.0 | ||
} | ||
} | ||
|
||
impl From<DbReceivedAnnounce> for ApubReceivedAnnounce { | ||
fn from(u: DbReceivedAnnounce) -> Self { | ||
Self(u) | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
crates/apub/src/activities/like_or_announce/db_received_announce_impl.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,26 @@ | ||
use activitypub_federation::kinds::activity::AnnounceType; | ||
use hatsu_db_schema::received_announce::Model as DbReceivedAnnounce; | ||
use hatsu_utils::AppError; | ||
use url::Url; | ||
|
||
use crate::activities::{ApubReceivedAnnounce, LikeOrAnnounce, LikeOrAnnounceType}; | ||
|
||
impl ApubReceivedAnnounce { | ||
pub fn into_json(self) -> Result<LikeOrAnnounce, AppError> { | ||
Ok(LikeOrAnnounce { | ||
kind: LikeOrAnnounceType::AnnounceType(AnnounceType::Announce), | ||
id: Url::parse(&self.id)?, | ||
actor: Url::parse(&self.actor)?.into(), | ||
object: Url::parse(&self.object)?.into(), | ||
}) | ||
} | ||
|
||
pub fn from_json(json: &LikeOrAnnounce) -> Result<Self, AppError> { | ||
Ok(DbReceivedAnnounce { | ||
id: json.id.to_string(), | ||
actor: json.actor.to_string(), | ||
object: json.object.to_string(), | ||
} | ||
.into()) | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.