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
c3d41b2b
Verified
Commit
c3d41b2b
authored
Mar 05, 2019
by
Haelwenn
Browse files
[Credo] make all variables use snake_case
parent
fb82f6fc
Changes
5
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/activity_pub/transmogrifier.ex
View file @
c3d41b2b
...
...
@@ -650,10 +650,10 @@ def get_obj_helper(id) do
if
object
=
Object
.
normalize
(
id
),
do
:
{
:ok
,
object
},
else
:
nil
end
def
set_reply_to_uri
(%{
"inReplyTo"
=>
in
R
eply
T
o
}
=
object
)
when
is_binary
(
in
R
eply
T
o
)
do
with
false
<-
String
.
starts_with?
(
in
R
eply
T
o
,
"http"
),
{
:ok
,
%{
data:
replied_to_object
}}
<-
get_obj_helper
(
in
R
eply
T
o
)
do
Map
.
put
(
object
,
"inReplyTo"
,
replied_to_object
[
"external_url"
]
||
in
R
eply
T
o
)
def
set_reply_to_uri
(%{
"inReplyTo"
=>
in
_r
eply
_t
o
}
=
object
)
when
is_binary
(
in
_r
eply
_t
o
)
do
with
false
<-
String
.
starts_with?
(
in
_r
eply
_t
o
,
"http"
),
{
:ok
,
%{
data:
replied_to_object
}}
<-
get_obj_helper
(
in
_r
eply
_t
o
)
do
Map
.
put
(
object
,
"inReplyTo"
,
replied_to_object
[
"external_url"
]
||
in
_r
eply
_t
o
)
else
_e
->
object
end
...
...
@@ -830,10 +830,10 @@ def set_sensitive(object) do
end
def
add_attributed_to
(
object
)
do
attributed
T
o
=
object
[
"attributedTo"
]
||
object
[
"actor"
]
attributed
_t
o
=
object
[
"attributedTo"
]
||
object
[
"actor"
]
object
|>
Map
.
put
(
"attributedTo"
,
attributed
T
o
)
|>
Map
.
put
(
"attributedTo"
,
attributed
_t
o
)
end
def
add_likes
(%{
"id"
=>
id
,
"like_count"
=>
likes
}
=
object
)
do
...
...
lib/pleroma/web/common_api/common_api.ex
View file @
c3d41b2b
...
...
@@ -88,8 +88,8 @@ def get_visibility(%{"in_reply_to_status_id" => status_id}) when not is_nil(stat
nil
->
"public"
in
R
eply
T
o
->
Pleroma
.
Web
.
MastodonAPI
.
StatusView
.
get_visibility
(
in
R
eply
T
o
.
data
[
"object"
])
in
_r
eply
_t
o
->
Pleroma
.
Web
.
MastodonAPI
.
StatusView
.
get_visibility
(
in
_r
eply
_t
o
.
data
[
"object"
])
end
end
...
...
@@ -101,15 +101,15 @@ def post(user, %{"status" => status} = data) do
with
status
<-
String
.
trim
(
status
),
attachments
<-
attachments_from_ids
(
data
),
in
R
eply
T
o
<-
get_replied_to_activity
(
data
[
"in_reply_to_status_id"
]),
in
_r
eply
_t
o
<-
get_replied_to_activity
(
data
[
"in_reply_to_status_id"
]),
{
content_html
,
mentions
,
tags
}
<-
make_content_html
(
status
,
attachments
,
data
),
{
to
,
cc
}
<-
to_for_user_and_mentions
(
user
,
mentions
,
in
R
eply
T
o
,
visibility
),
context
<-
make_context
(
in
R
eply
T
o
),
{
to
,
cc
}
<-
to_for_user_and_mentions
(
user
,
mentions
,
in
_r
eply
_t
o
,
visibility
),
context
<-
make_context
(
in
_r
eply
_t
o
),
cw
<-
data
[
"spoiler_text"
],
full_payload
<-
String
.
trim
(
status
<>
(
data
[
"spoiler_text"
]
||
""
)),
length
when
length
in
1
..
limit
<-
String
.
length
(
full_payload
),
...
...
@@ -120,7 +120,7 @@ def post(user, %{"status" => status} = data) do
context
,
content_html
,
attachments
,
in
R
eply
T
o
,
in
_r
eply
_t
o
,
tags
,
cw
,
cc
...
...
lib/pleroma/web/ostatus/handlers/note_handler.ex
View file @
c3d41b2b
...
...
@@ -19,13 +19,13 @@ defmodule Pleroma.Web.OStatus.NoteHandler do
2. The conversation reference in the ostatus xml
3. A newly generated context id.
"""
def
get_context
(
entry
,
in
R
eply
T
o
)
do
def
get_context
(
entry
,
in
_r
eply
_t
o
)
do
context
=
(
XML
.
string_from_xpath
(
"//ostatus:conversation[1]"
,
entry
)
||
XML
.
string_from_xpath
(
"//ostatus:conversation[1]/@ref"
,
entry
)
||
""
)
|>
String
.
trim
()
with
%{
data:
%{
"context"
=>
context
}}
<-
Object
.
get_cached_by_ap_id
(
in
R
eply
T
o
)
do
with
%{
data:
%{
"context"
=>
context
}}
<-
Object
.
get_cached_by_ap_id
(
in
_r
eply
_t
o
)
do
context
else
_e
->
...
...
@@ -88,14 +88,14 @@ def add_external_url(note, entry) do
Map
.
put
(
note
,
"external_url"
,
url
)
end
def
fetch_replied_to_activity
(
entry
,
in
R
eply
T
o
)
do
with
%
Activity
{}
=
activity
<-
Activity
.
get_create_by_object_ap_id
(
in
R
eply
T
o
)
do
def
fetch_replied_to_activity
(
entry
,
in
_r
eply
_t
o
)
do
with
%
Activity
{}
=
activity
<-
Activity
.
get_create_by_object_ap_id
(
in
_r
eply
_t
o
)
do
activity
else
_e
->
with
in
R
eply
ToH
ref
when
not
is_nil
(
in
R
eply
ToH
ref
)
<-
with
in
_r
eply
_to_h
ref
when
not
is_nil
(
in
_r
eply
_to_h
ref
)
<-
XML
.
string_from_xpath
(
"//thr:in-reply-to[1]/@href"
,
entry
),
{
:ok
,
[
activity
|
_
]}
<-
OStatus
.
fetch_activity_from_url
(
in
R
eply
ToH
ref
)
do
{
:ok
,
[
activity
|
_
]}
<-
OStatus
.
fetch_activity_from_url
(
in
_r
eply
_to_h
ref
)
do
activity
else
_e
->
nil
...
...
@@ -111,11 +111,12 @@ def handle_note(entry, doc \\ nil) do
{
:ok
,
actor
}
<-
OStatus
.
find_make_or_update_user
(
author
),
content_html
<-
OStatus
.
get_content
(
entry
),
cw
<-
OStatus
.
get_cw
(
entry
),
inReplyTo
<-
XML
.
string_from_xpath
(
"//thr:in-reply-to[1]/@ref"
,
entry
),
inReplyToActivity
<-
fetch_replied_to_activity
(
entry
,
inReplyTo
),
inReplyTo
<-
(
inReplyToActivity
&&
inReplyToActivity
.
data
[
"object"
][
"id"
])
||
inReplyTo
,
in_reply_to
<-
XML
.
string_from_xpath
(
"//thr:in-reply-to[1]/@ref"
,
entry
),
in_reply_to_activity
<-
fetch_replied_to_activity
(
entry
,
in_reply_to
),
in_reply_to
<-
(
in_reply_to_activity
&&
in_reply_to_activity
.
data
[
"object"
][
"id"
])
||
in_reply_to
,
attachments
<-
OStatus
.
get_attachments
(
entry
),
context
<-
get_context
(
entry
,
in
R
eply
T
o
),
context
<-
get_context
(
entry
,
in
_r
eply
_t
o
),
tags
<-
OStatus
.
get_tags
(
entry
),
mentions
<-
get_mentions
(
entry
),
to
<-
make_to_list
(
actor
,
mentions
),
...
...
@@ -129,7 +130,7 @@ def handle_note(entry, doc \\ nil) do
context
,
content_html
,
attachments
,
in
R
eply
ToA
ctivity
,
in
_r
eply
_to_a
ctivity
,
[],
cw
),
...
...
@@ -141,8 +142,8 @@ def handle_note(entry, doc \\ nil) do
# TODO: Handle this case in make_note_data
note
<-
if
(
in
R
eply
T
o
&&
!in
R
eply
ToA
ctivity
,
do
:
note
|>
Map
.
put
(
"inReplyTo"
,
in
R
eply
T
o
),
in
_r
eply
_t
o
&&
!in
_r
eply
_to_a
ctivity
,
do
:
note
|>
Map
.
put
(
"inReplyTo"
,
in
_r
eply
_t
o
),
else
:
note
)
do
ActivityPub
.
create
(%{
...
...
lib/pleroma/web/twitter_api/twitter_api.ex
View file @
c3d41b2b
...
...
@@ -133,7 +133,7 @@ def upload(%Plug.Upload{} = file, %User{} = user, format \\ "xml") do
end
def
register_user
(
params
)
do
token
S
tring
=
params
[
"token"
]
token
_s
tring
=
params
[
"token"
]
params
=
%{
nickname:
params
[
"nickname"
],
...
...
@@ -170,8 +170,8 @@ def register_user(params) do
# no need to query DB if registration is open
token
=
unless
registrations_open
||
is_nil
(
token
S
tring
)
do
Repo
.
get_by
(
UserInviteToken
,
%{
token:
token
S
tring
})
unless
registrations_open
||
is_nil
(
token
_s
tring
)
do
Repo
.
get_by
(
UserInviteToken
,
%{
token:
token
_s
tring
})
end
cond
do
...
...
lib/pleroma/web/websub/websub.ex
View file @
c3d41b2b
...
...
@@ -200,8 +200,8 @@ def gather_feed_data(topic, getter \\ &@httpoison.get/1) do
uri
when
not
is_nil
(
uri
)
<-
XML
.
string_from_xpath
(
"/feed/author[1]/uri"
,
doc
),
hub
when
not
is_nil
(
hub
)
<-
XML
.
string_from_xpath
(
~S{/feed/link[@rel="hub"]/@href}
,
doc
)
do
name
=
XML
.
string_from_xpath
(
"/feed/author[1]/name"
,
doc
)
preferred
U
sername
=
XML
.
string_from_xpath
(
"/feed/author[1]/poco:preferredUsername"
,
doc
)
display
N
ame
=
XML
.
string_from_xpath
(
"/feed/author[1]/poco:displayName"
,
doc
)
preferred
_u
sername
=
XML
.
string_from_xpath
(
"/feed/author[1]/poco:preferredUsername"
,
doc
)
display
_n
ame
=
XML
.
string_from_xpath
(
"/feed/author[1]/poco:displayName"
,
doc
)
avatar
=
OStatus
.
make_avatar_object
(
doc
)
bio
=
XML
.
string_from_xpath
(
"/feed/author[1]/summary"
,
doc
)
...
...
@@ -209,8 +209,8 @@ def gather_feed_data(topic, getter \\ &@httpoison.get/1) do
%{
"uri"
=>
uri
,
"hub"
=>
hub
,
"nickname"
=>
preferred
U
sername
||
name
,
"name"
=>
display
N
ame
||
name
,
"nickname"
=>
preferred
_u
sername
||
name
,
"name"
=>
display
_n
ame
||
name
,
"host"
=>
URI
.
parse
(
uri
)
.
host
,
"avatar"
=>
avatar
,
"bio"
=>
bio
...
...
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