def _new(cls, author, link, parent, body, ip): from r2.lib.db.queries import changed c = Comment(_ups=1, body=body, link_id=link._id, sr_id=link.sr_id, author_id=author._id, ip=ip) c._spam = author._spam # these props aren't relations if parent: c.parent_id = parent._id link._incr("num_comments", 1) to = None name = "inbox" if parent: to = Account._byID(parent.author_id, True) elif link.is_self and not link.noselfreply: to = Account._byID(link.author_id, True) name = "selfreply" c._commit() changed(link, True) # only the number of comments has changed inbox_rel = None # only global admins can be message spammed. if to and (not c._spam or to.name in g.admins): inbox_rel = Inbox._add(to, c, name) return (c, inbox_rel)
def _new(cls, author, link, parent, body, ip): c = Comment(body = body, link_id = link._id, sr_id = link.sr_id, author_id = author._id, ip = ip) c._spam = author._spam #these props aren't relations if parent: c.parent_id = parent._id c._commit() link._incr('num_comments', 1) to = None if parent: to = Account._byID(parent.author_id) elif link.is_self: to = Account._byID(link.author_id) inbox_rel = None # only global admins can be message spammed. if to and (not c._spam or to.name in g.admins): inbox_rel = Inbox._add(to, c, 'inbox') return (c, inbox_rel)
def _new(cls, author, link, parent, body, ip, spam = False): c = Comment(body = body, link_id = link._id, sr_id = link.sr_id, author_id = author._id, ip = ip) c._spam = spam #these props aren't relations if parent: c.parent_id = parent._id c._commit() link._incr('num_comments', 1) inbox_rel = None if parent: to = Account._byID(parent.author_id) # only global admins can be message spammed. if not c._spam or to.name in g.admins: inbox_rel = Inbox._add(to, c, 'inbox') #clear that chache clear_memo('builder.link_comments2', link._id) return (c, inbox_rel)
def _new(cls, author, link, parent, body, ip, spam = False): c = Comment(body = body, link_id = link._id, sr_id = link.sr_id, author_id = author._id, ip = ip) c._spam = spam #these props aren't relations if parent: c.parent_id = parent._id c._commit() link._incr('num_comments', 1) if parent: to = Account._byID(parent.author_id) i = Inbox._add(to, c, 'inbox') #clear that chache clear_memo('builder.link_comments2', link._id) from admintools import admintools utils.worker.do(lambda: admintools.add_thing(c)) return c
def _new(cls, author, link, parent, body, ip): c = Comment(_ups=1, body=body, link_id=link._id, sr_id=link.sr_id, author_id=author._id, ip=ip) c._spam = author._spam #these props aren't relations if parent: c.parent_id = parent._id link._incr('num_comments', 1) to = None name = 'inbox' if parent: to = Account._byID(parent.author_id) elif link.is_self: to = Account._byID(link.author_id) name = 'selfreply' c._commit() inbox_rel = None # only global admins can be message spammed. if to and (not c._spam or to.name in g.admins): inbox_rel = Inbox._add(to, c, name) return (c, inbox_rel)
def _new(cls, author, link, parent, body, ip,criticism=False): from r2.lib.db.queries import changed #We're turing it off for now... criticism = False c = Comment(_ups = 1, body = body, link_id = link._id, sr_id = link.sr_id, author_id = author._id, ip = ip) c._spam = author._spam c.criticism=criticism #these props aren't relations if parent: c.parent_id = parent._id #should increment based on crit flag #Each should contain the root author and its id, problem is the id isn't created yet if we're the root so have to be clever if criticism: link._incr("num_criticisms",1) if parent: c.rootauthor=parent.rootauthor if parent.rootid: c.rootid=parent.rootid else: c.rootid=parent._id else: c.rootauthor=author._id c.rootid=False else: link._incr('num_comments', 1) to = None name = 'inbox' if parent: to = Account._byID(parent.author_id, True) elif link.is_self and not link.noselfreply: to = Account._byID(link.author_id, True) name = 'selfreply' c._commit() changed(link, True) # link's number of comments changed inbox_rel = None # only global admins can be message spammed. # Don't send the message if the recipient has blocked # the author if to and ((not c._spam and author._id not in to.enemies) or to.name in g.admins): # When replying to your own comment, record the inbox # relation, but don't give yourself an orangered orangered = (to.name != author.name) inbox_rel = Inbox._add(to, c, name, orangered=orangered) return (c, inbox_rel)
def _new(cls, author, link, parent, body, ip): from r2.lib.db.queries import changed c = Comment(_ups=1, body=body, link_id=link._id, sr_id=link.sr_id, author_id=author._id, ip=ip) c._spam = author._spam if author._spam: g.stats.simple_event('spam.autoremove.comment') #these props aren't relations if parent: c.parent_id = parent._id link._incr('num_comments', 1) to = None name = 'inbox' if parent: to = Account._byID(parent.author_id, True) elif link.is_self and not link.noselfreply: to = Account._byID(link.author_id, True) name = 'selfreply' c._commit() changed(link, True) # link's number of comments changed inbox_rel = None # only global admins can be message spammed. # Don't send the message if the recipient has blocked # the author if to and ((not c._spam and author._id not in to.enemies) or to.name in g.admins): # When replying to your own comment, record the inbox # relation, but don't give yourself an orangered orangered = (to.name != author.name) inbox_rel = Inbox._add(to, c, name, orangered=orangered) return (c, inbox_rel)
def _new(cls, author, link, parent, body, ip): from r2.lib.db.queries import changed c = Comment(_ups=1, body=body, link_id=link._id, sr_id=link.sr_id, author_id=author._id, ip=ip) c._spam = author._spam #these props aren't relations if parent: c.parent_id = parent._id link._incr('num_comments', 1) to = None name = 'inbox' if parent: to = Account._byID(parent.author_id, True) elif link.is_self and not link.noselfreply: to = Account._byID(link.author_id, True) name = 'selfreply' c._commit() changed(link, True) # link's number of comments changed inbox_rel = None # only global admins can be message spammed. # Don't send the message if the recipient has blocked # the author if to and ((not c._spam and author._id not in to.enemies) or to.name in g.admins): # When replying to your own comment, record the inbox # relation, but don't give yourself an orangered orangered = (to.name != author.name) inbox_rel = Inbox._add(to, c, name, orangered=orangered) return (c, inbox_rel)
def _new(cls, author, link, parent, body, ip): from r2.lib.db.queries import changed c = Comment(_ups = 1, body = body, link_id = link._id, sr_id = link.sr_id, author_id = author._id, ip = ip) c._spam = author._spam #these props aren't relations if parent: c.parent_id = parent._id link._incr('num_comments', 1) to = None name = 'inbox' if parent: to = Account._byID(parent.author_id, True) elif link.is_self and not link.noselfreply: to = Account._byID(link.author_id, True) name = 'selfreply' c._commit() changed(link, True) # only the number of comments has changed inbox_rel = None # only global admins can be message spammed. if to and (not c._spam or to.name in g.admins): inbox_rel = Inbox._add(to, c, name) return (c, inbox_rel)