diff --git a/r2/r2/lib/db/queries.py b/r2/r2/lib/db/queries.py
index 3c97d71cd..1bcb72ee6 100644
--- a/r2/r2/lib/db/queries.py
+++ b/r2/r2/lib/db/queries.py
@@ -711,13 +711,13 @@ def new_message(message, inbox_rels):
from_user = Account._byID(message.author_id)
for inbox_rel in tup(inbox_rels):
to = inbox_rel._thing1
+ add_queries([get_sent(from_user)], insert_items=message)
# moderator message
if isinstance(inbox_rel, ModeratorInbox):
add_queries([get_subreddit_messages(to)],
insert_items = inbox_rel)
# personal message
else:
- add_queries([get_sent(from_user)], insert_items = message)
add_queries([get_inbox_messages(to)],
insert_items = inbox_rel)
set_unread(message, to, True)
diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py
index 1d7dda11e..c6d9a249b 100644
--- a/r2/r2/models/link.py
+++ b/r2/r2/models/link.py
@@ -1120,7 +1120,7 @@ class Message(Thing, Printable):
c.user_is_admin):
item.author = item.subreddit
item.hide_author = True
-
+
item.is_collapsed = None
if not item.new:
if item.recipient:
@@ -1134,6 +1134,24 @@ class Message(Thing, Printable):
if not c.user_is_admin:
item.subject = _('[message from blocked user]')
item.body = _('[unblock user to see this message]')
+ taglinetext = ''
+ if item.hide_author:
+ taglinetext = _("subreddit message %(author)s sent %(when)s ago")
+ elif item.author_id == c.user._id:
+ taglinetext = _("to %(dest)s sent %(when)s ago")
+ elif item.to_id == c.user._id or item.to_id is None:
+ taglinetext = _("from %(author)s sent %(when)s ago")
+ else:
+ taglinetext = _("to %(dest)s from %(author)s sent %(when)s ago")
+ item.taglinetext = taglinetext
+ item.dest = item.to.name if item.to else ""
+ if item.sr_id:
+ if item.hide_author:
+ item.updated_author = _("via %(subreddit)s")
+ else:
+ item.updated_author = _("%(author)s via %(subreddit)s")
+ else:
+ item.updated_author = ''
# Run this last
diff --git a/r2/r2/templates/message.compact b/r2/r2/templates/message.compact
index ecd8f5d8e..34f967304 100644
--- a/r2/r2/templates/message.compact
+++ b/r2/r2/templates/message.compact
@@ -54,32 +54,21 @@
<%
- taglinetext = ''
- if getattr(thing, "hide_author", False):
- taglinetext = _("subreddit message %(author)s sent %(when)s ago")
- elif thing.to_id == c.user._id or thing.to_id is None:
- taglinetext = _("from %(author)s sent %(when)s ago")
- elif thing.author_id == c.user._id:
- taglinetext = _("to %(dest)s sent %(when)s ago")
- else:
- taglinetext = _("to %(dest)s from %(author)s sent %(when)s ago")
-
- taglinetext = taglinetext.replace(' ', ' ')
author = WrappedUser(thing.author, thing.attribs, thing).render()
if thing.sr_id:
- if getattr(thing, "hide_author", False):
- updated_author = _("via %(subreddit)s")
- else:
- updated_author = _("%(author)s via %(subreddit)s").replace(' ', ' ')
subreddit = '
%s' % (thing.subreddit.path,
thing.subreddit.name)
- author = updated_author % dict(author = author, subreddit = subreddit)
+ if not thing.dest:
+ thing.dest = subreddit
+ author = thing.updated_author % dict(author=author, subreddit=subreddit)
+
+ taglinetext = thing.taglinetext % dict(when=thing.timesince,
+ author=u"
%s" % author,
+ dest=u"
%s" % thing.dest)
+ taglinetext = taglinetext.replace(' ', ' ')
%>
-
- ${unsafe(taglinetext % dict(when = thing.timesince,
- author= u"%s" % author,
- dest = u"%s" % (thing.to.name if thing.to else "")))}
+ ${unsafe(taglinetext)}
${unsafe(safemarkdown(thing.body))}
diff --git a/r2/r2/templates/message.html b/r2/r2/templates/message.html
index 7e3cf7a41..5c462dbcf 100644
--- a/r2/r2/templates/message.html
+++ b/r2/r2/templates/message.html
@@ -51,30 +51,20 @@ ${parent.thing_css_class(what)} ${"new" if thing.new else ""} ${"was-comment" if
<%
- taglinetext = ''
- if getattr(thing, "hide_author", False):
- taglinetext = _("subreddit message %(author)s sent %(when)s ago")
- elif thing.to_id == c.user._id or thing.to_id is None:
- taglinetext = _("from %(author)s sent %(when)s ago")
- elif thing.author_id == c.user._id:
- taglinetext = _("to %(dest)s sent %(when)s ago")
- else:
- taglinetext = _("to %(dest)s from %(author)s sent %(when)s ago")
-
- taglinetext = taglinetext.replace(' ', ' ')
author = WrappedUser(thing.author, thing.attribs, thing).render()
if thing.sr_id:
- if getattr(thing, "hide_author", False):
- updated_author = _("via %(subreddit)s")
- else:
- updated_author = _("%(author)s via %(subreddit)s").replace(' ', ' ')
- subreddit = '%s' % (thing.subreddit.path,
- thing.subreddit.name)
- author = updated_author % dict(author = author, subreddit = subreddit)
+ subreddit = '%s' % (thing.subreddit.path,
+ thing.subreddit.path)
+ if not thing.dest:
+ thing.dest = subreddit
+ author = thing.updated_author % dict(author=author, subreddit=subreddit)
+
+ taglinetext = thing.taglinetext % dict(when=thing.timesince,
+ author=u"%s" % author,
+ dest=u"%s" % thing.dest)
+ taglinetext = taglinetext.replace(' ', ' ')
%>
- ${unsafe(taglinetext % dict(when = thing.timesince,
- author= u"%s" % author,
- dest = u"%s" % (thing.to.name if thing.to else "")))}
+ ${unsafe(taglinetext)}
%if c.user_is_admin:
${self.admintagline()}
diff --git a/r2/r2/templates/message.xml b/r2/r2/templates/message.xml
index a752ef0fd..1fe320eb3 100644
--- a/r2/r2/templates/message.xml
+++ b/r2/r2/templates/message.xml
@@ -33,29 +33,15 @@
${permalink}
<%
- taglinetext = ''
- if getattr(thing, "hide_author", False):
- taglinetext = _("subreddit message %(author)s sent %(when)s ago")
- elif thing.to_id == c.user._id or thing.to_id is None:
- taglinetext = _("from %(author)s sent %(when)s ago")
- elif thing.author_id == c.user._id:
- taglinetext = _("to %(dest)s sent %(when)s ago")
- else:
- taglinetext = _("to %(dest)s from %(author)s sent %(when)s ago")
-
author = thing.author.name
if thing.sr_id and not (getattr(thing, "is_child", False) or
getattr(thing, "is_parent", False)):
- if getattr(thing, "hide_author", False):
- updated_author = _("via %(subreddit)s")
- else:
- updated_author = _("%(author)s via %(subreddit)s")
subreddit = thing.subreddit.name
- author = updated_author % dict(author = author, subreddit = subreddit)
+ author = thing.updated_author % dict(author=author, subreddit=subreddit)
%>
- ${thing.subject} : ${unsafe(taglinetext % dict(when = thing.timesince,
- author= u"%s" % author,
- dest = u"%s" % thing.to.name if thing.to else ""))}
+ ${thing.subject} : ${unsafe(thing.taglinetext % dict(when=thing.timesince,
+ author=u"%s" % author,
+ dest=u"%s" % thing.dest))}
${thing._date.strftime('%a, %d %b %Y %H:%M:%S %z')}
${thing._date.isoformat()}-0700