def po_new(cid, user_id, name, state, rid=0, id=None, zsite_id=0): if is_spammer(user_id): return if state is None: if zsite_id and zsite_id != user_id: state = STATE_PO_ZSITE_SHOW_THEN_REVIEW else: state = STATE_ACTIVE m = Po( id=id or gid(), name_=cnencut(name, 142), user_id=user_id, cid=cid, rid=rid, state=state, zsite_id=zsite_id, create_time=int(time()), ) m.save() if cid != CID_NOTE: #NOTE 可能是导入 , 通过po pos的状态判断是不是要发邮件 from po_pos import po_pos_set po_pos_set(user_id, m) mc_flush(user_id, cid) if state >= STATE_ACTIVE: m.tag_new() mc_flush_zsite_cid(zsite_id, cid) return m
def reply_new(self, user, txt, state=STATE_ACTIVE, create_time=None): from zsite import user_can_reply user_id = user.id cid = self.cid if cid not in (CID_SITE, CID_COM): if not user_can_reply(user): return if is_spammer(user_id): return txt = txt.rstrip() rid = self.id if not txt or is_same_post(user_id, cid, rid, txt, state): return id = gid() if not create_time: create_time = int(time()) txt_new(id, txt) cursor = self.reply_cursor cursor.execute( 'insert into reply (id,cid,create_time,state,rid,user_id) values (%s,%s,%s,%%s,%%s,%%s)' % ( id, cid, create_time, ), (state, rid, user_id) ) cursor.connection.commit() mc_flush_reply_id_list(cid, rid) # key = '%s_%s' % (rid, user_id) # if mc_reply_in_1h.get(key) is None: # mq_buzz_po_reply_new(user_id, rid) # mc_reply_in_1h.set(key, True, 3600) return id
def reply_new(self, user, txt, state=STATE_ACTIVE, create_time=None): from zsite import user_can_reply user_id = user.id cid = self.cid if cid not in (CID_SITE, CID_COM): if not user_can_reply(user): return if is_spammer(user_id): return txt = txt.rstrip() rid = self.id if not txt or is_same_post(user_id, cid, rid, txt, state): return id = gid() if not create_time: create_time = int(time()) txt_new(id, txt) cursor = self.reply_cursor cursor.execute( 'insert into reply (id,cid,create_time,state,rid,user_id) values (%s,%s,%s,%%s,%%s,%%s)' % ( id, cid, create_time, ), (state, rid, user_id)) cursor.connection.commit() mc_flush_reply_id_list(cid, rid) # key = '%s_%s' % (rid, user_id) # if mc_reply_in_1h.get(key) is None: # mq_buzz_po_reply_new(user_id, rid) # mc_reply_in_1h.set(key, True, 3600) return id