Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pleroma
pleroma
Commits
6dd83354
Commit
6dd83354
authored
May 02, 2017
by
lain
Browse files
Mark incoming activties as non-local.
parent
56bacc90
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/activity_pub/activity_pub.ex
View file @
6dd83354
...
...
@@ -3,7 +3,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
alias
Pleroma
.
{
Activity
,
Object
,
Upload
,
User
}
import
Ecto
.
Query
def
insert
(
map
)
when
is_map
(
map
)
do
def
insert
(
map
,
local
\\
true
)
when
is_map
(
map
)
do
map
=
map
|>
Map
.
put_new_lazy
(
"id"
,
&
generate_activity_id
/
0
)
|>
Map
.
put_new_lazy
(
"published"
,
&
make_date
/
0
)
...
...
@@ -16,10 +16,10 @@ def insert(map) when is_map(map) do
map
end
Repo
.
insert
(%
Activity
{
data:
map
})
Repo
.
insert
(%
Activity
{
data:
map
,
local:
local
})
end
def
create
(
to
,
actor
,
context
,
object
,
additional
\\
%{},
published
\\
nil
)
do
def
create
(
to
,
actor
,
context
,
object
,
additional
\\
%{},
published
\\
nil
,
local
\\
true
)
do
published
=
published
||
make_date
()
activity
=
%{
...
...
@@ -32,7 +32,7 @@ def create(to, actor, context, object, additional \\ %{}, published \\ nil) do
}
|>
Map
.
merge
(
additional
)
with
{
:ok
,
activity
}
<-
insert
(
activity
)
do
with
{
:ok
,
activity
}
<-
insert
(
activity
,
local
)
do
if
actor
.
local
do
Pleroma
.
Web
.
Federator
.
enqueue
(
:publish
,
activity
)
end
...
...
lib/pleroma/web/ostatus/ostatus.ex
View file @
6dd83354
...
...
@@ -86,7 +86,7 @@ def handle_note(entry, doc \\ nil) do
if
Object
.
get_by_ap_id
(
id
)
do
{
:error
,
"duplicate activity"
}
else
ActivityPub
.
create
(
to
,
actor
,
context
,
object
,
%{},
date
)
ActivityPub
.
create
(
to
,
actor
,
context
,
object
,
%{},
date
,
false
)
end
end
...
...
test/web/ostatus/ostatus_test.exs
View file @
6dd83354
...
...
@@ -18,6 +18,7 @@ test "handle incoming note - GS, Salmon" do
assert
activity
.
data
[
"published"
]
==
"2017-04-23T14:51:03+00:00"
assert
activity
.
data
[
"context"
]
==
"tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b"
assert
"http://pleroma.example.org:4000/users/lain3"
in
activity
.
data
[
"to"
]
assert
activity
.
local
==
false
end
test
"handle incoming notes - GS, subscription"
do
...
...
Write
Preview
Supports
Markdown
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