Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F12553967
tag_controller.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
tag_controller.ex
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Web.Feed.TagController
do
use
Pleroma.Web
,
:controller
alias
Pleroma.Config
alias
Pleroma.Web.ActivityPub.ActivityPub
alias
Pleroma.Web.Feed.FeedView
def
feed
(
conn
,
params
)
do
if
not
Config
.
restrict_unauthenticated_access?
(
:timelines
,
:local
)
do
render_feed
(
conn
,
params
)
else
render_error
(
conn
,
:not_found
,
"Not found"
)
end
end
defp
render_feed
(
conn
,
%{
"tag"
=>
raw_tag
}
=
params
)
do
local_only
=
Config
.
restrict_unauthenticated_access?
(
:timelines
,
:federated
)
{
format
,
tag
}
=
parse_tag
(
raw_tag
)
activities
=
%{
type
:
[
"Create"
],
tag
:
tag
,
local_only
:
local_only
}
|>
Pleroma.Maps
.
put_if_present
(
:max_id
,
params
[
"max_id"
])
|>
ActivityPub
.
fetch_public_activities
()
conn
|>
put_resp_content_type
(
"application/
#{
format
}
+xml"
)
|>
put_view
(
FeedView
)
|>
render
(
"tag.
#{
format
}
"
,
activities
:
activities
,
tag
:
tag
,
feed_config
:
Config
.
get
([
:feed
])
)
end
@spec
parse_tag
(
binary
()
|
any
())
::
{
format
::
String
.
t
(),
tag
::
String
.
t
()}
defp
parse_tag
(
raw_tag
)
do
case
is_binary
(
raw_tag
)
&&
Enum
.
reverse
(
String
.
split
(
raw_tag
,
"."
))
do
[
format
|
tag
]
when
format
in
[
"rss"
,
"atom"
]
->
{
format
,
Enum
.
join
(
tag
,
"."
)}
_
->
{
"atom"
,
raw_tag
}
end
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Sat, Nov 15, 2:45 AM (10 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
633102
Default Alt Text
tag_controller.ex (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment