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
d2ad9929
Commit
d2ad9929
authored
Mar 03, 2018
by
lain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle incoming deletes.
parent
1377b2e5
Pipeline
#868
passed with stage
in 3 minutes and 6 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
13 deletions
+65
-13
lib/pleroma/web/activity_pub/transmogrifier.ex
lib/pleroma/web/activity_pub/transmogrifier.ex
+15
-0
test/fixtures/mastodon-delete.json
test/fixtures/mastodon-delete.json
+33
-0
test/web/activity_pub/transmogrifier_test.exs
test/web/activity_pub/transmogrifier_test.exs
+17
-13
No files found.
lib/pleroma/web/activity_pub/transmogrifier.ex
View file @
d2ad9929
...
...
@@ -138,6 +138,21 @@ def handle_incoming(%{"type" => "Update", "object" => %{"type" => "Person"} = ob
end
end
# TODO: Make secure.
def
handle_incoming
(%{
"type"
=>
"Delete"
,
"object"
=>
object_id
,
"actor"
=>
actor
,
"id"
=>
id
}
=
data
)
do
object_id
=
case
object_id
do
%{
"id"
=>
id
}
->
id
id
->
id
end
with
%
User
{}
=
actor
<-
User
.
get_or_fetch_by_ap_id
(
actor
),
{
:ok
,
object
}
<-
get_obj_helper
(
object_id
)
||
ActivityPub
.
fetch_object_from_id
(
object_id
),
{
:ok
,
activity
}
<-
ActivityPub
.
delete
(
object
,
false
)
do
{
:ok
,
activity
}
else
e
->
:error
end
end
# TODO
# Accept
# Undo
...
...
test/fixtures/mastodon-delete.json
0 → 100644
View file @
d2ad9929
{
"type"
:
"Delete"
,
"signature"
:
{
"type"
:
"RsaSignature2017"
,
"signatureValue"
:
"cw0RlfNREf+5VdsOYcCBDrv521eiLsDTAYNHKffjF0bozhCnOh+wHkFik7WamUk$
uEiN4L2H6vPlGRprAZGRhEwgy+A7rIFQNmLrpW5qV5UNVI/2F7kngEHqZQgbQYj9hW+5GMYmPkHdv3D72ZefGw$
4Xa2NBLGFpAjQllfzt7kzZLKKY2DM99FdUa64I2Wj3iD04Hs23SbrUdAeuGk/c1Cg6bwGNG4vxoiwn1jikgJLA$
NAlSGjsRGdR7LfbC7GqWWsW3cSNsLFPoU6FyALjgTrrYoHiXe0QHggw+L3yMLfzB2S/L46/VRbyb+WDKMBIXUL$
5owmzHSi6e/ZtCI3w=="
,
"creator"
:
"http://mastodon.example.org/users/gargron#main-key"
,
"created"
:
"2018-03-03T16:24:11Z"
},
"object"
:
{
"type"
:
"Tombstone"
,
"id"
:
"http://mastodon.example.org/users/gargron/statuses/99620895606148759"
,
"atomUri"
:
"http://mastodon.example.org/users/gargron/statuses/99620895606148759"
},
"id"
:
"http://mastodon.example.org/users/gargron/statuses/99620895606148759#delete"
,
"actor"
:
"http://mastodon.example.org/users/gargron"
,
"@context"
:
[
{
"toot"
:
"http://joinmastodon.org/ns#"
,
"sensitive"
:
"as:sensitive"
,
"ostatus"
:
"http://ostatus.org#"
,
"movedTo"
:
"as:movedTo"
,
"manuallyApprovesFollowers"
:
"as:manuallyApprovesFollowers"
,
"inReplyToAtomUri"
:
"ostatus:inReplyToAtomUri"
,
"conversation"
:
"ostatus:conversation"
,
"atomUri"
:
"ostatus:atomUri"
,
"Hashtag"
:
"as:Hashtag"
,
"Emoji"
:
"toot:Emoji"
}
]
}
test/web/activity_pub/transmogrifier_test.exs
View file @
d2ad9929
...
...
@@ -148,6 +148,23 @@ test "it works for incoming update activities" do
assert
user
.
info
[
"banner"
][
"url"
]
==
[%{
"href"
=>
"https://cd.niu.moe/accounts/headers/000/033/323/original/850b3448fa5fd477.png"
}]
assert
user
.
bio
==
"<p>Some bio</p>"
end
test
"it works for incoming deletes"
do
activity
=
insert
(
:note_activity
)
data
=
File
.
read!
(
"test/fixtures/mastodon-delete.json"
)
|>
Poison
.
decode!
object
=
data
[
"object"
]
|>
Map
.
put
(
"id"
,
activity
.
data
[
"object"
][
"id"
])
data
=
data
|>
Map
.
put
(
"object"
,
object
)
|>
Map
.
put
(
"actor"
,
activity
.
data
[
"actor"
])
{
:ok
,
%
Activity
{
data:
data
,
local:
false
}}
=
Transmogrifier
.
handle_incoming
(
data
)
refute
Repo
.
get
(
Activity
,
activity
.
id
)
end
end
describe
"prepare outgoing"
do
...
...
@@ -256,18 +273,5 @@ test "it deletes all websub client subscripitions with the user as topic" do
refute
Repo
.
get
(
WebsubClientSubscription
,
ws
.
id
)
assert
Repo
.
get
(
WebsubClientSubscription
,
ws2
.
id
)
end
test
"it deletes all websub server subscriptions with the server as callback"
do
subscription
=
%
WebsubClientSubscription
{
topic:
"https://niu.moe/users/rye.atom"
}
{
:ok
,
ws
}
=
Repo
.
insert
(
subscription
)
subscription
=
%
WebsubClientSubscription
{
topic:
"https://niu.moe/users/pasty.atom"
}
{
:ok
,
ws2
}
=
Repo
.
insert
(
subscription
)
Transmogrifier
.
maybe_retire_websub
(
"https://niu.moe/users/rye"
)
refute
Repo
.
get
(
WebsubClientSubscription
,
ws
.
id
)
assert
Repo
.
get
(
WebsubClientSubscription
,
ws2
.
id
)
end
end
end
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