Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
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
Alex Gleason
pleroma
Commits
13ab8def
Commit
13ab8def
authored
4 years ago
by
lain
Browse files
Options
Downloads
Patches
Plain Diff
Pipeline: Move transctioning to common pipeline.
parent
09563545
No related branches found
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/activity_pub/pipeline.ex
+19
-4
19 additions, 4 deletions
lib/pleroma/web/activity_pub/pipeline.ex
lib/pleroma/web/activity_pub/side_effects.ex
+4
-9
4 additions, 9 deletions
lib/pleroma/web/activity_pub/side_effects.ex
with
23 additions
and
13 deletions
lib/pleroma/web/activity_pub/pipeline.ex
+
19
−
4
View file @
13ab8def
...
...
@@ -4,20 +4,33 @@
defmodule
Pleroma
.
Web
.
ActivityPub
.
Pipeline
do
alias
Pleroma
.
Activity
alias
Pleroma
.
Object
alias
Pleroma
.
Repo
alias
Pleroma
.
Web
.
ActivityPub
.
ActivityPub
alias
Pleroma
.
Web
.
ActivityPub
.
MRF
alias
Pleroma
.
Web
.
ActivityPub
.
ObjectValidator
alias
Pleroma
.
Web
.
ActivityPub
.
SideEffects
alias
Pleroma
.
Web
.
Federator
@spec
common_pipeline
(
map
(),
keyword
())
::
{
:ok
,
Activity
.
t
(),
keyword
()}
|
{
:error
,
any
()}
@spec
common_pipeline
(
map
(),
keyword
())
::
{
:ok
,
Activity
.
t
()
|
Object
.
t
(),
keyword
()}
|
{
:error
,
any
()}
def
common_pipeline
(
object
,
meta
)
do
case
Repo
.
transaction
(
fn
->
do_common_pipeline
(
object
,
meta
)
end
)
do
{
:ok
,
value
}
->
value
{
:error
,
e
}
->
{
:error
,
e
}
end
end
def
do_common_pipeline
(
object
,
meta
)
do
with
{
_
,
{
:ok
,
validated_object
,
meta
}}
<-
{
:validate_object
,
ObjectValidator
.
validate
(
object
,
meta
)},
{
_
,
{
:ok
,
mrfd_object
}}
<-
{
:mrf_object
,
MRF
.
filter
(
validated_object
)},
{
_
,
{
:ok
,
%
Activity
{}
=
activity
,
meta
}}
<-
{
_
,
{
:ok
,
activity
,
meta
}}
<-
{
:persist_object
,
ActivityPub
.
persist
(
mrfd_object
,
meta
)},
{
_
,
{
:ok
,
%
Activity
{}
=
activity
,
meta
}}
<-
{
_
,
{
:ok
,
activity
,
meta
}}
<-
{
:execute_side_effects
,
SideEffects
.
handle
(
activity
,
meta
)},
{
_
,
{
:ok
,
_
}}
<-
{
:federation
,
maybe_federate
(
activity
,
meta
)}
do
{
:ok
,
activity
,
meta
}
...
...
@@ -27,7 +40,9 @@ def common_pipeline(object, meta) do
end
end
defp
maybe_federate
(
activity
,
meta
)
do
defp
maybe_federate
(%
Object
{},
_
),
do
:
{
:ok
,
:not_federated
}
defp
maybe_federate
(%
Activity
{}
=
activity
,
meta
)
do
with
{
:ok
,
local
}
<-
Keyword
.
fetch
(
meta
,
:local
)
do
if
local
do
Federator
.
publish
(
activity
)
...
...
This diff is collapsed.
Click to expand it.
lib/pleroma/web/activity_pub/side_effects.ex
+
4
−
9
View file @
13ab8def
...
...
@@ -15,17 +15,12 @@ def handle(object, meta \\ [])
# - Add like to object
# - Set up notification
def
handle
(%{
data:
%{
"type"
=>
"Like"
}}
=
object
,
meta
)
do
{
:ok
,
result
}
=
Pleroma
.
Repo
.
transaction
(
fn
->
liked_object
=
Object
.
get_by_ap_id
(
object
.
data
[
"object"
])
Utils
.
add_like_to_object
(
object
,
liked_object
)
liked_object
=
Object
.
get_by_ap_id
(
object
.
data
[
"object"
])
Utils
.
add_like_to_object
(
object
,
liked_object
)
Notification
.
create_notifications
(
object
)
Notification
.
create_notifications
(
object
)
{
:ok
,
object
,
meta
}
end
)
result
{
:ok
,
object
,
meta
}
end
# Nothing to do
...
...
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