Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mastodon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pierre Boudes
mastodon
Commits
95bd0d45
Commit
95bd0d45
authored
6 years ago
by
M Somerville
Committed by
Eugen Rochko
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Support ActivityStreams’ summaryMap. (#8422)
In the same way as contentMap and nameMap.
parent
2bba6e58
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/lib/activitypub/activity/create.rb
+15
-1
15 additions, 1 deletion
app/lib/activitypub/activity/create.rb
with
15 additions
and
1 deletion
app/lib/activitypub/activity/create.rb
+
15
−
1
View file @
95bd0d45
...
...
@@ -48,7 +48,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
account:
@account
,
text:
text_from_content
||
''
,
language:
detected_language
,
spoiler_text:
@object
[
'
summary
'
]
||
''
,
spoiler_text:
text_from_
summary
||
''
,
created_at:
@object
[
'published'
],
override_timestamps:
@options
[
:override_timestamps
],
reply:
@object
[
'inReplyTo'
].
present?
,
...
...
@@ -193,6 +193,14 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
end
end
def
text_from_summary
if
@object
[
'summary'
].
present?
@object
[
'summary'
]
elsif
summary_language_map?
@object
[
'summaryMap'
].
values
.
first
end
end
def
text_from_name
if
@object
[
'name'
].
present?
@object
[
'name'
]
...
...
@@ -206,6 +214,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
@object
[
'contentMap'
].
keys
.
first
elsif
name_language_map?
@object
[
'nameMap'
].
keys
.
first
elsif
summary_language_map?
@object
[
'summaryMap'
].
keys
.
first
elsif
supported_object_type?
LanguageDetector
.
instance
.
detect
(
text_from_content
,
@account
)
end
...
...
@@ -223,6 +233,10 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
end
end
def
summary_language_map?
@object
[
'summaryMap'
].
is_a?
(
Hash
)
&&
!
@object
[
'summaryMap'
].
empty?
end
def
content_language_map?
@object
[
'contentMap'
].
is_a?
(
Hash
)
&&
!
@object
[
'contentMap'
].
empty?
end
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment