Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85197830
chat_view.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
chat_view.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.PleromaAPI.ChatView
do
use
Pleroma.Web
,
:view
alias
Pleroma.Chat
alias
Pleroma.Chat.MessageReference
alias
Pleroma.User
alias
Pleroma.Web.CommonAPI.Utils
alias
Pleroma.Web.MastodonAPI.AccountView
alias
Pleroma.Web.PleromaAPI.Chat.MessageReferenceView
def
render
(
"show.json"
,
%{
chat
:
%
Chat
{}
=
chat
}
=
opts
)
do
recipient
=
User
.
get_cached_by_ap_id
(
chat
.
recipient
)
last_message
=
opts
[
:last_message
]
||
MessageReference
.
last_message_for_chat
(
chat
)
%{
id
:
chat
.
id
|>
to_string
(),
account
:
AccountView
.
render
(
"show.json"
,
Map
.
put
(
opts
,
:user
,
recipient
)),
unread
:
MessageReference
.
unread_count_for_chat
(
chat
),
last_message
:
last_message
&&
MessageReferenceView
.
render
(
"show.json"
,
chat_message_reference
:
last_message
),
updated_at
:
Utils
.
to_masto_date
(
chat
.
updated_at
)
}
end
def
render
(
"index.json"
,
%{
chats
:
chats
})
do
render_many
(
chats
,
__MODULE__
,
"show.json"
)
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Mon, Jun 29, 9:36 AM (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1572230
Default Alt Text
chat_view.ex (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment