-
-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/invitation court and program #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
562b2ba
feat: сказать в приглашении, на какой корт зовут
denis1011101 1e9fc11
fix: не резать план тренировки посреди слова
denis1011101 4d489bb
fix: убрать превью ссылки из сообщений бота
denis1011101 fe753a0
feat: сделать имя корта ссылкой на страницу корта
denis1011101 4147a20
feat: не считать свободные места на тренировке
denis1011101 f0d8c5d
feat: сделать корт ссылкой и в напоминании
denis1011101 db1e7ed
docs: объяснить, почему первый блок плана берётся без проверки предела
denis1011101 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| require "cgi" | ||
| require "uri" | ||
|
|
||
| module Telegram | ||
| module Helpers | ||
| # Имя корта — ссылка, и в приглашении, и в напоминании. Ради неё сообщение | ||
| # уходит в телеграм с parse_mode: HTML, а значит всё, что ввели люди, | ||
| # придётся экранировать. В письме тот же текст собирается без разметки: | ||
| # @body вставляется и в текстовый шаблон, где теги видно как есть. | ||
| module Markup | ||
| module_function | ||
|
|
||
| def markup?(channel) | ||
| channel.to_s == "telegram" | ||
| end | ||
|
|
||
| # Экранирует, только когда текст пойдёт размеченным. | ||
| def escaper(channel) | ||
| markup = markup?(channel) | ||
| ->(value) { markup ? CGI.escapeHTML(value.to_s) : value.to_s } | ||
| end | ||
|
|
||
| # Готовое имя корта: в телеграме ссылкой, в письме просто именем. | ||
| def court_name(court, base_url:, channel:) | ||
| name = court&.name.to_s.strip | ||
| return nil if name.blank? | ||
|
|
||
| esc = escaper(channel) | ||
| url = markup?(channel) ? court_url(court, base_url) : nil | ||
| return esc.call(name) if url.blank? | ||
|
|
||
| %(<a href="#{esc.call(url)}">#{esc.call(name)}</a>) | ||
| end | ||
|
|
||
| # Хост берём у ссылки на игру: она пришла из запроса и верна и на проде, | ||
| # и локально. | ||
| def court_url(court, base_url) | ||
| return nil if court&.id.blank? || base_url.blank? | ||
|
|
||
| uri = URI.parse(base_url) | ||
| uri.path = "/courts/#{court.id}" | ||
| uri.query = nil | ||
| uri.fragment = nil | ||
| uri.to_s | ||
| rescue URI::InvalidURIError | ||
| nil | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the first block title alone exceeds
limit,kept.any?is false, so the block is appended without any bound. A sufficiently long user-provided title can therefore make invitation and reminder messages exceed Telegram's 4096-character limit and be rejected, despite this method being intended to prevent that; truncate or otherwise cap an oversized individual block.Useful? React with 👍 / 👎.