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
normandy
pleroma
Commits
debf7f01
Commit
debf7f01
authored
6 years ago
by
kaniini
Browse files
Options
Downloads
Patches
Plain Diff
ostatus: use preload objects with Object.normalize() when opportunistic
parent
3c2350cb
No related branches found
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
+5
-5
5 additions, 5 deletions
lib/pleroma/web/ostatus/ostatus.ex
lib/pleroma/web/ostatus/ostatus_controller.ex
+7
-6
7 additions, 6 deletions
lib/pleroma/web/ostatus/ostatus_controller.ex
with
12 additions
and
11 deletions
lib/pleroma/web/ostatus/ostatus.ex
+
5
−
5
View file @
debf7f01
...
...
@@ -23,8 +23,8 @@ defmodule Pleroma.Web.OStatus do
alias
Pleroma
.
Web
.
WebFinger
alias
Pleroma
.
Web
.
Websub
def
is_representable?
(%
Activity
{
data:
data
}
)
do
object
=
Object
.
normalize
(
data
[
"object"
]
)
def
is_representable?
(%
Activity
{
}
=
activity
)
do
object
=
Object
.
normalize
(
activity
)
cond
do
is_nil
(
object
)
->
...
...
@@ -119,7 +119,7 @@ defmodule Pleroma.Web.OStatus do
def
make_share
(
entry
,
doc
,
retweeted_activity
)
do
with
{
:ok
,
actor
}
<-
find_make_or_update_user
(
doc
),
%
Object
{}
=
object
<-
Object
.
normalize
(
retweeted_activity
.
data
[
"object"
]
),
%
Object
{}
=
object
<-
Object
.
normalize
(
retweeted_activity
),
id
when
not
is_nil
(
id
)
<-
string_from_xpath
(
"/entry/id"
,
entry
),
{
:ok
,
activity
,
_object
}
=
ActivityPub
.
announce
(
actor
,
object
,
id
,
false
)
do
{
:ok
,
activity
}
...
...
@@ -137,7 +137,7 @@ defmodule Pleroma.Web.OStatus do
def
make_favorite
(
entry
,
doc
,
favorited_activity
)
do
with
{
:ok
,
actor
}
<-
find_make_or_update_user
(
doc
),
%
Object
{}
=
object
<-
Object
.
normalize
(
favorited_activity
.
data
[
"object"
]
),
%
Object
{}
=
object
<-
Object
.
normalize
(
favorited_activity
),
id
when
not
is_nil
(
id
)
<-
string_from_xpath
(
"/entry/id"
,
entry
),
{
:ok
,
activity
,
_object
}
=
ActivityPub
.
like
(
actor
,
object
,
id
,
false
)
do
{
:ok
,
activity
}
...
...
@@ -159,7 +159,7 @@ defmodule Pleroma.Web.OStatus do
Logger
.
debug
(
"Trying to get entry from db"
)
with
id
when
not
is_nil
(
id
)
<-
string_from_xpath
(
"//activity:object[1]/id"
,
entry
),
%
Activity
{}
=
activity
<-
Activity
.
get_create_by_object_ap_id
(
id
)
do
%
Activity
{}
=
activity
<-
Activity
.
get_create_by_object_ap_id
_with_object
(
id
)
do
{
:ok
,
activity
}
else
_
->
...
...
This diff is collapsed.
Click to expand it.
lib/pleroma/web/ostatus/ostatus_controller.ex
+
7
−
6
View file @
debf7f01
...
...
@@ -102,7 +102,8 @@ defmodule Pleroma.Web.OStatus.OStatusController do
ActivityPubController
.
call
(
conn
,
:object
)
else
with
id
<-
o_status_url
(
conn
,
:object
,
uuid
),
{
_
,
%
Activity
{}
=
activity
}
<-
{
:activity
,
Activity
.
get_create_by_object_ap_id
(
id
)},
{
_
,
%
Activity
{}
=
activity
}
<-
{
:activity
,
Activity
.
get_create_by_object_ap_id_with_object
(
id
)},
{
_
,
true
}
<-
{
:public?
,
Visibility
.
is_public?
(
activity
)},
%
User
{}
=
user
<-
User
.
get_cached_by_ap_id
(
activity
.
data
[
"actor"
])
do
case
get_format
(
conn
)
do
...
...
@@ -148,13 +149,13 @@ defmodule Pleroma.Web.OStatus.OStatusController do
end
def
notice
(
conn
,
%{
"id"
=>
id
})
do
with
{
_
,
%
Activity
{}
=
activity
}
<-
{
:activity
,
Activity
.
get_by_id
(
id
)},
with
{
_
,
%
Activity
{}
=
activity
}
<-
{
:activity
,
Activity
.
get_by_id
_with_object
(
id
)},
{
_
,
true
}
<-
{
:public?
,
Visibility
.
is_public?
(
activity
)},
%
User
{}
=
user
<-
User
.
get_cached_by_ap_id
(
activity
.
data
[
"actor"
])
do
case
format
=
get_format
(
conn
)
do
"html"
->
if
activity
.
data
[
"type"
]
==
"Create"
do
%
Object
{}
=
object
=
Object
.
normalize
(
activity
.
data
[
"object"
]
)
%
Object
{}
=
object
=
Object
.
normalize
(
activity
)
Fallback
.
RedirectController
.
redirector_with_meta
(
conn
,
%{
activity_id:
activity
.
id
,
...
...
@@ -191,9 +192,9 @@ defmodule Pleroma.Web.OStatus.OStatusController do
# Returns an HTML embedded <audio> or <video> player suitable for embed iframes.
def
notice_player
(
conn
,
%{
"id"
=>
id
})
do
with
%
Activity
{
data:
%{
"type"
=>
"Create"
}}
=
activity
<-
Activity
.
get_by_id
(
id
),
with
%
Activity
{
data:
%{
"type"
=>
"Create"
}}
=
activity
<-
Activity
.
get_by_id
_with_object
(
id
),
true
<-
Visibility
.
is_public?
(
activity
),
%
Object
{}
=
object
<-
Object
.
normalize
(
activity
.
data
[
"object"
]
),
%
Object
{}
=
object
<-
Object
.
normalize
(
activity
),
%{
data:
%{
"attachment"
=>
[%{
"url"
=>
[
url
|
_
]}
|
_
]}}
<-
object
,
true
<-
String
.
starts_with?
(
url
[
"mediaType"
],
[
"audio"
,
"video"
])
do
conn
...
...
@@ -219,7 +220,7 @@ defmodule Pleroma.Web.OStatus.OStatusController do
%
Activity
{
data:
%{
"type"
=>
"Create"
}}
=
activity
,
_user
)
do
object
=
Object
.
normalize
(
activity
.
data
[
"object"
]
)
object
=
Object
.
normalize
(
activity
)
conn
|>
put_resp_header
(
"content-type"
,
"application/activity+json"
)
...
...
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