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

Feature/detect broken contacts #615

Merged
merged 10 commits into from
Mar 6, 2021
Merged

Conversation

androndo
Copy link
Contributor

PR Summary

Additional information

Relates #614

@coveralls
Copy link

coveralls commented Feb 26, 2021

Coverage Status

Coverage decreased (-0.3%) to 74.411% when pulling 3396a9b on feature/detect_broken_contacts into 8d8dd0d on master.

errors.go Outdated Show resolved Hide resolved
errors.go Show resolved Hide resolved
@androndo androndo marked this pull request as ready for review March 2, 2021 06:05
@androndo androndo requested a review from a team as a code owner March 2, 2021 06:05
@androndo androndo marked this pull request as draft March 2, 2021 13:22
@androndo androndo force-pushed the feature/detect_broken_contacts branch from 12a55b9 to 7deee8b Compare March 3, 2021 08:50
@androndo androndo marked this pull request as ready for review March 3, 2021 08:50
notifier/notifier_test.go Show resolved Hide resolved
@@ -37,9 +37,15 @@ func (sender *Sender) SendEvents(events moira.NotificationEvents, contact moira.
sender.logger.Debugf("Calling telegram api with chat_id %s and message body %s", contact.Value, message)
chat, err := sender.getChat(contact.Value)
if err != nil {
if ok, errorBrokenContact := checkBrokenContactError(sender.logger, err); ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

It's pretty strange to see that we raise an error if ok is true. Probably we need to invert bool value in return of function and invert condition here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Additionally: do we really need this bool value? probably we can just return SenderBrokenContactError if contact is broken and nil otherwise. And this condition will become just

if errorBrokenContact := checkBrokenContactError(sender.logger, err); errorBrokenContact != nil {

Copy link
Contributor

Choose a reason for hiding this comment

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

Or even better solution. Let's the function checkBrokenContactError will return SenderBrokenContactError if contact is broken or original error otherwise. And here we can remove this second if and use just

if err != nil {
	return checkBrokenContactError(sender.logger, err)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looks good)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@androndo androndo self-assigned this Mar 4, 2021
@androndo androndo force-pushed the feature/detect_broken_contacts branch from 2176ebd to 3396a9b Compare March 5, 2021 08:20
@litleleprikon litleleprikon merged commit 2f06468 into master Mar 6, 2021
@litleleprikon litleleprikon deleted the feature/detect_broken_contacts branch March 6, 2021 14:37
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