Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mautrix-amp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Tulir Asokan
mautrix-amp
Commits
fc62029b
Commit
fc62029b
authored
3 years ago
by
Tulir Asokan
Browse files
Options
Downloads
Patches
Plain Diff
Update provisioning API paths
parent
26fb3a20
Branches
unpuppet
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#2827
passed
3 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mautrix_amp/user.py
+1
-7
1 addition, 7 deletions
mautrix_amp/user.py
mautrix_amp/web/provisioning_api.py
+8
-6
8 additions, 6 deletions
mautrix_amp/web/provisioning_api.py
with
9 additions
and
13 deletions
mautrix_amp/user.py
+
1
−
7
View file @
fc62029b
...
...
@@ -68,16 +68,10 @@ class User(DBUser, BaseUser):
async
def
is_logged_in
(
self
)
->
bool
:
try
:
return
bool
(
self
.
client
)
#
and
(await self.client.start()).is_logged_in
return
bool
(
self
.
client
)
and
bool
(
self
.
session_data
)
except
Exception
:
return
False
async
def
try_connect
(
self
)
->
None
:
try
:
await
self
.
connect
()
except
Exception
:
self
.
log
.
exception
(
"
Error while connecting to puppeteer script
"
)
async
def
connect_double_puppet
(
self
)
->
None
:
self
.
log
.
debug
(
"
Trying to log in with shared secret
"
)
try
:
...
...
This diff is collapsed.
Click to expand it.
mautrix_amp/web/provisioning_api.py
+
8
−
6
View file @
fc62029b
...
...
@@ -32,8 +32,8 @@ class ProvisioningAPI:
def
__init__
(
self
,
shared_secret
:
str
)
->
None
:
self
.
app
=
web
.
Application
()
self
.
shared_secret
=
shared_secret
self
.
app
.
router
.
add_get
(
"
/
api/
whoami
"
,
self
.
status
)
self
.
app
.
router
.
add_get
(
"
/
api/
login
"
,
self
.
login
)
self
.
app
.
router
.
add_get
(
"
/whoami
"
,
self
.
status
)
self
.
app
.
router
.
add_get
(
"
/login
"
,
self
.
login
)
@property
def
_acao_headers
(
self
)
->
Dict
[
str
,
str
]:
...
...
@@ -95,8 +95,9 @@ class ProvisioningAPI:
data
=
{
"
mxid
"
:
user
.
mxid
,
"
amp
"
:
{
"
connected
"
:
True
,
}
if
await
user
.
is_logged_in
()
else
None
,
"
has_session
"
:
user
.
session_data
is
not
None
,
"
connected
"
:
await
user
.
is_logged_in
(),
},
}
return
web
.
json_response
(
data
,
headers
=
self
.
_acao_headers
)
...
...
@@ -109,12 +110,13 @@ class ProvisioningAPI:
ws
=
web
.
WebSocketResponse
(
protocols
=
[
"
net.maunium.amp.login
"
])
await
ws
.
prepare
(
request
)
# TODO if already logged in, send "already logged in" as an error
try
:
async
for
url
in
user
.
client
.
login
():
self
.
log
.
debug
(
"
Sending QR URL %s to websocket
"
,
url
)
await
ws
.
send_json
({
"
url
"
:
url
})
except
Exception
:
await
ws
.
send_json
({
"
success
"
:
False
})
except
Exception
as
e
:
await
ws
.
send_json
({
"
success
"
:
False
,
"
error
"
:
str
(
e
)
})
self
.
log
.
exception
(
"
Error logging in
"
)
else
:
await
ws
.
send_json
({
"
success
"
:
True
})
...
...
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