From 9b95fbf0dc42cfc98ad34c3122cb6336297f29f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Evren=20Esat=20=C3=96zkan?= Date: Fri, 22 Jul 2016 12:19:52 +0300 Subject: [PATCH] rref #5367 rref #5366 ref zetaops/zengine#66 ref zetaops/zengine#65 --- zengine/messaging/lib.py | 8 ++++---- zengine/messaging/model.py | 2 +- zengine/messaging/views.py | 11 ++++++----- zengine/tornado_server/server.py | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/zengine/messaging/lib.py b/zengine/messaging/lib.py index 69a02bbd..e7ea46b3 100644 --- a/zengine/messaging/lib.py +++ b/zengine/messaging/lib.py @@ -68,9 +68,10 @@ def is_online(self, status=None): else: mq_channel = self._connect_mq() for sbs in self.subscriptions.objects.filter(): - mq_channel.basic_publish(exchange=sbs.channel.key, - routing_key='', - body=json.dumps({ + if sbs.channel.typ == 10: + mq_channel.basic_publish(exchange=sbs.channel.code_name, + routing_key='', + body=json.dumps({ 'cmd': 'user_status', 'channel_key': sbs.channel.key, 'channel_name': sbs.name, @@ -79,7 +80,6 @@ def is_online(self, status=None): })) ConnectionStatus(self.key).set(status) - def encrypt_password(self): """ encrypt password if not already encrypted """ if self.password and not self.password.startswith('$pbkdf2'): diff --git a/zengine/messaging/model.py b/zengine/messaging/model.py index 9b1328e6..ed90656a 100644 --- a/zengine/messaging/model.py +++ b/zengine/messaging/model.py @@ -329,7 +329,7 @@ def serialize(self, user=None): 'content': self.body, 'type': self.typ, 'updated_at': self.updated_at, - 'timestamp': self.timestamp.strftime(DATE_TIME_FORMAT), + 'timestamp': self.updated_at, 'is_update': hasattr(self, 'unsaved'), 'attachments': [attachment.serialize() for attachment in self.attachment_set], 'title': self.msg_title, diff --git a/zengine/messaging/views.py b/zengine/messaging/views.py index f2a793ff..29ef5781 100644 --- a/zengine/messaging/views.py +++ b/zengine/messaging/views.py @@ -224,7 +224,7 @@ def report_last_seen_message(current): { 'view':'_zops_last_seen_msg', 'channel_key': key, - 'msg_key': key, + 'key': key, 'timestamp': datetime, } @@ -671,14 +671,15 @@ def delete_message(current): # response: { + 'key': key, 'status': 'OK', 'code': 200 } """ try: Message(current).objects.get(sender_id=current.user_id, - key=current.input['message_key']).delete() - current.output = {'status': 'Deleted', 'code': 200} + key=current.input['key']).delete() + current.output = {'status': 'Deleted', 'code': 200, 'key': current.input['key']} except ObjectDoesNotExist: raise HTTPError(404, "") @@ -772,7 +773,7 @@ def get_message_actions(current): # request: { 'view':'_zops_get_message_actions', - 'message_key': key, + 'key': key, } # response: { @@ -785,7 +786,7 @@ def get_message_actions(current): current.output = {'status': 'OK', 'code': 200, 'actions': Message.objects.get( - current.input['message_key']).get_actions_for(current.user)} + current.input['key']).get_actions_for(current.user)} def add_to_favorites(current): diff --git a/zengine/tornado_server/server.py b/zengine/tornado_server/server.py index 7c13e8b7..9753f57b 100644 --- a/zengine/tornado_server/server.py +++ b/zengine/tornado_server/server.py @@ -137,7 +137,7 @@ def post(self, view_name): (r'/(\w+)', HttpHandler), ] -app = web.Application(URL_CONFS, debug=DEBUG) +app = web.Application(URL_CONFS, debug=DEBUG, autoreload=False) def runserver(host=None, port=None):