def readd_mention_notification(mention): """Reinsert into inbox after a comment has been unspammed""" inbox_owner = mention._thing1 thing = mention._thing2 with query_cache.CachedQueryMutator() as m: m.insert(queries.get_inbox_comment_mentions(inbox_owner), [mention]) unread = getattr(mention, "unread_preremoval", True) queries.set_unread(thing, inbox_owner, unread=unread, mutator=m)
def readd_mention_notification(mention): """Reinsert into inbox after a comment has been unspammed""" inbox_owner = mention._thing1 thing = mention._thing2 with query_cache.CachedQueryMutator() as m: m.insert(queries.get_inbox_comment_mentions(inbox_owner), [mention]) unread = getattr(mention, 'unread_preremoval', True) queries.set_unread(thing, inbox_owner, unread=unread, mutator=m)
def notify_mention(user, thing): try: inbox_rel = Inbox._add(user, thing, "mention") except CreationError: # this mention was already inserted, ignore it g.log.error("duplicate mention for (%s, %s)", user, thing) return with query_cache.CachedQueryMutator() as m: m.insert(queries.get_inbox_comment_mentions(user), [inbox_rel]) queries.set_unread(thing, user, unread=True, mutator=m)
def query(self): if self.where == 'messages': q = queries.get_inbox_messages(c.user) elif self.where == 'comments': q = queries.get_inbox_comments(c.user) elif self.where == 'selfreply': q = queries.get_inbox_selfreply(c.user) elif self.where == 'mentions': q = queries.get_inbox_comment_mentions(c.user) elif self.where == 'inbox': q = queries.get_inbox(c.user) elif self.where == 'unread': q = queries.get_unread_inbox(c.user) elif self.where == 'sent': q = queries.get_sent(c.user) elif self.where == 'multi' and self.subwhere == 'unread': q = queries.get_unread_subreddit_messages_multi(c.site.kept_sr_ids) elif self.where == 'moderator' and self.subwhere == 'unread': if c.default_sr: srids = Subreddit.reverse_moderator_ids(c.user) srs = [ sr for sr in Subreddit._byID( srids, data=False, return_dict=False) if sr.is_moderator_with_perms(c.user, 'mail') ] q = queries.get_unread_subreddit_messages_multi(srs) else: q = queries.get_unread_subreddit_messages(c.site) elif self.where in ('moderator', 'multi'): if c.have_mod_messages and self.mark != 'false': c.have_mod_messages = False c.user.modmsgtime = False c.user._commit() # the query is handled by the builder on the moderator page return else: return self.abort404() if self.where != 'sent': #reset the inbox if c.have_messages and self.mark != 'false': c.have_messages = False c.user.msgtime = False c.user._commit() return q
def query(self): if self.where == "messages": q = queries.get_inbox_messages(c.user) elif self.where == "comments": q = queries.get_inbox_comments(c.user) elif self.where == "selfreply": q = queries.get_inbox_selfreply(c.user) elif self.where == "mentions": q = queries.get_inbox_comment_mentions(c.user) elif self.where == "inbox": q = queries.get_inbox(c.user) elif self.where == "unread": q = queries.get_unread_inbox(c.user) elif self.where == "sent": q = queries.get_sent(c.user) elif self.where == "multi" and self.subwhere == "unread": q = queries.get_unread_subreddit_messages_multi(c.site.kept_sr_ids) elif self.where == "moderator" and self.subwhere == "unread": if c.default_sr: srids = Subreddit.reverse_moderator_ids(c.user) srs = [ sr for sr in Subreddit._byID(srids, data=False, return_dict=False) if sr.is_moderator_with_perms(c.user, "mail") ] q = queries.get_unread_subreddit_messages_multi(srs) else: q = queries.get_unread_subreddit_messages(c.site) elif self.where in ("moderator", "multi"): if c.have_mod_messages and self.mark != "false": c.have_mod_messages = False c.user.modmsgtime = False c.user._commit() # the query is handled by the builder on the moderator page return else: return self.abort404() if self.where != "sent": # reset the inbox if c.have_messages and self.mark != "false": c.have_messages = False c.user.msgtime = False c.user._commit() return q
def query(self): if self.where == 'messages': q = queries.get_inbox_messages(c.user) elif self.where == 'comments': q = queries.get_inbox_comments(c.user) elif self.where == 'selfreply': q = queries.get_inbox_selfreply(c.user) elif self.where == 'mentions': q = queries.get_inbox_comment_mentions(c.user) elif self.where == 'inbox': q = queries.get_inbox(c.user) elif self.where == 'unread': q = queries.get_unread_inbox(c.user) elif self.where == 'sent': q = queries.get_sent(c.user) elif self.where == 'multi' and self.subwhere == 'unread': q = queries.get_unread_subreddit_messages_multi(c.site.kept_sr_ids) elif self.where == 'moderator' and self.subwhere == 'unread': if c.default_sr: srids = Subreddit.reverse_moderator_ids(c.user) srs = [sr for sr in Subreddit._byID(srids, data=False, return_dict=False) if sr.is_moderator_with_perms(c.user, 'mail')] q = queries.get_unread_subreddit_messages_multi(srs) else: q = queries.get_unread_subreddit_messages(c.site) elif self.where in ('moderator', 'multi'): if c.have_mod_messages and self.mark != 'false': c.have_mod_messages = False c.user.modmsgtime = False c.user._commit() # the query is handled by the builder on the moderator page return else: return self.abort404() if self.where != 'sent': #reset the inbox if c.have_messages and self.mark != 'false': c.have_messages = False c.user.msgtime = False c.user._commit() return q
def remove_mention_notification(mention): inbox_owner = mention._thing1 thing = mention._thing2 with query_cache.CachedQueryMutator() as m: m.delete(queries.get_inbox_comment_mentions(inbox_owner), [mention]) queries.set_unread(thing, inbox_owner, unread=False, mutator=m)
def notify_mention(user, thing): inbox_rel = Inbox._add(user, thing, "mention") with query_cache.CachedQueryMutator() as m: m.insert(queries.get_inbox_comment_mentions(user), [inbox_rel]) queries.set_unread(thing, user, unread=True, mutator=m)