-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed Issue #1: [SNS] Subscriptions all sub to the same topic arn
- Loading branch information
1 parent
ee0babc
commit e1db34e
Showing
8 changed files
with
72 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { InjectRepository } from '@nestjs/typeorm'; | ||
import { Repository } from 'typeorm'; | ||
import { AbstractActionHandler, AwsProperties, Format } from '../abstract-action.handler'; | ||
import { Action } from '../action.enum'; | ||
import * as Joi from 'joi'; | ||
import { TagsService } from '../aws-shared-entities/tags.service'; | ||
import { AttributesService } from '../aws-shared-entities/attributes.service'; | ||
import { SnsTopicSubscription } from './sns-topic-subscription.entity'; | ||
import * as uuid from 'uuid'; | ||
|
||
type QueryParams = { | ||
SubscriptionArn: string; | ||
} | ||
|
||
@Injectable() | ||
export class UnsubscribeHandler extends AbstractActionHandler<QueryParams> { | ||
|
||
constructor( | ||
@InjectRepository(SnsTopicSubscription) | ||
private readonly snsTopicSubscription: Repository<SnsTopicSubscription>, | ||
private readonly tagsService: TagsService, | ||
private readonly attributeService: AttributesService, | ||
) { | ||
super(); | ||
} | ||
|
||
format = Format.Xml; | ||
action = Action.SnsUnsubscribe; | ||
validator = Joi.object<QueryParams, true>({ | ||
SubscriptionArn: Joi.string().required(), | ||
}); | ||
|
||
protected async handle(params: QueryParams, awsProperties: AwsProperties) { | ||
|
||
const id = params.SubscriptionArn.split(':').pop(); | ||
const subscription = await this.snsTopicSubscription.findOne({ where: { id } }); | ||
|
||
await this.tagsService.deleteByArn(subscription.arn); | ||
await this.attributeService.deleteByArn(subscription.arn); | ||
await this.snsTopicSubscription.delete({ id }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters