|
|
@ -201,9 +201,11 @@ class NotifyMatrix(NotifyBase):
|
|
|
|
'{schema}://{token}',
|
|
|
|
'{schema}://{token}',
|
|
|
|
'{schema}://{user}@{token}',
|
|
|
|
'{schema}://{user}@{token}',
|
|
|
|
|
|
|
|
|
|
|
|
# Disabled webhook
|
|
|
|
# Matrix Server
|
|
|
|
'{schema}://{user}:{password}@{host}/{targets}',
|
|
|
|
'{schema}://{user}:{password}@{host}/{targets}',
|
|
|
|
'{schema}://{user}:{password}@{host}:{port}/{targets}',
|
|
|
|
'{schema}://{user}:{password}@{host}:{port}/{targets}',
|
|
|
|
|
|
|
|
'{schema}://{token}@{host}/{targets}',
|
|
|
|
|
|
|
|
'{schema}://{token}@{host}:{port}/{targets}',
|
|
|
|
|
|
|
|
|
|
|
|
# Webhook mode
|
|
|
|
# Webhook mode
|
|
|
|
'{schema}://{user}:{token}@{host}/{targets}',
|
|
|
|
'{schema}://{user}:{token}@{host}/{targets}',
|
|
|
@ -612,6 +614,9 @@ class NotifyMatrix(NotifyBase):
|
|
|
|
Perform Direct Matrix Server Notification (no webhook)
|
|
|
|
Perform Direct Matrix Server Notification (no webhook)
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.access_token is None and self.password and not self.user:
|
|
|
|
|
|
|
|
self.access_token = self.password
|
|
|
|
|
|
|
|
|
|
|
|
if self.access_token is None:
|
|
|
|
if self.access_token is None:
|
|
|
|
# We need to register
|
|
|
|
# We need to register
|
|
|
|
if not self._login():
|
|
|
|
if not self._login():
|
|
|
@ -890,14 +895,7 @@ class NotifyMatrix(NotifyBase):
|
|
|
|
# Login not required; silently skip-over
|
|
|
|
# Login not required; silently skip-over
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
if not (self.user and self.password):
|
|
|
|
if (self.user and self.password):
|
|
|
|
# It's not possible to register since we need these 2 values to
|
|
|
|
|
|
|
|
# make the action possible.
|
|
|
|
|
|
|
|
self.logger.warning(
|
|
|
|
|
|
|
|
'Failed to login to Matrix server: '
|
|
|
|
|
|
|
|
'user/pass combo is missing.')
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Prepare our Authentication Payload
|
|
|
|
# Prepare our Authentication Payload
|
|
|
|
if self.version == MatrixVersion.V3:
|
|
|
|
if self.version == MatrixVersion.V3:
|
|
|
|
payload = {
|
|
|
|
payload = {
|
|
|
@ -916,6 +914,14 @@ class NotifyMatrix(NotifyBase):
|
|
|
|
'password': self.password,
|
|
|
|
'password': self.password,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
# It's not possible to register since we need these 2 values to
|
|
|
|
|
|
|
|
# make the action possible.
|
|
|
|
|
|
|
|
self.logger.warning(
|
|
|
|
|
|
|
|
'Failed to login to Matrix server: '
|
|
|
|
|
|
|
|
'token or user/pass combo is missing.')
|
|
|
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
# Build our URL
|
|
|
|
# Build our URL
|
|
|
|
postokay, response = self._fetch('/login', payload=payload)
|
|
|
|
postokay, response = self._fetch('/login', payload=payload)
|
|
|
|
if not (postokay and isinstance(response, dict)):
|
|
|
|
if not (postokay and isinstance(response, dict)):
|
|
|
@ -1483,9 +1489,10 @@ class NotifyMatrix(NotifyBase):
|
|
|
|
safe=''),
|
|
|
|
safe=''),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
elif self.user:
|
|
|
|
elif self.user or self.password:
|
|
|
|
auth = '{user}@'.format(
|
|
|
|
auth = '{value}@'.format(
|
|
|
|
user=NotifyMatrix.quote(self.user, safe=''),
|
|
|
|
value=NotifyMatrix.quote(
|
|
|
|
|
|
|
|
self.user if self.user else self.password, safe=''),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
default_port = 443 if self.secure else 80
|
|
|
|
default_port = 443 if self.secure else 80
|
|
|
@ -1567,6 +1574,11 @@ class NotifyMatrix(NotifyBase):
|
|
|
|
if 'token' in results['qsd'] and len(results['qsd']['token']):
|
|
|
|
if 'token' in results['qsd'] and len(results['qsd']['token']):
|
|
|
|
results['password'] = NotifyMatrix.unquote(results['qsd']['token'])
|
|
|
|
results['password'] = NotifyMatrix.unquote(results['qsd']['token'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif not results['password'] and results['user']:
|
|
|
|
|
|
|
|
# swap
|
|
|
|
|
|
|
|
results['password'] = results['user']
|
|
|
|
|
|
|
|
results['user'] = None
|
|
|
|
|
|
|
|
|
|
|
|
# Support the use of the version= or v= keyword
|
|
|
|
# Support the use of the version= or v= keyword
|
|
|
|
if 'version' in results['qsd'] and len(results['qsd']['version']):
|
|
|
|
if 'version' in results['qsd'] and len(results['qsd']['version']):
|
|
|
|
results['version'] = \
|
|
|
|
results['version'] = \
|
|
|
|