-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add endpoint to send newsletter consent email (#645)
* feat: Add endpoint to send newsletter consent email * feat: Allow for dynamic setting for removing registeredUsers from mail list * chore: Add maximum number of retries when getting export status Needed to prevent potential infinite loop * chore: Make send-newsletter-consent endpoint protected * chore: Improvements * chore: Add content value dynamically based on fn call Not quite sure, what this value is for, but it is better to have it like this for now * fix: Linter error * chore: Improve TS definitions * chore: Code cleanup
- Loading branch information
1 parent
66a6354
commit c814b46
Showing
7 changed files
with
372 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Create a chunked array of new Map() | ||
* @param map map to be chunked | ||
* @param chunkSize The size of the chunk | ||
* @returns Array chunk of new Map() | ||
*/ | ||
|
||
export function mapChunk<T extends Map<any, any>>(map: T, chunkSize: number) { | ||
return Array.from(map.entries()).reduce<T[]>((chunk, curr, index) => { | ||
const ch = Math.floor(index / chunkSize) | ||
if (!chunk[ch]) { | ||
chunk[ch] = new Map() as T | ||
} | ||
chunk[ch].set(curr[0], curr[1]) | ||
return chunk | ||
}, []) | ||
} |
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,35 @@ | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { Expose } from 'class-transformer' | ||
import { IsDateString, IsNumber, IsOptional, IsString } from 'class-validator' | ||
|
||
export class MassMailDto { | ||
@ApiProperty() | ||
@Expose() | ||
@IsString() | ||
listId: string | ||
|
||
@ApiProperty() | ||
@Expose() | ||
@IsString() | ||
templateId: string | ||
|
||
@ApiProperty() | ||
@Expose() | ||
@IsString() | ||
@IsOptional() | ||
subject: string | ||
|
||
//Sendgrid limits sending emails to 1000 at once. | ||
@ApiProperty() | ||
@Expose() | ||
@IsNumber() | ||
@IsOptional() | ||
chunkSize = 1000 | ||
|
||
//Remove users registered after the dateThreshold from mail list | ||
@ApiProperty() | ||
@Expose() | ||
@IsDateString() | ||
@IsOptional() | ||
dateThreshold: Date = new Date() | ||
} |
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
Oops, something went wrong.