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
d5f03c1a
Commit
d5f03c1a
authored
4 years ago
by
Tulir Asokan
Browse files
Options
Downloads
Patches
Plain Diff
Add API for refreshing connection
parent
f7690032
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mautrix_facebook/web/public.py
+28
-1
28 additions, 1 deletion
mautrix_facebook/web/public.py
with
28 additions
and
1 deletion
mautrix_facebook/web/public.py
+
28
−
1
View file @
d5f03c1a
...
@@ -46,6 +46,9 @@ class PublicBridgeWebsite:
...
@@ -46,6 +46,9 @@ class PublicBridgeWebsite:
self
.
app
.
router
.
add_options
(
"
/api/login
"
,
self
.
login_options
)
self
.
app
.
router
.
add_options
(
"
/api/login
"
,
self
.
login_options
)
self
.
app
.
router
.
add_post
(
"
/api/login
"
,
self
.
login
)
self
.
app
.
router
.
add_post
(
"
/api/login
"
,
self
.
login
)
self
.
app
.
router
.
add_post
(
"
/api/logout
"
,
self
.
logout
)
self
.
app
.
router
.
add_post
(
"
/api/logout
"
,
self
.
logout
)
self
.
app
.
router
.
add_post
(
"
/api/disconnect
"
,
self
.
disconnect
)
self
.
app
.
router
.
add_post
(
"
/api/reconnect
"
,
self
.
reconnect
)
self
.
app
.
router
.
add_post
(
"
/api/refresh
"
,
self
.
refresh
)
self
.
app
.
router
.
add_static
(
"
/
"
,
pkg_resources
.
resource_filename
(
"
mautrix_facebook
"
,
self
.
app
.
router
.
add_static
(
"
/
"
,
pkg_resources
.
resource_filename
(
"
mautrix_facebook
"
,
"
web/static/
"
))
"
web/static/
"
))
...
@@ -106,9 +109,11 @@ class PublicBridgeWebsite:
...
@@ -106,9 +109,11 @@ class PublicBridgeWebsite:
"
facebook
"
:
None
,
"
facebook
"
:
None
,
}
}
if
await
user
.
is_logged_in
():
if
await
user
.
is_logged_in
():
info
=
cast
(
fbchat
.
UserData
,
await
user
.
client
.
fetch_thread_info
([
user
.
fbid
]).
__anext__
())
info
=
cast
(
fbchat
.
UserData
,
await
user
.
client
.
fetch_thread_info
([
user
.
fbid
]).
__anext__
())
data
[
"
facebook
"
]
=
attr
.
asdict
(
info
)
data
[
"
facebook
"
]
=
attr
.
asdict
(
info
)
del
data
[
"
facebook
"
][
"
session
"
]
del
data
[
"
facebook
"
][
"
session
"
]
data
[
"
facebook
"
][
"
connected
"
]
=
user
.
is_connected
return
web
.
json_response
(
data
,
headers
=
self
.
_acao_headers
)
return
web
.
json_response
(
data
,
headers
=
self
.
_acao_headers
)
async
def
login
(
self
,
request
:
web
.
Request
)
->
web
.
Response
:
async
def
login
(
self
,
request
:
web
.
Request
)
->
web
.
Response
:
...
@@ -149,3 +154,25 @@ class PublicBridgeWebsite:
...
@@ -149,3 +154,25 @@ class PublicBridgeWebsite:
if
puppet
.
is_real_user
:
if
puppet
.
is_real_user
:
await
puppet
.
switch_mxid
(
None
,
None
)
await
puppet
.
switch_mxid
(
None
,
None
)
return
web
.
json_response
({},
headers
=
self
.
_acao_headers
)
return
web
.
json_response
({},
headers
=
self
.
_acao_headers
)
async
def
disconnect
(
self
,
request
:
web
.
Request
)
->
web
.
Response
:
user
=
self
.
check_token
(
request
)
if
not
user
.
is_connected
:
raise
web
.
HTTPBadRequest
(
body
=
'
{
"
error
"
:
"
User is not connected
"
}
'
,
headers
=
self
.
_headers
)
user
.
listener
.
disconnect
()
await
user
.
listen_task
return
web
.
json_response
({},
headers
=
self
.
_acao_headers
)
async
def
reconnect
(
self
,
request
:
web
.
Request
)
->
web
.
Response
:
user
=
self
.
check_token
(
request
)
if
user
.
is_connected
:
raise
web
.
HTTPConflict
(
body
=
'
{
"
error
"
:
"
User is already connected
"
}
'
,
headers
=
self
.
_headers
)
user
.
start_listen
()
return
web
.
json_response
({},
headers
=
self
.
_acao_headers
)
async
def
refresh
(
self
,
request
:
web
.
Request
)
->
web
.
Response
:
user
=
self
.
check_token
(
request
)
await
user
.
try_refresh
()
return
web
.
json_response
({},
headers
=
self
.
_acao_headers
)
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