update message text, ignore errors for now
This commit is contained in:
parent
409f6651c3
commit
d1d7ae7365
|
@ -69,15 +69,13 @@ def send_topic_update_email(sender, instance, **kwargs):
|
||||||
to=[user_email],
|
to=[user_email],
|
||||||
headers={'Reply-To': 'no-reply@maidstone-hackspace.org.uk'})
|
headers={'Reply-To': 'no-reply@maidstone-hackspace.org.uk'})
|
||||||
email.send()
|
email.send()
|
||||||
matrix_message.delay('%s https://%s%s' % (
|
matrix_message.delay('https://%s%s' % (
|
||||||
instance.topic.title,
|
|
||||||
Site.objects.get_current().domain,
|
Site.objects.get_current().domain,
|
||||||
instance.topic.get_absolute_url()))
|
instance.topic.get_absolute_url()))
|
||||||
|
|
||||||
|
|
||||||
def wiki_article_updated(sender, instance, **kwargs):
|
def wiki_article_updated(sender, instance, **kwargs):
|
||||||
matrix_message.delay('%s https://%s%s' % (
|
matrix_message.delay('https://%s%s' % (
|
||||||
instance.title,
|
|
||||||
Site.objects.get_current().domain,
|
Site.objects.get_current().domain,
|
||||||
instance.article.get_absolute_url()))
|
instance.article.get_absolute_url()))
|
||||||
|
|
||||||
|
|
|
@ -17,62 +17,34 @@ matrix_send_msg_url = matrix_url + "/rooms/%21{room}/send/m.room.message?access_
|
||||||
|
|
||||||
@shared_task
|
@shared_task
|
||||||
def matrix_message(message):
|
def matrix_message(message):
|
||||||
# login
|
# we dont rely on theses, so ignore if it goes wrong
|
||||||
details = {
|
# TODO at least log that something has gone wrong
|
||||||
"type":"m.login.password",
|
try:
|
||||||
"user":settings.MATRIX_USER,
|
# login
|
||||||
"password":settings.MATRIX_PASSWORD}
|
details = {
|
||||||
r0 = requests.post(matrix_login_url, json = details)
|
"type":"m.login.password",
|
||||||
access_token = r0.json().get('access_token')
|
"user":settings.MATRIX_USER,
|
||||||
|
"password":settings.MATRIX_PASSWORD}
|
||||||
|
r0 = requests.post(matrix_login_url, json = details)
|
||||||
|
access_token = r0.json().get('access_token')
|
||||||
|
|
||||||
# join room by id
|
# join room by id
|
||||||
url_params = {
|
url_params = {
|
||||||
'room': settings.MATRIX_ROOM,
|
'room': settings.MATRIX_ROOM,
|
||||||
'access_token': access_token}
|
'access_token': access_token}
|
||||||
url = matrix_join_room_id_url.format(**url_params)
|
url = matrix_join_room_id_url.format(**url_params)
|
||||||
r1 = requests.post(url)
|
r1 = requests.post(url)
|
||||||
|
|
||||||
# send message
|
# send message
|
||||||
url_params = {
|
url_params = {
|
||||||
"room": settings.MATRIX_ROOM,
|
"room": settings.MATRIX_ROOM,
|
||||||
"access_token": access_token}
|
"access_token": access_token}
|
||||||
url = matrix_send_msg_url.format(**url_params)
|
url = matrix_send_msg_url.format(**url_params)
|
||||||
details = {
|
details = {
|
||||||
"msgtype": "m.text",
|
"msgtype": "m.text",
|
||||||
"body": "%s %s" % (settings.MSG_PREFIX, message)}
|
"body": "%s %s" % (settings.MSG_PREFIX, message)}
|
||||||
r2 = requests.post(url, json=details)
|
r2 = requests.post(url, json=details)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# url = "https://matrix.org/_matrix/client/r0/join/{room_alias}?access_token={access_token}".format(
|
|
||||||
# **{'access_token': access_token,
|
|
||||||
# 'room_alias': '#maidstone-hackspace:matrix.org'})
|
|
||||||
# response = requests.post(url)
|
|
||||||
|
|
||||||
|
|
||||||
# return import_feeds()
|
|
||||||
# url = "https://matrix.org/_matrix/client/r0/rooms/%21{room}:matrix.org/join?access_token={access_token}".format(
|
|
||||||
# **{'room': 'fmCpNwqgIiuwATlcdw',
|
|
||||||
# 'access_token': access_token})
|
|
||||||
# r = requests.get(url)
|
|
||||||
# fmCpNwqgIiuwATlcdw:matrix.org
|
|
||||||
|
|
||||||
|
|
||||||
#join room by id
|
|
||||||
# url = "https://matrix.org/_matrix/client/r0/rooms/%21{room}/join?access_token={access_token}".format(
|
|
||||||
# **{'room': 'fmCpNwqgIiuwATlcdw:matrix.org',
|
|
||||||
# 'access_token': access_token})
|
|
||||||
# response = requests.post(url)
|
|
||||||
|
|
||||||
|
|
||||||
# url = "https://matrix.org/_matrix/client/r0/rooms/%21{room}/send/m.room.message?access_token={access_token}".format(
|
|
||||||
# **{'room': 'fmCpNwqgIiuwATlcdw:matrix.org',
|
|
||||||
# 'access_token': access_token})
|
|
||||||
# details = {"msgtype":"m.text", "body":"poke from python"} #{"type":"m.login.password", "user":"oly", "password":""}
|
|
||||||
# r = requests.post(url, json = details)
|
|
||||||
# return r.json()
|
|
||||||
|
|
||||||
|
|
||||||
# url = "https://matrix.org/_matrix/client/r0/rooms/%21{room}/join?access_token={access_token}".format(
|
|
||||||
# **{'room': 'fmCpNwqgIiuwATlcdw:matrix.org',
|
|
||||||
# 'access_token': access_token})
|
|
||||||
# response = requests.post(url)
|
|
||||||
|
|
Loading…
Reference in New Issue