Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F84164559
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-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Web.PleromaAPI.NotificationController
do
use
Pleroma.Web
,
:controller
alias
Pleroma.Notification
plug
(
Pleroma.Web.ApiSpec.CastAndValidate
,
replace_params
:
false
)
plug
(
Pleroma.Web.Plugs.OAuthScopesPlug
,
%{
scopes
:
[
"write:notifications"
]}
when
action
==
:mark_as_read
)
defdelegate
open_api_operation
(
action
),
to
:
Pleroma.Web.ApiSpec.PleromaNotificationOperation
def
mark_as_read
(
%{
assigns
:
%{
user
:
user
},
private
:
%{
open_api_spex
:
%{
body_params
:
%{
id
:
notification_id
}}}
}
=
conn
,
_
)
do
with
{
:ok
,
_
}
<-
Notification
.
read_one
(
user
,
notification_id
)
do
conn
|>
json
(
"ok"
)
else
{
:error
,
message
}
->
conn
|>
put_status
(
:bad_request
)
|>
json
(%{
"error"
=>
message
})
end
end
def
mark_as_read
(
%{
assigns
:
%{
user
:
user
},
private
:
%{
open_api_spex
:
%{
body_params
:
%{
max_id
:
max_id
}}}}
=
conn
,
_
)
do
with
{
:ok
,
_
}
<-
Notification
.
set_read_up_to
(
user
,
max_id
)
do
conn
|>
json
(
"ok"
)
else
{
:error
,
message
}
->
conn
|>
put_status
(
:bad_request
)
|>
json
(%{
"error"
=>
message
})
end
end
end
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Thu, Jun 4, 6:21 PM (20 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1504876
Default Alt Text
notification_controller.ex (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment