Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F85197448
notification_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
notification_controller.ex
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Web.MastodonAPI.NotificationController
do
use
Pleroma.Web
,
:controller
import
Pleroma.Web.ControllerHelper
,
only
:
[
add_link_headers
:
2
]
alias
Pleroma.Notification
alias
Pleroma.Web.MastodonAPI.MastodonAPI
# GET /api/v1/notifications
def
index
(%{
assigns
:
%{
user
:
user
}}
=
conn
,
params
)
do
notifications
=
MastodonAPI
.
get_notifications
(
user
,
params
)
conn
|>
add_link_headers
(
notifications
)
|>
render
(
"index.json"
,
notifications
:
notifications
,
for
:
user
)
end
# GET /api/v1/notifications/:id
def
show
(%{
assigns
:
%{
user
:
user
}}
=
conn
,
%{
"id"
=>
id
})
do
with
{
:ok
,
notification
}
<-
Notification
.
get
(
user
,
id
)
do
render
(
conn
,
"show.json"
,
notification
:
notification
,
for
:
user
)
else
{
:error
,
reason
}
->
conn
|>
put_status
(
:forbidden
)
|>
json
(%{
"error"
=>
reason
})
end
end
# POST /api/v1/notifications/clear
def
clear
(%{
assigns
:
%{
user
:
user
}}
=
conn
,
_params
)
do
Notification
.
clear
(
user
)
json
(
conn
,
%{})
end
# POST /api/v1/notifications/dismiss
def
dismiss
(%{
assigns
:
%{
user
:
user
}}
=
conn
,
%{
"id"
=>
id
}
=
_params
)
do
with
{
:ok
,
_notif
}
<-
Notification
.
dismiss
(
user
,
id
)
do
json
(
conn
,
%{})
else
{
:error
,
reason
}
->
conn
|>
put_status
(
:forbidden
)
|>
json
(%{
"error"
=>
reason
})
end
end
# DELETE /api/v1/notifications/destroy_multiple
def
destroy_multiple
(%{
assigns
:
%{
user
:
user
}}
=
conn
,
%{
"ids"
=>
ids
}
=
_params
)
do
Notification
.
destroy_multiple
(
user
,
ids
)
json
(
conn
,
%{})
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Mon, Jun 29, 9:21 AM (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1633934
Default Alt Text
notification_controller.ex (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment