From b416587aabec1e4ccf679652b7f3d61a6788317a Mon Sep 17 00:00:00 2001 From: Rishi Gupta Date: Tue, 14 Mar 2017 15:31:05 -0700 Subject: [PATCH] Change sender_domain to sender_realm_str in message dict. --- templates/zerver/api_content.json | 4 ++-- tools/zulip-export/zulip-export | 2 +- zerver/lib/feedback.py | 4 ++-- zerver/lib/message.py | 8 ++++---- zerver/models.py | 4 ++-- zerver/tests/test_events.py | 2 +- zerver/tests/test_messages.py | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/templates/zerver/api_content.json b/templates/zerver/api_content.json index ab5360a195..941ac0975b 100644 --- a/templates/zerver/api_content.json +++ b/templates/zerver/api_content.json @@ -81,7 +81,7 @@ 'sender_full_name': 'Othello Bot', 'sender_email': 'othello-bot@example.com', 'sender_short_name': 'othello-bot', - 'sender_domain': 'example.com', + 'sender_realm_str': 'example', 'content': 'Something is rotten in the state of Denmark.', 'gravatar_hash': '17d93357cca1e793739836ecbc7a9bf7', 'recipient_id': 12314, @@ -106,7 +106,7 @@ 'sender_full_name': 'Othello Bot', 'sender_email': 'othello-bot@example.com', 'sender_short_name': 'othello-bot', - 'sender_domain': 'example.com', + 'sender_realm_str': 'example', 'content': 'I come not, friends, to steal away your hearts.', 'gravatar_hash': '17d93357cca1e793739836ecbc7a9bf7', 'recipient_id': 18391, diff --git a/tools/zulip-export/zulip-export b/tools/zulip-export/zulip-export index 9ce8609d0a..4d70c490e1 100755 --- a/tools/zulip-export/zulip-export +++ b/tools/zulip-export/zulip-export @@ -81,7 +81,7 @@ for msg in result['messages']: # Remove extraneous metadata for k in ['flags', 'edit_history', 'subject_links', 'gravatar_hash', 'avatar_url', 'recipient_id', 'sender_short_name', - 'content_type', 'client', 'sender_domain', 'id', 'type']: + 'content_type', 'client', 'sender_realm_str', 'id', 'type']: msg.pop(k, None) messages.append(msg) diff --git a/zerver/lib/feedback.py b/zerver/lib/feedback.py index 9ce2c3d4ae..1cd70a588a 100644 --- a/zerver/lib/feedback.py +++ b/zerver/lib/feedback.py @@ -56,8 +56,8 @@ def deliver_feedback_by_zulip(message): content += '\nticket Z%03d (@support please ack)' % (ticket_number,) content += '\nsender: %s' % (message['sender_full_name'],) content += '\nemail: %s' % (sender_email,) - if 'sender_domain' in message: - content += '\nrealm: %s' % (message['sender_domain'],) + if 'sender_realm_str' in message: + content += '\nrealm: %s' % (message['sender_realm_str'],) content += '\n~~~' content += '\n\n' diff --git a/zerver/lib/message.py b/zerver/lib/message.py index 47316ffa37..3dc7aedaaf 100644 --- a/zerver/lib/message.py +++ b/zerver/lib/message.py @@ -75,7 +75,7 @@ class MessageDict(object): sender_id = message.sender.id, sender_email = message.sender.email, sender_realm_id = message.sender.realm_id, - sender_realm_domain = message.sender.realm.domain, + sender_realm_str = message.sender.realm.string_id, sender_full_name = message.sender.full_name, sender_short_name = message.sender.short_name, sender_avatar_source = message.sender.avatar_source, @@ -109,7 +109,7 @@ class MessageDict(object): sender_id = row['sender_id'], sender_email = row['sender__email'], sender_realm_id = row['sender__realm__id'], - sender_realm_domain = row['sender__realm__domain'], + sender_realm_str = row['sender__realm__string_id'], sender_full_name = row['sender__full_name'], sender_short_name = row['sender__short_name'], sender_avatar_source = row['sender__avatar_source'], @@ -137,7 +137,7 @@ class MessageDict(object): sender_id, sender_email, sender_realm_id, - sender_realm_domain, + sender_realm_str, sender_full_name, sender_short_name, sender_avatar_source, @@ -186,7 +186,7 @@ class MessageDict(object): sender_email = sender_email, sender_full_name = sender_full_name, sender_short_name = sender_short_name, - sender_domain = sender_realm_domain, + sender_realm_str = sender_realm_str, sender_id = sender_id, type = display_type, display_recipient = display_recipient, diff --git a/zerver/models.py b/zerver/models.py index b05c68a92a..c872d26f77 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -1008,7 +1008,7 @@ class Message(AbstractMessage): id = self.id, sender_id = self.sender.id, sender_email = self.sender.email, - sender_domain = self.sender.realm.domain, + sender_realm_str = self.sender.realm.string_id, sender_full_name = self.sender.full_name, sender_short_name = self.sender.short_name, sending_client = self.sending_client.name, @@ -1041,7 +1041,7 @@ class Message(AbstractMessage): 'sender__full_name', 'sender__short_name', 'sender__realm__id', - 'sender__realm__domain', + 'sender__realm__string_id', 'sender__avatar_source', 'sender__avatar_version', 'sender__is_mirror_dummy', diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index 05c4ff062d..1c988eb27f 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -397,7 +397,7 @@ class EventsRegisterTest(ZulipTestCase): ('gravatar_hash', check_string), ('id', check_int), ('recipient_id', check_int), - ('sender_domain', check_string), + ('sender_realm_str', check_string), ('sender_email', check_string), ('sender_full_name', check_string), ('sender_id', check_int), diff --git a/zerver/tests/test_messages.py b/zerver/tests/test_messages.py index da4033c65c..3a99bcf89e 100644 --- a/zerver/tests/test_messages.py +++ b/zerver/tests/test_messages.py @@ -1859,7 +1859,7 @@ class LogDictTest(ZulipTestCase): self.assertEqual(dct['content'], 'find me some good coffee shops') self.assertEqual(dct['id'], message.id) self.assertEqual(dct['recipient'], 'Denmark') - self.assertEqual(dct['sender_domain'], 'zulip.com') + self.assertEqual(dct['sender_realm_str'], 'zulip') self.assertEqual(dct['sender_email'], 'hamlet@zulip.com') self.assertEqual(dct['sender_full_name'], 'King Hamlet') self.assertEqual(dct['sender_id'], get_user_profile_by_email(email).id)