Exemplo n.º 1
0
async def update_user_information(user: schemas.UserInfo,
                                  db: Session = Depends(utils.get_db)):
    db_user = crud.get_user_by_id(db, id=user.id)
    if not db_user:
        raise HTTPException(status_code=400, detail="User not found")

    return crud.update_user_info(db=db, user=user)
Exemplo n.º 2
0
async def get_me(
        current_user: User = Depends(get_current_active_user),
        db: Session = Depends(get_db),
):
    db_user = crud.get_user_by_id(db, user_id=current_user.id)
    if db_user is None:
        raise HTTPException(status_code=404, detail="User not found")
    return db_user
Exemplo n.º 3
0
async def handle_webhook(update: Update, client_session: ClientSession = Depends(http_client_session), ):
    update_message = update.message if update.message is not None else update.edited_message

    user = crud.get_user_by_id(update_message.from_.id)
    if not user:
        await send_message(client_session, chat_id=update_message.chat.id, text=language_info())
        user = crud.create_user(update_message)

    args = FuncParameters(
        session=client_session,
        message=update_message,
        localization=user.lang,
    )

    msg_welcome_back = await welcome_back(args)
    if msg_welcome_back:
        await send_message(client_session, chat_id=update_message.chat.id, text=msg_welcome_back)

    crud.save_message(update_message)
    answer = await choice_of_answer(args)
    msg = await send_message(client_session, chat_id=update_message.chat.id, text=answer)
    logger.debug(msg.json(indent=2, sort_keys=True))
Exemplo n.º 4
0
def get_trash_for_user(user_id: int, db: Session = Depends(utils.get_db)):
    db_user = crud.get_user_by_id(db, id=user_id)
    if not db_user:
        raise HTTPException(status_code=404, detail="User not found")
    return crud.get_trash_for_user(db, user_id)
Exemplo n.º 5
0
async def get_user_details(id: int, db: Session = Depends(utils.get_db)):
    db_user = crud.get_user_by_id(db, id=id)
    if not db_user:
        raise HTTPException(status_code=404, detail="User not found")
    return db_user