Skip to content
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

Telegram notifications for users #1029

Merged
merged 2 commits into from
Jul 3, 2021
Merged

Telegram notifications for users #1029

merged 2 commits into from
Jul 3, 2021

Conversation

paskal
Copy link
Collaborator

@paskal paskal commented May 26, 2021

Would add backend support #830.

Verification message:
image
Reply notification:
image

For frontend (@akellbl4): when config option telegram_bot_username is not empty, telegram notifications are enabled. We need to ask the user to write a bot with that username (https://tg.me/$username) and then use his ID for subscription: send /getid to https://tg.me/myidbot in Telegram messenger.

@paskal paskal added the backend label May 26, 2021
@paskal paskal requested review from umputun and akellbl4 May 26, 2021 00:49
@paskal paskal marked this pull request as draft May 26, 2021 00:49
@codecov
Copy link

codecov bot commented May 26, 2021

Codecov Report

Merging #1029 (761b5da) into master (dfcf728) will decrease coverage by 0.44%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1029      +/-   ##
==========================================
- Coverage   44.18%   43.73%   -0.45%     
==========================================
  Files         126      126              
  Lines        2904     2991      +87     
  Branches      653      680      +27     
==========================================
+ Hits         1283     1308      +25     
- Misses       1609     1670      +61     
- Partials       12       13       +1     
Impacted Files Coverage Δ
frontend/app/common/static-store.ts 100.00% <ø> (ø)
frontend/app/common/types.ts 100.00% <ø> (ø)
frontend/app/common/fetcher.ts 96.15% <0.00%> (-0.28%) ⬇️
frontend/app/components/root/index.ts 0.00% <0.00%> (ø)
frontend/app/components/user-info/user-info.tsx 0.00% <0.00%> (ø)
frontend/app/components/root/root.tsx 2.07% <0.00%> (+2.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1847184...761b5da. Read the comment docs.

@github-actions
Copy link

github-actions bot commented May 26, 2021

size-limit report 📦

Path Size
public/embed.mjs 2.23 KB (0%)
public/remark.mjs 65.31 KB (+0.03% 🔺)
public/remark.css 9.4 KB (0%)
public/last-comments.mjs 30.08 KB (+0.06% 🔺)
public/last-comments.css 5.07 KB (0%)
public/deleteme.mjs 9.79 KB (+0.19% 🔺)
public/counter.mjs 601 B (0%)

@coveralls
Copy link

coveralls commented May 26, 2021

Pull Request Test Coverage Report for Build 936678403

  • 187 of 233 (80.26%) changed or added relevant lines in 4 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.04%) to 83.566%

Changes Missing Coverage Covered Lines Changed/Added Lines %
backend/app/notify/telegram.go 45 49 91.84%
backend/app/cmd/server.go 34 54 62.96%
backend/app/rest/api/rest_private.go 70 92 76.09%
Files with Coverage Reduction New Missed Lines %
backend/app/cmd/server.go 3 78.17%
Totals Coverage Status
Change from base Build 934148517: -0.04%
Covered Lines: 5639
Relevant Lines: 6748

💛 - Coveralls

@paskal paskal added this to the v1.9 milestone May 27, 2021
@paskal paskal force-pushed the paskal/telegram_notify branch 6 times, most recently from 86c9c2c to 236e907 Compare June 7, 2021 23:13
@paskal paskal force-pushed the paskal/telegram_notify branch 6 times, most recently from 18b4857 to a9cf849 Compare June 13, 2021 23:02
@paskal paskal force-pushed the paskal/telegram_notify branch 2 times, most recently from 45c386f to da048bc Compare June 13, 2021 23:22
@paskal paskal force-pushed the paskal/telegram_notify branch from da048bc to feb9355 Compare June 14, 2021 00:11
@paskal paskal marked this pull request as ready for review June 14, 2021 00:11
@paskal paskal force-pushed the paskal/telegram_notify branch from feb9355 to 5eed05f Compare June 14, 2021 00:28
Copy link
Owner

@umputun umputun left a comment

Choose a reason for hiding this comment

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

just a quick view, plannig to go deeper later on

backend/app/cmd/server.go Outdated Show resolved Hide resolved
backend/app/cmd/server.go Show resolved Hide resolved
backend/app/rest/api/rest_private.go Show resolved Hide resolved
errors.New("missing parameter"), "address parameter is required", rest.ErrInternal)
return
}
existingAddress, err := s.dataService.GetUserTelegram(siteID, user.ID)
Copy link
Owner

Choose a reason for hiding this comment

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

btw, if i understant "tricky to use SendErrorJSON" part this is about incorrect frame report? this can be solved with an extra param "skipFrames" of some sort. Not saying we have to refactor this, just a note

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nope, just we'll need to have a nested function which also could potentially send an answer to the user (SendErrorJSON) so it would need request and response passed to it, and some boolean flag to check if we can carry on with our logic or that function took care about it for us and we need to just return immediately. It will hurt readability more than code duplication in my opinion.

backend/app/rest/api/rest_private.go Show resolved Hide resolved
backend/app/rest/api/rest_private_test.go Outdated Show resolved Hide resolved
@@ -156,7 +156,7 @@ _this is the recommended way to run remark42_
| auth.email.subj | AUTH_EMAIL_SUBJ | `remark42 confirmation` | email subject |
| auth.email.content-type | AUTH_EMAIL_CONTENT_TYPE | `text/html` | email content type |
| auth.email.template | AUTH_EMAIL_TEMPLATE | none (predefined) | custom email message template file |
| notify.users | NOTIFY_USERS | none | type of user notifications (email) |
| notify.users | NOTIFY_USERS | none | type of user notifications (telegram, email) |
Copy link
Owner

Choose a reason for hiding this comment

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

probably we need some detailed info about user's tg notif somewhere

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please elaborate on this one, documentation note on what is the trickiness of telegram notify?

@paskal paskal force-pushed the paskal/telegram_notify branch from a776e9f to 0655e2a Compare June 14, 2021 17:51
@paskal
Copy link
Collaborator Author

paskal commented Jun 14, 2021

I've fixed most of the review comments in the second commit for the reviewer convenience, looking forward to the next review round.

@paskal paskal force-pushed the paskal/telegram_notify branch from 0655e2a to 761b5da Compare June 17, 2021 18:29
@paskal paskal requested a review from umputun June 20, 2021 13:49
Copy link
Owner

@umputun umputun left a comment

Choose a reason for hiding this comment

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

LGTM

@umputun umputun merged commit 83ae758 into master Jul 3, 2021
@umputun umputun deleted the paskal/telegram_notify branch July 3, 2021 19:57
@paskal paskal mentioned this pull request Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants