Skip to content

Commit

Permalink
fix: fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
darraghoriordan committed Dec 24, 2023
1 parent 5684846 commit b984f08
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 31 deletions.
21 changes: 11 additions & 10 deletions src/invitations/invitation.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,12 @@ export class InvitationService {
});

if (
existingMemberships.some((m) =>
m.roles?.some(
(r) => r.name === Roles.member || r.name === Roles.owner
)
existingMemberships.some(
(m) =>
m.roles?.some(
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
(r) => r.name === Roles.member || r.name === Roles.owner
)
)
) {
const message =
Expand Down Expand Up @@ -146,9 +148,8 @@ export class InvitationService {
membership.invitations?.push(unsavedInvitation);
membership.roles = [role];

const savedMembership = await this.orgMembershipRepository.save(
membership
);
const savedMembership =
await this.orgMembershipRepository.save(membership);
const retrievedMembership = await this.orgMembershipRepository.findOne({
where: {id: savedMembership.id},
relations: {
Expand Down Expand Up @@ -200,9 +201,8 @@ export class InvitationService {
// if it gets to here we have a queued invitation
validInvitation.notificationSent = new Date();

const savedInvitation = await this.invitationRepository.save(
validInvitation
);
const savedInvitation =
await this.invitationRepository.save(validInvitation);
// we need to return the membership with the invitation
// torm doesn't like if we just assign and return so get it again
const fullInvitation = await this.invitationRepository.findOne({
Expand Down Expand Up @@ -253,6 +253,7 @@ export class InvitationService {
},
});
if (
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
requesterMembership.roles?.some((role) => role.name === Roles.owner)
) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export class OrganisationMembershipsService {
// add all roles to the existing membership
for (const role of createOmDto.roles) {
const existingRole = existingMembership.roles?.find(
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
(r) => r.name === role
);
if (!existingRole) {
Expand Down Expand Up @@ -106,6 +107,7 @@ export class OrganisationMembershipsService {
const membership = org.memberships?.find(
(m) =>
m.user.id === currentUserId &&
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
m.roles?.some((r) => r.name === Roles.owner)
);
if (!membership) {
Expand Down
33 changes: 12 additions & 21 deletions src/stripe-client/services/queued-payment-event.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ export class StripeQueuedEventHandler {
// Payment is successful and for example the subscription can be created.
// If you support asynchronous payment methods, handle those events in the
// checkout.session.async_payment_succeeded webhook.
const stripeDataProperty = job.data.data
.object as Stripe.Checkout.Session;
const stripeDataProperty = job.data.data.object;
if (stripeDataProperty.payment_status === "paid") {
// fulfil it
const fullSession =
Expand Down Expand Up @@ -104,8 +103,7 @@ export class StripeQueuedEventHandler {
case "checkout.session.async_payment_succeeded": {
// Payment link payment is successful for async payment methods. (bank drafts, etc.)
// probably not relevant for most people. But if you want to support it, here's how.
const stripeDataProperty = job.data.data
.object as Stripe.Checkout.Session;
const stripeDataProperty = job.data.data.object;
const fullSession =
await this.stripe.checkout.sessions.retrieve(
stripeDataProperty.id,
Expand All @@ -122,17 +120,15 @@ export class StripeQueuedEventHandler {
fullSession
);

const result = await this.organisationSubscriptionService.save(
subs
);
const result =
await this.organisationSubscriptionService.save(subs);
this.logger.log("Async payment succeeded", {result});
return;
}
case "checkout.session.async_payment_failed": {
// Payment link payment is NOT successful for async payment methods. (bank drafts, etc.)
// You can use this webhook to notify the user that their payment was not successful.
const stripeDataProperty = job.data.data
.object as Stripe.Checkout.Session;
const stripeDataProperty = job.data.data.object;
this.logger.error(
`Async payment failed for session ${stripeDataProperty.id}`
);
Expand Down Expand Up @@ -168,8 +164,7 @@ export class StripeQueuedEventHandler {

// The subscription becomes past_due. Notify your customer and send them to the
// customer portal to update their payment information.
const stripeDataProperty = job.data.data
.object as Stripe.Invoice;
const stripeDataProperty = job.data.data.object;
this.logger.error("Invoice payment failed", {
stripeDataProperty,
});
Expand All @@ -189,8 +184,7 @@ export class StripeQueuedEventHandler {
case "customer.subscription.deleted": {
// Sent when a customer’s subscription ends.

const stripeDataProperty = job.data.data
.object as Stripe.Subscription;
const stripeDataProperty = job.data.data.object;
const fullSession = await this.stripe.subscriptions.retrieve(
stripeDataProperty.id,
{
Expand All @@ -207,9 +201,8 @@ export class StripeQueuedEventHandler {
sub.validUntil = new Date();
}

const result = await this.organisationSubscriptionService.save(
subs
);
const result =
await this.organisationSubscriptionService.save(subs);
this.logger.log(
"Subscription deleted - validity set to today",
{result}
Expand All @@ -224,8 +217,7 @@ export class StripeQueuedEventHandler {
* For example, adding a coupon, applying a discount,
* adding an invoice item, and changing plans all trigger this event.
*/
const stripeDataProperty = job.data.data
.object as Stripe.Subscription;
const stripeDataProperty = job.data.data.object;
const fullSubscription =
await this.stripe.subscriptions.retrieve(
stripeDataProperty.id,
Expand All @@ -242,9 +234,8 @@ export class StripeQueuedEventHandler {
}
);

const result = await this.organisationSubscriptionService.save(
subs
);
const result =
await this.organisationSubscriptionService.save(subs);

this.logger.log("Subscription updated", {result});
return;
Expand Down

0 comments on commit b984f08

Please sign in to comment.