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

feat(support-notifications): use notification content type #2699

Merged
merged 1 commit into from
Sep 23, 2020
Merged

feat(support-notifications): use notification content type #2699

merged 1 commit into from
Sep 23, 2020

Conversation

AlexCuse
Copy link
Contributor

Use ContentType defined on notification on HTTP header for HTTP channel
and MIME header for SMTP channel. Also add chunking with newlines for
long SMTP messages.

Signed-off-by: Alex Ullrich alexullrich@technotects.com

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit subject follows the Conventional Commits spec
  • The commit message follows the EdgeX Contributor Guide
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • make test has completed successfully

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

Not sure if a bug per se but current implementation disregards the content type set on the notification, and also runs into problems sending long SMTP messages

What is the current behavior?

Issue Number: #2682

What is the new behavior?

Includes content type specified on the notification in the HTTP header for REST transmission, and in the MIME header for SMTP transmission. Also introduces chunking of SMTP payloads for messages longer than 1000 characters.

Does this PR introduce a breaking change?

  • Yes
  • No

Are there any new imports or modules? If so, what are they used for and why?

No

Are there any specific instructions or things that should be known prior to reviewing?

I mentioned ability to specify character set and general sending service refactoring in the linked issue but not addressing at this time. Not going to pursue 'smarter' chunking using bytes.Runes until I find a failure case with the current implementation - not sure if this will come with expanding charset support or not.

Other information

@AlexCuse
Copy link
Contributor Author

I just looked through the docs and the diagrams already mention content type and defaulting to text/plain, I am not sure there is anything to do there.

https://docs.edgexfoundry.org/1.2/microservices/support/notifications/Ch-AlertsNotifications/

@AlexCuse
Copy link
Contributor Author

Build failure appears to be when trying to build Kong. Don't think it is related to my change but please let me know if I missed something.


stringResult := string(result)

assert.Equal(t, fmt.Sprintf("Subject: %s\r\n\r\n%s\r\n", subject, message), stringResult)
Copy link
Member

Choose a reason for hiding this comment

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

Like to see expected set outside the assert for readability. Here and the other tests

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 both of these and rebased

internal/support/notifications/sending_service.go Outdated Show resolved Hide resolved
lenny-goodell
lenny-goodell previously approved these changes Sep 23, 2020
Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

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

LGTM

@lenny-goodell
Copy link
Member

@AlexCuse , code looks good. Please tweak your commit message to follow our new Conventional Commit guidelines here:
https://wiki.edgexfoundry.org/display/FA/Committing+Code+Guidelines#CommittingCodeGuidelines-ConventionalCommits

Specifically. The issue number should be in the body as closes #2699 and I feel the title should include something like and long line splitting. We are hoping to start using a tool that creates the release notes from these commit messages. THX!

splitting
Use ContentType defined on notification on HTTP header for HTTP channel
and MIME header for SMTP channel.  Also add chunking with newlines for
long SMTP message lines.

Closes #2699

Signed-off-by: Alex Ullrich <alexullrich@technotects.com>
@sonarcloud
Copy link

sonarcloud bot commented Sep 23, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@AlexCuse
Copy link
Contributor Author

@lenny-intel should be good now thanks. I wanted to include the line splitting in title but worried it'd be too long. I rebased the branch again too just in case.

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.

2 participants