Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
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
Container Registry
Model registry
Operate
Environments
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
normandy
pleroma
Commits
d3ec09bb
Commit
d3ec09bb
authored
6 years ago
by
Maksim
Browse files
Options
Downloads
Patches
Plain Diff
fix tags
parent
91236c60
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/pleroma/web/mastodon_api/views/status_view.ex
+20
-1
20 additions, 1 deletion
lib/pleroma/web/mastodon_api/views/status_view.ex
test/web/mastodon_api/status_view_test.exs
+16
-1
16 additions, 1 deletion
test/web/mastodon_api/status_view_test.exs
with
36 additions
and
2 deletions
lib/pleroma/web/mastodon_api/views/status_view.ex
+
20
−
1
View file @
d3ec09bb
...
...
@@ -140,7 +140,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
visibility:
get_visibility
(
object
),
media_attachments:
attachments
|>
Enum
.
take
(
4
),
mentions:
mentions
,
tags:
tags
,
tags:
build_tags
(
tags
)
,
application:
%{
name:
"Web"
,
website:
nil
...
...
@@ -234,6 +234,25 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
def
render_content
(
object
),
do
:
object
[
"content"
]
||
""
@doc
"""
Builds a dictionary tags.
## Examples
iex> Pleroma.Web.MastodonAPI.StatusView.build_tags(["fediverse", "nextcloud"])
[{"name": "fediverse", "url": "/tag/fediverse"},
{"name": "nextcloud", "url": "/tag/nextcloud"}]
"""
@spec
build_tags
(
list
(
String
.
t
()))
::
list
(
map
())
def
build_tags
(
object_tags
)
when
is_list
(
object_tags
)
do
Enum
.
reduce
(
object_tags
,
[],
fn
tag
,
tags
->
tags
++
[%{
name:
tag
,
url:
"/tag/
#{
tag
}
"
}]
end
)
end
def
build_tags
(
_
),
do
:
[]
@doc
"""
Builds list emojis.
...
...
This diff is collapsed.
Click to expand it.
test/web/mastodon_api/status_view_test.exs
+
16
−
1
View file @
d3ec09bb
...
...
@@ -62,7 +62,12 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
visibility:
"public"
,
media_attachments:
[],
mentions:
[],
tags:
note
.
data
[
"object"
][
"tag"
],
tags:
[
%{
name:
"
#{
note
.
data
[
"object"
][
"tag"
]
}
"
,
url:
"/tag/
#{
note
.
data
[
"object"
][
"tag"
]
}
"
}
],
application:
%{
name:
"Web"
,
website:
nil
...
...
@@ -151,4 +156,14 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
assert
represented
[
:reblog
][
:id
]
==
to_string
(
activity
.
id
)
assert
represented
[
:emojis
]
==
[]
end
describe
"build_tags/1"
do
test
"it returns a a dictionary tags"
do
assert
StatusView
.
build_tags
([
"fediverse"
,
"mastodon"
,
"nextcloud"
])
==
[
%{
name:
"fediverse"
,
url:
"/tag/fediverse"
},
%{
name:
"mastodon"
,
url:
"/tag/mastodon"
},
%{
name:
"nextcloud"
,
url:
"/tag/nextcloud"
}
]
end
end
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