Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
facebook
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
mautrix
facebook
Commits
d3a8cc88
Commit
d3a8cc88
authored
4 years ago
by
Tulir Asokan
Browse files
Options
Downloads
Patches
Plain Diff
Use main fbchat aiohttp session for all avatar downloads
parent
e3535d3b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mautrix_facebook/puppet.py
+2
-2
2 additions, 2 deletions
mautrix_facebook/puppet.py
with
2 additions
and
2 deletions
mautrix_facebook/puppet.py
+
2
−
2
View file @
d3a8cc88
...
@@ -191,14 +191,14 @@ class Puppet(CustomPuppetMixin):
...
@@ -191,14 +191,14 @@ class Puppet(CustomPuppetMixin):
async
def
reupload_avatar
(
source
:
Optional
[
'
u.User
'
],
intent
:
IntentAPI
,
url
:
str
,
async
def
reupload_avatar
(
source
:
Optional
[
'
u.User
'
],
intent
:
IntentAPI
,
url
:
str
,
fbid
:
Optional
[
str
])
->
ContentURI
:
fbid
:
Optional
[
str
])
->
ContentURI
:
data
=
None
data
=
None
http_client
=
source
.
client
.
session
.
_session
if
url
and
source
and
source
.
client
and
source
.
client
.
session
:
if
url
and
source
and
source
.
client
and
source
.
client
.
session
:
http_client
=
source
.
client
.
session
.
_session
graph_url
=
f
"
https://graph.facebook.com/
{
fbid
}
/picture?width=1000&height=1000
"
graph_url
=
f
"
https://graph.facebook.com/
{
fbid
}
/picture?width=1000&height=1000
"
async
with
http_client
.
get
(
graph_url
)
as
resp
:
async
with
http_client
.
get
(
graph_url
)
as
resp
:
if
resp
.
status
<
400
:
if
resp
.
status
<
400
:
data
=
await
resp
.
read
()
data
=
await
resp
.
read
()
if
data
is
None
:
if
data
is
None
:
async
with
aio
http
.
C
lient
Session
()
as
session
,
session
.
get
(
url
)
as
resp
:
async
with
http
_c
lient
.
get
(
url
)
as
resp
:
data
=
await
resp
.
read
()
data
=
await
resp
.
read
()
mime
=
magic
.
from_buffer
(
data
,
mime
=
True
)
mime
=
magic
.
from_buffer
(
data
,
mime
=
True
)
return
await
intent
.
upload_media
(
data
,
mime_type
=
mime
)
return
await
intent
.
upload_media
(
data
,
mime_type
=
mime
)
...
...
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