Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pleroma
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kaniini
pleroma
Commits
18edc299
Commit
18edc299
authored
7 years ago
by
lain
Browse files
Options
Downloads
Patches
Plain Diff
Handle duplicates.
parent
62607f37
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/pleroma/web/ostatus/ostatus.ex
+9
-6
9 additions, 6 deletions
lib/pleroma/web/ostatus/ostatus.ex
test/web/ostatus/ostatus_test.exs
+6
-0
6 additions, 0 deletions
test/web/ostatus/ostatus_test.exs
with
15 additions
and
6 deletions
lib/pleroma/web/ostatus/ostatus.ex
+
9
−
6
View file @
18edc299
...
...
@@ -3,7 +3,7 @@ defmodule Pleroma.Web.OStatus do
import
Pleroma
.
Web
.
XML
require
Logger
alias
Pleroma
.
{
Repo
,
User
,
Web
}
alias
Pleroma
.
{
Repo
,
User
,
Web
,
Object
}
alias
Pleroma
.
Web
.
ActivityPub
.
ActivityPub
alias
Pleroma
.
Web
.
{
WebFinger
,
Websub
}
...
...
@@ -28,11 +28,9 @@ defmodule Pleroma.Web.OStatus do
case
object_type
do
'http://activitystrea.ms/schema/1.0/note'
->
{
:ok
,
activity
}
=
handle_note
(
entry
,
doc
)
activity
with
{
:ok
,
activity
}
<-
handle_note
(
entry
,
doc
),
do
:
activity
'http://activitystrea.ms/schema/1.0/comment'
->
{
:ok
,
activity
}
=
handle_note
(
entry
,
doc
)
activity
with
{
:ok
,
activity
}
<-
handle_note
(
entry
,
doc
),
do
:
activity
_
->
Logger
.
error
(
"Couldn't parse incoming document"
)
nil
...
...
@@ -86,7 +84,12 @@ defmodule Pleroma.Web.OStatus do
object
end
ActivityPub
.
create
(
to
,
actor
,
context
,
object
,
%{},
date
)
# TODO: Bail out sooner and use transaction.
if
Object
.
get_by_ap_id
(
id
)
do
{
:error
,
"duplicate activity"
}
else
ActivityPub
.
create
(
to
,
actor
,
context
,
object
,
%{},
date
)
end
end
def
find_or_make_user
(
uri
)
do
...
...
This diff is collapsed.
Click to expand it.
test/web/ostatus/ostatus_test.exs
+
6
−
0
View file @
18edc299
...
...
@@ -2,6 +2,12 @@ defmodule Pleroma.Web.OStatusTest do
use
Pleroma
.
DataCase
alias
Pleroma
.
Web
.
OStatus
test
"don't insert create notes twice"
do
incoming
=
File
.
read!
(
"test/fixtures/incoming_note_activity.xml"
)
{
:ok
,
[
_activity
]}
=
OStatus
.
handle_incoming
(
incoming
)
assert
{
:ok
,
[{
:error
,
"duplicate activity"
}]}
==
OStatus
.
handle_incoming
(
incoming
)
end
test
"handle incoming note - GS, Salmon"
do
incoming
=
File
.
read!
(
"test/fixtures/incoming_note_activity.xml"
)
{
:ok
,
[
activity
]}
=
OStatus
.
handle_incoming
(
incoming
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment