Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F84164882
embed_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
embed_controller.ex
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Web.EmbedController
do
use
Pleroma.Web
,
:controller
alias
Pleroma.Activity
alias
Pleroma.Object
alias
Pleroma.User
alias
Pleroma.Web.ActivityPub.Visibility
plug
(
:put_layout
,
:embed
)
def
show
(
conn
,
%{
"id"
=>
id
})
do
with
%
Activity
{
local
:
true
}
=
activity
<-
Activity
.
get_by_id_with_object
(
id
),
true
<-
Visibility
.
is_public?
(
activity
.
object
)
do
{
:ok
,
author
}
=
User
.
get_or_fetch
(
activity
.
object
.
data
[
"actor"
])
conn
|>
delete_resp_header
(
"x-frame-options"
)
|>
delete_resp_header
(
"content-security-policy"
)
|>
render
(
"show.html"
,
activity
:
activity
,
author
:
User
.
sanitize_html
(
author
),
counts
:
get_counts
(
activity
)
)
end
end
defp
get_counts
(%
Activity
{}
=
activity
)
do
%
Object
{
data
:
data
}
=
Object
.
normalize
(
activity
)
%{
likes
:
Map
.
get
(
data
,
"like_count"
,
0
),
replies
:
Map
.
get
(
data
,
"repliesCount"
,
0
),
announces
:
Map
.
get
(
data
,
"announcement_count"
,
0
)
}
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Thu, Jun 4, 6:29 PM (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1480969
Default Alt Text
embed_controller.ex (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment