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

NOISSUE - Add SMPP notifier #1464

Merged
merged 6 commits into from
Oct 6, 2021
Merged

NOISSUE - Add SMPP notifier #1464

merged 6 commits into from
Oct 6, 2021

Conversation

blokovi
Copy link
Contributor

@blokovi blokovi commented Sep 20, 2021

Signed-off-by: Ivan Milosevic iva@blokovi.com

What does this do?

Adds an implementation of SMPP Notifier (capability of sending SMS notifications).

Signed-off-by: Ivan Milosevic <iva@blokovi.com>
remove env file

Signed-off-by: Ivan Milosevic <iva@blokovi.com>
@blokovi blokovi requested a review from a team as a code owner September 20, 2021 09:55
@codecov-commenter
Copy link

codecov-commenter commented Sep 20, 2021

Codecov Report

Merging #1464 (092ea0a) into master (f4312ae) will decrease coverage by 0.01%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1464      +/-   ##
==========================================
- Coverage   70.92%   70.90%   -0.02%     
==========================================
  Files         123      123              
  Lines        9564     9565       +1     
==========================================
- Hits         6783     6782       -1     
- Misses       2254     2256       +2     
  Partials      527      527              
Impacted Files Coverage Δ
users/api/logging.go 0.00% <0.00%> (ø)
consumers/notifiers/service.go 88.00% <100.00%> (+0.24%) ⬆️
things/service.go 72.02% <0.00%> (-1.20%) ⬇️

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 f4312ae...092ea0a. Read the comment docs.

