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

feat(api): homogenize trigger event use cases and fix tech debt #2885

Merged
merged 2 commits into from
Feb 23, 2023

Conversation

p-fernandez
Copy link
Contributor

What change does this PR introduce?

Homogenise the Trigger Event module use cases and fixes some tech debt related.
Also moves MessageMatcher to its own location as being an use case and not being used by TriggerEvent usecase.

Why was this change needed?

Tech debt.

Other information (Screenshots)

@@ -56,7 +54,6 @@ export const USE_CASES = [
SendMessageDelay,
SendTestEmail,
MapTriggerRecipients,
MapTriggerRecipientsCommand,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a mistake I introduced time ago.

Comment on lines -40 to -57
export class TestSendMessageCommand extends EnvironmentWithUserCommand {
@IsDefined()
contentType: 'customHtml' | 'editor';
@IsDefined()
payload: any; // eslint-disable-line @typescript-eslint/no-explicit-any
@IsDefined()
@IsString()
subject: string;
preheader?: string;
senderName?: string;
@IsDefined()
content: string | IEmailBlock[];
@IsDefined()
to: string | string[];
@IsOptional()
@IsString()
layoutId?: string | null;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving to its own file.

@@ -21,7 +23,7 @@ export class SendTestEmail {
private getDecryptedIntegrationsUsecase: GetDecryptedIntegrations
) {}

public async execute(command: TestSendMessageCommand) {
public async execute(command: SendTestEmailCommand) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We had a mixing naming style for this use case and command. Homogenised.

@@ -1,5 +1,11 @@
import type { BuilderFieldOperator } from './builder.types';

export enum TimeOperatorEnum {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added for tighter validation.
We could reuse it in other places we use these time strings. For example, DigestUnitEnum.

Copy link
Contributor

Choose a reason for hiding this comment

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

Loved it 👍🏻

@p-fernandez p-fernandez force-pushed the feat-api-tech-debt-homogenize-use-cases branch from 63819aa to 3e88330 Compare February 22, 2023 15:25
@@ -458,7 +460,7 @@ async function findAsync<T>(array: T[], predicate: (t: T) => Promise<boolean>):
}

async function filterAsync<T>(arr: T[], callback: (item: T) => Promise<boolean>): Promise<T[]> {
const fail = Symbol();
const fail = Symbol('Filter Async failure');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

DeepSource flagged this.

Comment on lines 14 to 15
preheader?: string;
senderName?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add IsOptional() here?

Copy link
Contributor

@djabarovgeorge djabarovgeorge left a comment

Choose a reason for hiding this comment

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

Looks good to me, added small comment there

@p-fernandez p-fernandez added this pull request to the merge queue Feb 23, 2023
Merged via the queue into next with commit 8a84cf5 Feb 23, 2023
@p-fernandez p-fernandez deleted the feat-api-tech-debt-homogenize-use-cases branch February 23, 2023 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants