forked from discourse/discourse-activity-pub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Article support on a per-category basis
An Article is for when you don't want to restrict the length of the content being federated (i.e. you want to federate entire posts). Note that Mastodon currently converts the content of Article types into a link, however platforms like Lemmy will show the full content. See further mastodon/mastodon#24079
- Loading branch information
1 parent
1c63290
commit 4d3a42b
Showing
15 changed files
with
249 additions
and
34 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
23 changes: 23 additions & 0 deletions
23
app/serializers/discourse_activity_pub/ap/object/article_serializer.rb
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,23 @@ | ||
# frozen_string_literal: true | ||
|
||
class DiscourseActivityPub::AP::Object::ArticleSerializer < DiscourseActivityPub::AP::ObjectSerializer | ||
attributes :content, | ||
:url, | ||
:updated | ||
|
||
def include_content? | ||
object.content.present? && !deleted? | ||
end | ||
|
||
def include_url? | ||
object.stored.local? && !deleted? | ||
end | ||
|
||
def include_updated? | ||
object.updated.present? | ||
end | ||
|
||
def deleted? | ||
!object.stored.model || object.stored.model.trashed? | ||
end | ||
end |
32 changes: 32 additions & 0 deletions
32
assets/javascripts/discourse/components/activity-pub-post-object-type-dropdown.js
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,32 @@ | ||
import DropdownSelectBoxComponent from "select-kit/components/dropdown-select-box"; | ||
import I18n from "I18n"; | ||
import { computed } from "@ember/object"; | ||
|
||
export default DropdownSelectBoxComponent.extend({ | ||
classNames: ["activity-pub-post-object-type-dropdown"], | ||
|
||
content: computed(function () { | ||
return [ | ||
{ | ||
id: "Note", | ||
label: I18n.t("discourse_activity_pub.post_object_type.note.label"), | ||
title: I18n.t( | ||
"discourse_activity_pub.post_object_type.note.description" | ||
), | ||
}, | ||
{ | ||
id: "Article", | ||
label: I18n.t("discourse_activity_pub.post_object_type.article.label"), | ||
title: I18n.t( | ||
"discourse_activity_pub.post_object_type.article.description" | ||
), | ||
}, | ||
]; | ||
}), | ||
|
||
actions: { | ||
onChange(value) { | ||
this.attrs.onChange && this.attrs.onChange(value); | ||
}, | ||
}, | ||
}); |
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
1 change: 1 addition & 0 deletions
1
...vascripts/discourse/connectors/category-custom-settings/activity-pub-category-settings.js
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
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,25 @@ | ||
# frozen_string_literal: true | ||
module DiscourseActivityPub | ||
module AP | ||
class Object | ||
class Article < Object | ||
|
||
def type | ||
"Article" | ||
end | ||
|
||
def content | ||
stored&.content | ||
end | ||
|
||
def updated | ||
stored&.updated_at.iso8601 | ||
end | ||
|
||
def can_belong_to | ||
%i(post) | ||
end | ||
end | ||
end | ||
end | ||
end |
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
Oops, something went wrong.