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

[IOCIT-141] Handle user preferences for push notification format #232

Merged
merged 7 commits into from
Nov 16, 2022

Conversation

gquadrati
Copy link
Contributor

@gquadrati gquadrati commented Nov 9, 2022

List of Changes

Motivation and Context

Send push notification as defined by user.

How Has This Been Tested?

Unit test

Screenshots (if appropriate):

Types of changes

  • Chore (nothing changes by a user perspective)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

@pagopa-github-bot
Copy link
Contributor

pagopa-github-bot commented Nov 9, 2022

Warnings
⚠️ This PR changes a total of 281 LOCs, that is more than a reasonable size of 250. Consider splitting the pull request into smaller ones.
⚠️ Please include a Pivotal story at the beginning of the PR title (see below).

Example of PR titles that include pivotal stories:

  • single story: [#123456] my PR title
  • multiple stories: [#123456,#123457,#123458] my PR title

Generated by 🚫 dangerJS against 5ded0e7

Copy link
Contributor

@michaeldisaro michaeldisaro left a comment

Choose a reason for hiding this comment

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

Just some comments, logic looks good.

title: NonEmptyString,
detail: NonEmptyString,
objectName: NonEmptyString
): NotFoundError => ({ detail, kind: "NotFound", objectName, title });
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not defining an enum for error kinds instead of always writing a string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not "always", because this is a method that builds a NotFoundError, so it's the only point in which that string will be written.
But I agree that having an enum is a best practice.
Done in 7908370

@@ -125,11 +130,14 @@ export const sendToWebhook = (
notifyApiCall({
notification: {
// If the service requires secure channels
// or user did not allow to receave verbose notifications
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: Receive

fiscalCode: message.fiscalCode
}),
// We are using T.map(E.getOrElseW(..)) because
// TE.getOrElseW is unable to infer `userProfile` type
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this an fp-ts bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad. With TE.getOrElse it works fine.
Done in [#IOCIT-141] fix TE.getOrElse return type on userProfile

@@ -38,6 +39,11 @@ import * as TE from "fp-ts/lib/TaskEither";
import * as O from "fp-ts/lib/Option";
import { StandardServiceCategoryEnum } from "../../generated/api-admin/StandardServiceCategory";

import { toInternalError, toNotFoundError } from "../../utils/domain-errors";
import { GetUserProfileReader } from "../../readers/user-profile.readers";
Copy link
Contributor

Choose a reason for hiding this comment

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

The folder is readers, why calling the file .readers.ts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WebhookNotification/__tests__/handler.test.ts Outdated Show resolved Hide resolved
@gquadrati gquadrati marked this pull request as ready for review November 10, 2022 09:20
@gquadrati gquadrati requested a review from a team as a code owner November 10, 2022 09:20
@gquadrati gquadrati force-pushed the IOCIT-141--verbose-notification branch from 3a35752 to 60ac8fb Compare November 10, 2022 12:17
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Contributor

@AleDore AleDore left a comment

Choose a reason for hiding this comment

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

LGTM

fiscalCode: message.fiscalCode
}),
TE.getOrElse(err => {
throw new Error(err.title);
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 better to throw the err title or the err message?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure, since this error is needed for replaying the operation, I thought it was not useful to write detailed info.

Copy link
Contributor

@fabriziopapi fabriziopapi left a comment

Choose a reason for hiding this comment

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

LGTM, just a minor comment.

@gquadrati gquadrati merged commit 088090d into master Nov 16, 2022
@gquadrati gquadrati deleted the IOCIT-141--verbose-notification branch November 16, 2022 14:26
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