Ejemplo n.º 1
0
	def on_new_note(self, note, user):
		room = ChatRoom.get(note['id'])
		if not room:
			return '채팅방을 찾을수 없습니다.',
		if user not in room.users:
			return '채팅방에 참여하지 않았습니다.',

		message = Message()
		message.user = user
		message.message = note['message']
		message.color = note['color']
		for u in room.users:
			log = MessageLog()
			log.user = u
			if u is user:
				log.status |= MessageLog.READ
			message.logs.append(log)
		room.messages.append(message)
		db.session.commit()
		print message.logs.all()
		json = message.to_json()
		self.emit_to_room(str(room.id), 'new note', json)
		online_users = self.users_in_room(str(room.id))
		q = room.users.filter(User.status==User.NORMAL)
		if online_users:
			q = q.filter(not_(User.id.in_(online_users)))
		for offline_user in q:
			pass
		return None, json
Ejemplo n.º 2
0
	def on_notified_notes(self, message_ids, user):
		MessageLog.update_status(message_ids, MessageLog.NOTIFIED, user.id)
		return
Ejemplo n.º 3
0
	def on_read_notes(self, message_ids, user):
		MessageLog.update_status(message_ids, MessageLog.READ, user.id)
		return