Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
pleroma
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
391
Issues
391
List
Boards
Labels
Service Desk
Milestones
Merge Requests
54
Merge Requests
54
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Pleroma
pleroma
Commits
0b8aeac0
Commit
0b8aeac0
authored
Jun 26, 2019
by
minibikini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove previous idempotency implementation from `post_status`
parent
74132e37
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
22 deletions
+2
-22
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
+2
-22
No files found.
lib/pleroma/web/mastodon_api/mastodon_api_controller.ex
View file @
0b8aeac0
...
...
@@ -561,18 +561,13 @@ def post_status(%{assigns: %{user: user}} = conn, %{"status" => _} = params) do
else
params
=
Map
.
drop
(
params
,
[
"scheduled_at"
])
case
get_cached_status_or_post
(
conn
,
params
)
do
{
:ignore
,
message
}
->
conn
|>
put_status
(
422
)
|>
json
(%{
error:
message
})
case
CommonAPI
.
post
(
user
,
params
)
do
{
:error
,
message
}
->
conn
|>
put_status
(
422
)
|>
json
(%{
error:
message
})
{
_
,
activity
}
->
{
:ok
,
activity
}
->
conn
|>
put_view
(
StatusView
)
|>
try_render
(
"status.json"
,
%{
activity:
activity
,
for:
user
,
as:
:activity
})
...
...
@@ -580,21 +575,6 @@ def post_status(%{assigns: %{user: user}} = conn, %{"status" => _} = params) do
end
end
defp
get_cached_status_or_post
(%{
assigns:
%{
user:
user
}}
=
conn
,
params
)
do
idempotency_key
=
case
get_req_header
(
conn
,
"idempotency-key"
)
do
[
key
]
->
key
_
->
Ecto
.
UUID
.
generate
()
end
Cachex
.
fetch
(
:idempotency_cache
,
idempotency_key
,
fn
_
->
case
CommonAPI
.
post
(
user
,
params
)
do
{
:ok
,
activity
}
->
activity
{
:error
,
message
}
->
{
:ignore
,
message
}
end
end
)
end
def
delete_status
(%{
assigns:
%{
user:
user
}}
=
conn
,
%{
"id"
=>
id
})
do
with
{
:ok
,
%
Activity
{}}
<-
CommonAPI
.
delete
(
id
,
user
)
do
json
(
conn
,
%{})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment