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
be187f82
Commit
be187f82
authored
Dec 05, 2018
by
Ivan Tashkinov
Browse files
[
#210
] Further refactoring.
parent
44ab3dbe
Changes
1
Hide whitespace changes
Inline
Side-by-side
lib/pleroma/web/twitter_api/twitter_api_controller.ex
View file @
be187f82
...
...
@@ -226,13 +226,21 @@ def fetch_conversation(%{assigns: %{user: user}} = conn, %{"id" => id}) do
end
end
@doc
"https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-metadata-create"
@doc
"""
Updates metadata of uploaded media object.
Derived from [Twitter API endpoint](https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-metadata-create).
"""
def
update_media
(%{
assigns:
%{
user:
_
}}
=
conn
,
%{
"media_id"
=>
id
}
=
data
)
do
description
=
get_in
(
data
,
[
"alt_text"
,
"text"
])
||
data
[
"name"
]
||
data
[
"description"
]
with
%
Object
{}
=
object
<-
Repo
.
get
(
Object
,
id
),
is_binary
(
description
)
do
with
%
Object
{}
=
object
<-
Repo
.
get
(
Object
,
id
),
is_binary
(
description
)
do
new_data
=
Map
.
put
(
object
.
data
,
"name"
,
description
)
{
:ok
,
_
}
=
object
|>
Object
.
change
(%{
data:
new_data
})
|>
Repo
.
update
()
{
:ok
,
_
}
=
object
|>
Object
.
change
(%{
data:
new_data
})
|>
Repo
.
update
()
end
conn
...
...
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