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

[#174824788] subscription feed on user delete #81

Merged
merged 20 commits into from
Sep 23, 2020

Conversation

balanza
Copy link
Contributor

@balanza balanza commented Sep 17, 2020

Add a record of type UNSUBSCRIBE to the subscription feed when a user is deleted in his/her claim to erasure.

A connection to the SubscriptionsFeed storage table is added to the current service.

Env variables

The following environment variables have been added:

Variable name Description type
QueueStorageConnection Storage connection string for subscription feed string
SUBSCRIPTIONS_FEED_TABLE Table name for the Subscriptions Feed in the storage string

@balanza balanza requested review from gunzip and removed request for cloudify and francescopersico September 17, 2020 10:29
@balanza balanza self-assigned this Sep 17, 2020
@pagopa-github-bot
Copy link
Contributor

pagopa-github-bot commented Sep 17, 2020

Affected stories

  • 🌟 #174824788: Come SAS non voglio inviare messaggi a utenti che hanno chiesto l'eliminazione dei propri dati da IO

New dependencies added: html-to-text, nodemailer and nodemailer-sendgrid.

html-to-text

Author: Malte Legenhausen

Description: Advanced html to plain text converter

Homepage: https://github.com/werk85/node-html-to-text

Createdabout 8 years ago
Last Updatedabout 1 year ago
LicenseMIT
Maintainers1
Releases36
Direct Dependencieshe, htmlparser2, minimist and lodash
Keywordshtml, node, text, mail, plain and converter
This README is too long to show.

nodemailer

Author: Andris Reinman

Description: Easy as cake e-mail sending from your Node.js applications

Homepage: https://nodemailer.com/

Createdover 9 years ago
Last Updatedabout 2 months ago
LicenseMIT
Maintainers1
Releases231
Direct Dependencies
KeywordsNodemailer
README

Nodemailer

Nodemailer

Send e-mails from Node.js – easy as cake! 🍰✉️

NPM

See nodemailer.com for documentation and terms.

Having an issue?

First review the docs

Documentation for Nodemailer can be found at nodemailer.com.

Nodemailer throws a SyntaxError for "..."

You are using older Node.js version than v6.0. Upgrade Node.js to get support for the spread operator.

I'm having issues with Gmail

Gmail either works well or it does not work at all. It is probably easier to switch to an alternative service instead of fixing issues with Gmail. If Gmail does not work for you then don't use it. Read more about it here.

I get ETIMEDOUT errors

Check your firewall settings. Timeout usually occurs when you try to open a connection to a port that is firewalled either on the server or on your machine.

I get TLS errors

  • If you are running the code in your own machine, then check your antivirus settings. Antiviruses often mess around with email ports usage. Node.js might not recognize the MITM cert your antivirus is using.
  • Latest Node versions allow only TLS versions 1.2 and higher, some servers might still use TLS 1.1 or lower. Check Node.js docs how to get correct TLS support for your app.

I have a different problem

If you are having issues with Nodemailer, then the best way to find help would be Stack Overflow or revisit the docs.

License

Nodemailer is licensed under the MIT license


The Nodemailer logo was designed by Sven Kristjansen.

nodemailer-sendgrid

Author: Andris Reinman

Description: SendGrid transport object for Nodemailer.

Homepage: http://npmjs.com/package/nodemailer-sendgrid

Createdalmost 3 years ago
Last Updatedover 2 years ago
LicenseMIT
Maintainers1
Releases4
Direct Dependencies@sendgrid/mail
Keywordsnodemailer and sendgrid
README

nodemailer-sendgrid

SendGrid transport object for Nodemailer.

Warning, vendor lock-in ahead!

Using provider APIs like SendGrid might result in a vendor lock-in, especially if you are using provider specific features. So always consider if you would
prefer to use SMTP based services instead where vendor lock-ins do not happen.

Switching from a SMTP based provider to another is much easier (you do need to edit some DNS settings at least) than switching API based providers where you
probably have a lot of custom code targeting your existing provider.

This module is specially designed to be as much compatible with Nodemailer as possible, so if you do not touch the Sendgrid specific configuration options then
switching from SendGrid API to any other provider should be just as easy as switching from SMTP.

Usage

Requires Nodemailer v4.3.0+

This module is mostly meant to demonstrate the usage of mail.normalize(cb) method in Nodemailer v4.3. This allows creating HTTP API based transports for
Nodemailer much easier.

Install from NPM

npm install nodemailer nodemailer-sendgrid

Create Nodemailer transport

const nodemailer = require('nodemailer');
const nodemailerSendgrid = require('nodemailer-sendgrid');
const transport = nodemailer.createTransport(
    nodemailerSendgrid({
        apiKey: process.env.SENDGRID_API_KEY
    })
);

See full example.

Send a message

Message objects support the entire Nodemailer API. In addition you can provide SendGrid specific keys like templateId or sendAt.

transport.sendMail({
    from: '[email protected]',
    to: 'Receiver Name <[email protected]>, [email protected]',
    subject: 'hello world',
    html: '<h1>Hello world!</h1>'
});

License

MIT

Generated by 🚫 dangerJS

GetProfileActivity/handler.ts Outdated Show resolved Hide resolved
Comment on lines 59 to 61
// When the function starts, attempt to create the table if it does not exist
// Note that we cannot log anything just yet since we don't have a Context
tableService.createTableIfNotExists(subscriptionsFeedTable, () => 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

remove these lines (they're useless even in io-fn-app)

env.example Outdated
@@ -53,3 +53,6 @@ NODE_TLS_REJECT_UNAUTHORIZED=0
languageWorkers__node__arguments="--inspect=0.0.0.0:5861"

# AzureWebJobs.UpdateVisibleServicesCache.Disabled=true

QueueStorageConnection=<STORAGE_CONNECTION_STRING>
Copy link
Contributor

Choose a reason for hiding this comment

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

can we rename QueueStorageConnection to SubscriptionFeedStorageConnection ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@codecov-commenter
Copy link

codecov-commenter commented Sep 17, 2020

Codecov Report

Merging #81 into master will decrease coverage by 2.68%.
The diff coverage is 76.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #81      +/-   ##
==========================================
- Coverage   86.62%   83.94%   -2.69%     
==========================================
  Files          39       44       +5     
  Lines        1249     1489     +240     
  Branches       88      124      +36     
==========================================
+ Hits         1082     1250     +168     
- Misses        166      234      +68     
- Partials        1        5       +4     
Impacted Files Coverage Δ
SendUserDataDeleteEmailActivity/handler.ts 37.50% <37.50%> (ø)
DeleteUserDataActivity/utils.ts 34.21% <50.00%> (ø)
utils/conversions.ts 81.81% <58.33%> (-6.82%) ⬇️
GetUser/handler.ts 90.27% <63.63%> (-1.91%) ⬇️
ExtractUserDataActivity/handler.ts 77.30% <70.96%> (-0.71%) ⬇️
UserDataDeleteOrchestrator/handler.ts 90.55% <83.33%> (-2.24%) ⬇️
DeleteUserDataActivity/backupAndDelete.ts 92.85% <87.09%> (ø)
GetProfileActivity/handler.ts 90.69% <90.69%> (ø)
GetServices/handler.ts 84.84% <94.73%> (-0.34%) ⬇️
CreateService/handler.ts 85.18% <100.00%> (ø)
... and 14 more

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 618aff4...3faa986. Read the comment docs.

@gunzip gunzip self-requested a review September 17, 2020 15:30
Copy link
Contributor

@gunzip gunzip left a comment

Choose a reason for hiding this comment

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

lgtm @francescopersico can we merge this?

@@ -0,0 +1,176 @@
import * as crypto from "crypto";
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really want to maintain all this logic when we just want to add an UNSUBSCRIBE event in the table?

Copy link
Contributor

@gunzip gunzip Sep 18, 2020

Choose a reason for hiding this comment

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

May you mark the parts that you think are redundant? I've asked the same question myself, then I noticed that

  1. the intent here was to have a general purpose activity (as the name is indeed 'UpdateSubscriptionsFeedActivity' and not 'UnsubscribeUser')
  2. If we switch this to UnsubscribeUser we need to keep 80% of the logic anyway and you only gain about 10 lines less getting rid of the 'subscribe' branch.

a better way, as @balanza suggested, is to have this code inside io-functions-commons and use that here and in io-functions-app

Copy link
Contributor

Choose a reason for hiding this comment

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

The risk of duplicating the "subscribe" code here is that you must maintain it in sync if changes happens.
About sharing the code inside io-functions-commons i am more convinced that subscriptions must be managed by a specific/separate service.

Copy link
Contributor

Choose a reason for hiding this comment

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

what do you suggest in the meantime?

Copy link
Contributor

Choose a reason for hiding this comment

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

It is ok for me to merge as is.

@gunzip gunzip merged commit 8b711c3 into master Sep 23, 2020
@gunzip gunzip deleted the 174824788-subscription-feed-on-user-delete branch September 23, 2020 13:04
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.

5 participants