Skip to content

refactoring to inertia#138

Open
nic11371 wants to merge 2 commits intohexlet-volunteers:mainfrom
nic11371:inertia-telegram-profession
Open

refactoring to inertia#138
nic11371 wants to merge 2 commits intohexlet-volunteers:mainfrom
nic11371:inertia-telegram-profession

Conversation

@nic11371
Copy link
Copy Markdown
Contributor

  1. Переделал телеграм каналы на inertia.
  2. Добавил в env.example

TELEGRAM_API_ID=1234567890
TELEGRAM_SESSION=session.session
TELEGRAM_API_HASH=hfk693kcln9673nclbb94j

  1. Забыл, что ранее рефакторил телеграм в непринятом PR, но здесь тоже произвел рефакторинг.
  2. добавил session.session в .gitignore.

Copy link
Copy Markdown

@maxjamchuk maxjamchuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Главное разобраться с тем что в итоге возвращаем в AddChannelView.get() и почистить .env.example


TELEGRAM_API_ID=1234567890
TELEGRAM_SESSION=session.session
TELEGRAM_API_HASH=hfk693kcln9673nclbb94j
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

даже если это значение не настоящее, а примерное, это провоцирует людей хранить/коммитить реальные секреты в .env.example, а потом случайно утекать ими в репозиторий/логи/скриншоты.

TELEGRAM_API_HASH — это по сути секрет (как API key).

Как лучше:

Оставить в .env.example только плейсхолдеры, явно пометить как секреты:

TELEGRAM_API_HASH=__CHANGE_ME__

или что-то типа того.
если же это реальное значение, то его надо перевыпустить и больше не светить в GitHub.

DATABASE_ENGINE="postgresql"

TELEGRAM_API_ID=1234567890
TELEGRAM_SESSION=session.session
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Название TELEGRAM_SESSION=session.session выглядит как имя файла” но переменная названа как session — значение.

Лучше: TELEGRAM_SESSION_FILE=session.session или TELEGRAM_SESSION_PATH=... — чтобы по названию было понятно, что это путь/файл, а не строка-сессия.

postgres
key_word.py

session.session
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

добавили session.sessionСУПЕР, идея понятна: не коммитить файл сессии Telegram-клиента.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

в конце файла нет перевода строки.

в принципе ничего ужасного, прод не сломается, но будет постоянно шуметь в линтерах.

Фикс: добавить пустую строчку в конец файла.

async def get(self, request, *args, **kwargs):
form = ChannelForm()
return JsonResponse({"status": "ok", "form_fields": list(form.fields.keys())})
return JsonResponse(request, "Channels/Add", props={
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

насколько я помню JsonResponse сам по себе не принимает (request, component, props)

здесь подробнее

фикс скорее всего будет примерно такой:

return render(request, "Channels/Add", props={...})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants