attempt to generate the pnut matrix user on event
This commit is contained in:
parent
03949ff67b
commit
937ad8cea1
1 changed files with 12 additions and 0 deletions
|
@ -390,6 +390,17 @@ def create_room(channel, invite):
|
||||||
logger.debug(r.status_code)
|
logger.debug(r.status_code)
|
||||||
logger.debug(r)
|
logger.debug(r)
|
||||||
|
|
||||||
|
def new_matrix_user(username):
|
||||||
|
matrix_api = MatrixHttpApi(app.config['MATRIX_HOST'],
|
||||||
|
token=app.config['MATRIX_AS_TOKEN'])
|
||||||
|
data = {'type': 'm.login.application_service','user': app.config['MATRIX_PNUT_PREFIX'] + username}
|
||||||
|
try:
|
||||||
|
matrix_api.register(content=data)
|
||||||
|
|
||||||
|
except Exception:
|
||||||
|
errmsg = "- new_matrix_user user already exists -"
|
||||||
|
logger.warning(errmsg)
|
||||||
|
|
||||||
def on_admin_event(event):
|
def on_admin_event(event):
|
||||||
matrix_api = MatrixHttpApi(app.config['MATRIX_HOST'],
|
matrix_api = MatrixHttpApi(app.config['MATRIX_HOST'],
|
||||||
token=app.config['MATRIX_AS_TOKEN'])
|
token=app.config['MATRIX_AS_TOKEN'])
|
||||||
|
@ -574,6 +585,7 @@ def on_direct_invite(event):
|
||||||
# TODO: need to handle if the user isn't registered
|
# TODO: need to handle if the user isn't registered
|
||||||
pnutpy.api.add_authorization_token(user.pnut_user_token)
|
pnutpy.api.add_authorization_token(user.pnut_user_token)
|
||||||
channel, meta = pnutpy.api.existing_pm(ids=pnut_user)
|
channel, meta = pnutpy.api.existing_pm(ids=pnut_user)
|
||||||
|
new_matrix_user(pnut_user)
|
||||||
|
|
||||||
dm = DirectRooms(room_id=event['room_id'],
|
dm = DirectRooms(room_id=event['room_id'],
|
||||||
bridge_user=bridge_user, pnut_chan=channel.id)
|
bridge_user=bridge_user, pnut_chan=channel.id)
|
||||||
|
|
Loading…
Reference in a new issue