예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
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)
예제 #4
0
def change_message_content(message_id, content):
    message_tmp = Message.query.filter_by(id=message_id).first()
    message_tmp.content = str(content)
    commit_value()
예제 #5
0
def remove_all_messages(chat_id):
    for message in Message.query.filter_by(chat_id=chat_id):
        delete_value(message)
        commit_value()
예제 #6
0
def remove_user(user_id):
    delete_value(User.query.filter_by(id=user_id).first())
    commit_value()
    return (True)
예제 #7
0
def remove_message(message_id):
    delete_value(Message.query.filter_by(id=message_id).first())
    commit_value()
    return (True)
예제 #8
0
def add_new_attach(type, size, chat_id):
    add_value(Attachment(type=type, size=size, chat_id=chat_id))
    commit_value()