@@ -28,7 +28,7 @@ var (
ErrSave = errors.New("failed to subscription")

// ErrNotFound indicates a non-existent entity request.
ErrNotFound = errors.New("non-existent entity")
ErrNotFound = errors.New("non-existent entityty")
Copy link
Contributor

Choose a reason for hiding this comment

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

Fix entityty

@@ -29,7 +29,8 @@ func newService() notifiers.Service {
auth := mocks.NewAuth(map[string]string{exampleUser1: exampleUser1, exampleUser2: exampleUser2, invalidUser: invalidUser})
notifier := mocks.NewNotifier()
idp := uuid.NewMock()
return notifiers.New(auth, repo, idp, notifier)
from := ""
Copy link
Contributor

Choose a reason for hiding this comment

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

Mayeb better to don't use an empty string here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree, simply use a string literal.

@@ -68,7 +68,8 @@ func newService(tokens map[string]string) notifiers.Service {
repo := mocks.NewRepo(make(map[string]notifiers.Subscription))
idp := uuid.NewMock()
notif := mocks.NewNotifier()
return notifiers.New(auth, repo, idp, notif)
from := ""
Copy link
Contributor

@manuio manuio Sep 20, 2021

Choose a reason for hiding this comment

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

Mayeb better to don't use an empty string here?

@@ -29,7 +29,8 @@ func newService() notifiers.Service {
auth := mocks.NewAuth(map[string]string{exampleUser1: exampleUser1, exampleUser2: exampleUser2, invalidUser: invalidUser})
notifier := mocks.NewNotifier()
idp := uuid.NewMock()
return notifiers.New(auth, repo, idp, notifier)
from := ""
Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree, simply use a string literal.

Comment on lines 13 to 26
| MF_SMTP_NOTIFY_LOG_LEVEL | Log level for SMT Notifier (debug, info, warn, error) | error |
| MF_SMTP_NOTIFY_DB_HOST | Database host address | localhost |
| MF_SMTP_NOTIFY_DB_PORT | Database host port | 5432 |
| MF_SMTP_NOTIFY_DB_USER | Database user | mainflux |
| MF_SMTP_NOTIFY_DB_PASS | Database password | mainflux |
| MF_SMTP_NOTIFY_DB | Name of the database used by the service | subscriptions |
| MF_SMTP_NOTIFY_WRITER_CONFIG_PATH | Database connection SSL mode (disable, require, verify-ca, verify-full) | disable |
| MF_SMTP_NOTIFY_DB_SSL_MODE | Path to the PEM encoded certificate file | |
| MF_SMTP_NOTIFY_DB_SSL_CERT | Path to the PEM encoded key file | |
| MF_SMTP_NOTIFY_DB_SSL_KEY | Path to the PEM encoded root certificate file | |
| MF_SMTP_NOTIFY_DB_SSL_ROOT_CERT | Users service HTTP port | 8180 |
| MF_SMTP_NOTIFY_HTTP_PORT | Path to server certificate in pem format | |
| MF_SMTP_NOTIFY_SERVER_CERT | Path to server cert in pem format | |
| MF_SMTP_NOTIFY_SERVER_KEY | Path to server key in pem format | |
Copy link
Collaborator

Choose a reason for hiding this comment

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

SMTP docs.

Comment on lines 7 to 10
The Subscription service using SMTP Notifier is configured using the environment variables presented in the
following table. Note that any unset variables will be replaced with their
default values.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please fix README.

Comment on lines 52 to 53
fmt.Println(to)
fmt.Println(len(to))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove.

Comment on lines 46 to 49
MF_NATS_URL: ${MF_NATS_URL}
MF_JAEGER_URL: ${MF_JAEGER_URL}
MF_AUTH_GRPC_URL: ${MF_AUTH_GRPC_URL}
MF_AUTH_GRPC_TIMEOUT: ${MF_AUTH_GRPC_TIMEOUT}
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can group SMPP-related env vars by putting these on top of the environment section.

Signed-off-by: Ivan Milosevic <iva@blokovi.com>
Comment on lines 64 to 67
if err != nil {
return err
}
fmt.Println("Message ID:", sm.RespID())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove logs.

Signed-off-by: Ivan Milosevic <iva@blokovi.com>
dborovcanin
dborovcanin previously approved these changes Sep 24, 2021
var _ notifiers.Notifier = (*notifier)(nil)

type notifier struct {
t *smpp.Transmitter
Copy link
Contributor

Choose a reason for hiding this comment

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

I would consider calling this struct field transmitter, and one below transformer. When it comes to struct fields, I find it easier to read the code - example on one of the lines below n.t.Submit() does not tell me much as n.transmitter.Submit().

@nmarcetic @dusanb94 opinions?

Copy link
Collaborator

Choose a reason for hiding this comment

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

For me, both are fine. Transmitter is a bit more self-explanatory, t is shorter. When reading the code, the one will probably need to check what it is in any case.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agree @drasko @dusanb94 , readability wins. I prefer to keep variable names short in scopes (like 1-3 letters), not struct fields where they should be obvious.

Signed-off-by: Ivan Milosevic <iva@blokovi.com>
@@ -18,8 +18,8 @@ import (
var _ notifiers.Notifier = (*notifier)(nil)

type notifier struct {
t *smpp.Transmitter
tr transformers.Transformer
transmiter *smpp.Transmitter
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: transmitter

Signed-off-by: Ivan Milosevic <iva@blokovi.com>
Copy link
Contributor

@drasko drasko left a comment

Choose a reason for hiding this comment

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

LGTM

@drasko drasko merged commit 66d3da0 into absmach:master Oct 6, 2021
buraksekili pushed a commit to buraksekili/mainflux that referenced this pull request Oct 18, 2021
* Add SMPP notifier

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* fix readme
remove env file

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* resolve conversations

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* Remove debug log

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* Rename transmiter and transformer fields in struct

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* fix typo

Signed-off-by: Ivan Milosevic <iva@blokovi.com>
buraksekili pushed a commit to buraksekili/mainflux that referenced this pull request Oct 18, 2021
* Add SMPP notifier

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* fix readme
remove env file

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* resolve conversations

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* Remove debug log

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* Rename transmiter and transformer fields in struct

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* fix typo

Signed-off-by: Ivan Milosevic <iva@blokovi.com>
dborovcanin pushed a commit to dborovcanin/magistrala that referenced this pull request Oct 22, 2021
* Add SMPP notifier

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* fix readme
remove env file

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* resolve conversations

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* Remove debug log

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* Rename transmiter and transformer fields in struct

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* fix typo

Signed-off-by: Ivan Milosevic <iva@blokovi.com>
mteodor pushed a commit to mteodor/mainflux that referenced this pull request Dec 23, 2021
* Add SMPP notifier

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* fix readme
remove env file

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* resolve conversations

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* Remove debug log

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* Rename transmiter and transformer fields in struct

Signed-off-by: Ivan Milosevic <iva@blokovi.com>

* fix typo

Signed-off-by: Ivan Milosevic <iva@blokovi.com>
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.

6 participants