Skip to content

Commit

Permalink
Implement separate mod activities for feature, lock post (#2716)
Browse files Browse the repository at this point in the history
* Implement separate mod activities for feature, lock post

Also includes collection for featured posts. Later we also need
to do the same for Comment.distinguished

* some changes

---------

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
  • Loading branch information
Nutomic and dessalines committed Feb 18, 2023
1 parent 8409e50 commit 62663a9
Show file tree
Hide file tree
Showing 54 changed files with 1,294 additions and 679 deletions.
4 changes: 4 additions & 0 deletions crates/api_common/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,10 @@ pub fn generate_outbox_url(actor_id: &DbUrl) -> Result<DbUrl, ParseError> {
Ok(Url::parse(&format!("{actor_id}/outbox"))?.into())
}

pub fn generate_featured_url(actor_id: &DbUrl) -> Result<DbUrl, ParseError> {
Ok(Url::parse(&format!("{actor_id}/featured"))?.into())
}

pub fn generate_moderators_url(community_id: &DbUrl) -> Result<DbUrl, LemmyError> {
Ok(Url::parse(&format!("{community_id}/moderators"))?.into())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"cc": [
"https://ds9.lemmy.ml/c/main"
],
"id": "https://ds9.lemmy.ml/activities/add/47d911f5-52c5-4659-b2fd-0e58c451a427",
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"type": "Add",
"actor": "https://ds9.lemmy.ml/u/lemmy_alpha",
"object": "https://ds9.lemmy.ml/post/2",
"target": "https://ds9.lemmy.ml/c/main/featured",
"audience": "https://ds9.lemmy.ml/c/main"
}
13 changes: 13 additions & 0 deletions crates/apub/assets/lemmy/activities/community/lock_page.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"id": "http://lemmy-alpha:8541/activities/lock/cb48761d-9e8c-42ce-aacb-b4bbe6408db2",
"actor": "http://lemmy-alpha:8541/u/lemmy_alpha",
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"object": "http://lemmy-alpha:8541/post/2",
"cc": [
"http://lemmy-alpha:8541/c/main"
],
"type": "Lock",
"audience": "http://lemmy-alpha:8541/c/main"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"cc": [
"https://ds9.lemmy.ml/c/main"
],
"id": "https://ds9.lemmy.ml/activities/add/47d911f5-52c5-4659-b2fd-0e58c451a427",
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"type": "Remove",
"actor": "https://ds9.lemmy.ml/u/lemmy_alpha",
"object": "https://ds9.lemmy.ml/post/2",
"target": "https://ds9.lemmy.ml/c/main/featured",
"audience": "https://ds9.lemmy.ml/c/main"
}
25 changes: 25 additions & 0 deletions crates/apub/assets/lemmy/activities/community/undo_lock_page.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"id": "http://lemmy-alpha:8541/activities/undo/d6066719-d277-4964-9190-4d6faffac286",
"actor": "http://lemmy-alpha:8541/u/lemmy_alpha",
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"object": {
"actor": "http://lemmy-alpha:8541/u/lemmy_alpha",
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"object": "http://lemmy-alpha:8541/post/2",
"cc": [
"http://lemmy-alpha:8541/c/main"
],
"type": "Lock",
"id": "http://lemmy-alpha:8541/activities/lock/08b6fd3e-9ef3-4358-a987-8bb641f3e2c3",
"audience": "http://lemmy-alpha:8541/c/main"
},
"cc": [
"http://lemmy-alpha:8541/c/main"
],
"type": "Undo",
"audience": "http://lemmy-alpha:8541/c/main"
}
51 changes: 51 additions & 0 deletions crates/apub/assets/lemmy/collections/group_featured_posts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"type": "OrderedCollection",
"id": "https://ds9.lemmy.ml/c/main/featured",
"totalItems": 2,
"orderedItems": [
{
"type": "Page",
"id": "https://ds9.lemmy.ml/post/2",
"attributedTo": "https://ds9.lemmy.ml/u/lemmy_alpha",
"to": [
"https://ds9.lemmy.ml/c/main",
"https://www.w3.org/ns/activitystreams#Public"
],
"name": "test 2",
"cc": [],
"mediaType": "text/html",
"attachment": [],
"commentsEnabled": true,
"sensitive": false,
"stickied": true,
"published": "2023-02-06T06:42:41.939437+00:00",
"language": {
"identifier": "de",
"name": "Deutsch"
},
"audience": "https://ds9.lemmy.ml/c/main"
},
{
"type": "Page",
"id": "https://ds9.lemmy.ml/post/1",
"attributedTo": "https://ds9.lemmy.ml/u/lemmy_alpha",
"to": [
"https://ds9.lemmy.ml/c/main",
"https://www.w3.org/ns/activitystreams#Public"
],
"name": "test 1",
"cc": [],
"mediaType": "text/html",
"attachment": [],
"commentsEnabled": true,
"sensitive": false,
"stickied": true,
"published": "2023-02-06T06:42:37.119567+00:00",
"language": {
"identifier": "de",
"name": "Deutsch"
},
"audience": "https://ds9.lemmy.ml/c/main"
}
]
}
1 change: 1 addition & 0 deletions crates/apub/assets/lemmy/objects/group.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"followers": "https://enterprise.lemmy.ml/c/tenforward/followers",
"moderators": "https://enterprise.lemmy.ml/c/tenforward/moderators",
"attributedTo": "https://enterprise.lemmy.ml/c/tenforward/moderators",
"featured": "https://enterprise.lemmy.ml/c/tenforward//featured",
"postingRestrictedToMods": false,
"endpoints": {
"sharedInbox": "https://enterprise.lemmy.ml/inbox"
Expand Down
73 changes: 73 additions & 0 deletions crates/apub/assets/mastodon/collections/featured.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"@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",
"Hashtag": "as:Hashtag"
}
],
"id": "https://mastodon.social/users/LemmyDev/collections/featured",
"type": "OrderedCollection",
"totalItems": 1,
"orderedItems": [
{
"id": "https://mastodon.social/users/LemmyDev/statuses/104246642906910728",
"type": "Note",
"summary": null,
"inReplyTo": null,
"published": "2020-05-28T14:52:14Z",
"url": "https://mastodon.social/@LemmyDev/104246642906910728",
"attributedTo": "https://mastodon.social/users/LemmyDev",
"to": [
"https://www.w3.org/ns/activitystreams#Public"
],
"cc": [
"https://mastodon.social/users/LemmyDev/followers"
],
"sensitive": false,
"atomUri": "https://mastodon.social/users/LemmyDev/statuses/104246642906910728",
"inReplyToAtomUri": null,
"conversation": "tag:mastodon.social,2020-05-28:objectId=175451535:objectType=Conversation",
"content": "<p>Inaugural Post for Lemmy, a decentralized, easily self-hostable <a href=\"https://mastodon.social/tags/reddit\" class=\"mention hashtag\" rel=\"tag\">#<span>reddit</span></a> / link aggregator alternative,intended to work in the <a href=\"https://mastodon.social/tags/fediverse\" class=\"mention hashtag\" rel=\"tag\">#<span>fediverse</span></a>: </p><p><a href=\"https://github.com/LemmyNet/lemmy/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><span class=\"invisible\">https://</span><span class=\"\">github.com/LemmyNet/lemmy/</span><span class=\"invisible\"></span></a></p><p><a href=\"https://mastodon.social/tags/activitypub\" class=\"mention hashtag\" rel=\"tag\">#<span>activitypub</span></a></p>",
"contentMap": {
"en": "<p>Inaugural Post for Lemmy, a decentralized, easily self-hostable <a href=\"https://mastodon.social/tags/reddit\" class=\"mention hashtag\" rel=\"tag\">#<span>reddit</span></a> / link aggregator alternative, intended to work in the <a href=\"https://mastodon.social/tags/fediverse\" class=\"mention hashtag\" rel=\"tag\">#<span>fediverse</span></a>: </p><p><a href=\"https://github.com/LemmyNet/lemmy/\" target=\"_blank\" rel=\"nofollownoopener noreferrer\"><span class=\"invisible\">https://</span><span class=\"\">github.com/LemmyNet/lemmy/</span><span class=\"invisible\"></span></a></p><p><a href=\"https://mastodon.social/tags/activitypub\" class=\"mentionhashtag\" rel=\"tag\">#<span>activitypub</span></a></p>"
},
"attachment": [],
"tag": [
{
"type": "Hashtag",
"href": "https://mastodon.social/tags/reddit",
"name": "#reddit"
},
{
"type": "Hashtag",
"href": "https://mastodon.social/tags/fediverse",
"name": "#fediverse"
},
{
"type": "Hashtag",
"href": "https://mastodon.social/tags/activitypub",
"name": "#activitypub"
}
],
"replies": {
"id": "https://mastodon.social/users/LemmyDev/statuses/104246642906910728/replies",
"type": "Collection",
"first": {
"type": "CollectionPage",
"next": "https://mastodon.social/users/LemmyDev/statuses/104246642906910728/replies?min_id=104246644059085152&page=true",
"partOf": "https://mastodon.social/users/LemmyDev/statuses/104246642906910728/replies",
"items": [
"https://mastodon.social/users/LemmyDev/statuses/104246644059085152"
]
}
}
}
]
}
182 changes: 0 additions & 182 deletions crates/apub/src/activities/community/add_mod.rs

This file was deleted.

Loading

0 comments on commit 62663a9

Please sign in to comment.