def add_new_chat(is_group_chat, name, unread, key, avatar, user_id): add_value( Chat(is_group_chat=is_group_chat, name=name, unread=unread, key=key, avatar=avatar, user_id=user_id)) commit_value() email = get_email(user_id) name_chat_got = get_name(user_id) send_mail_on_chat.delay(name_chat_got, name, email)
def add_new_message(content, sent, chat_id): message = Message(content=content, sent=sent, chat_id=chat_id) add_value(message) commit_value() return (message.id)
def add_new_user(name, nick, avatar, email): user = User(name=name, nick=nick, avatar=avatar, email=email) add_value(user) commit_value() return (user.id)
def change_message_content(message_id, content): message_tmp = Message.query.filter_by(id=message_id).first() message_tmp.content = str(content) commit_value()
def remove_all_messages(chat_id): for message in Message.query.filter_by(chat_id=chat_id): delete_value(message) commit_value()
def remove_user(user_id): delete_value(User.query.filter_by(id=user_id).first()) commit_value() return (True)
def remove_message(message_id): delete_value(Message.query.filter_by(id=message_id).first()) commit_value() return (True)
def add_new_attach(type, size, chat_id): add_value(Attachment(type=type, size=size, chat_id=chat_id)) commit_value()