diff --git a/zerver/models.py b/zerver/models.py index ebc55a6021..bcfce5a487 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -815,11 +815,7 @@ class Message(ModelReprMixin, models.Model): domain = u"mit.edu/zephyr_mirror" rendered_content = bugdown.convert(content, domain, self) - # For /me syntax, JS can detect the is_me_message flag - # and do special rendering. - if content.startswith('/me ') and '\n' not in content: - if rendered_content.startswith('
') and rendered_content.endswith('
'): - self.is_me_message = True + self.is_me_message = Message.is_status_message(content, rendered_content) return rendered_content @@ -1117,6 +1113,17 @@ class Message(ModelReprMixin, models.Model): # type: (text_type) -> bool return 'http://' in content or 'https://' in content or '/user_uploads' in content + @staticmethod + def is_status_message(content, rendered_content): + # type: (text_type, text_type) -> bool + """ + Returns True if content and rendered_content are from 'me_message' + """ + if content.startswith('/me ') and '\n' not in content: + if rendered_content.startswith('') and rendered_content.endswith('
'): + return True + return False + def update_calculated_fields(self): # type: () -> None # TODO: rendered_content could also be considered a calculated field