Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

fix emails and draft

Nevo David5d1988c2f18a
diff --git a/apps/frontend/src/components/new-launch/manage.modal.tsx b/apps/frontend/src/components/new-launch/manage.modal.tsx
index d7cf56260..243da51f2 100644
--- a/apps/frontend/src/components/new-launch/manage.modal.tsx
+++ b/apps/frontend/src/components/new-launch/manage.modal.tsx
@@ -246,35 +246,36 @@ export const ManageModal: FC<AddEditModalProps> = (props) => {
setLoading(true);
const checkAllValid = await ref.current.checkAllValid();
- if (type !== 'draft') {
- const notEnoughChars = checkAllValid.filter((p: any) => {
- return p.values.some((a: any) => {
- return (
- countCharacters(
- stripHtmlValidation('normal', a.content, true),
- p?.integration?.identifier || ''
- ) === 0 && a.media?.length === 0
- );
- });
- });
- for (const item of notEnoughChars) {
- toaster.show(
- `${capitalize(item.integration.identifier.split('-')[0])} (${
- item.integration.name
- }):` +
- ' ' +
- t(
- 'post_needs_content_or_image',
- 'Your post should have at least one character or one image.'
- ),
- 'warning'
+ const notEnoughChars = checkAllValid.filter((p: any) => {
+ return p.values.some((a: any) => {
+ return (
+ countCharacters(
+ stripHtmlValidation('normal', a.content, true),
+ p?.integration?.identifier || ''
+ ) === 0 && a.media?.length === 0
);
- setLoading(false);
- item.preview();
- return;
- }
+ });
+ });
+
+ for (const item of notEnoughChars) {
+ toaster.show(
+ `${capitalize(item.integration.identifier.split('-')[0])} (${
+ item.integration.name
+ }):` +
+ ' ' +
+ t(
+ 'post_needs_content_or_image',
+ 'Your post should have at least one character or one image.'
+ ),
+ 'warning'
+ );
+ setLoading(false);
+ item.preview();
+ return;
+ }
+ if (type !== 'draft') {
for (const item of checkAllValid) {
if (item.valid === false) {
toaster.show(
diff --git a/libraries/nestjs-libraries/src/services/email.service.ts b/libraries/nestjs-libraries/src/services/email.service.ts
index a0dc83112..75157f58d 100644
--- a/libraries/nestjs-libraries/src/services/email.service.ts
+++ b/libraries/nestjs-libraries/src/services/email.service.ts
@@ -4,6 +4,7 @@ import { ResendProvider } from '@gitroom/nestjs-libraries/emails/resend.provider
import { EmptyProvider } from '@gitroom/nestjs-libraries/emails/empty.provider';
import { NodeMailerProvider } from '@gitroom/nestjs-libraries/emails/node.mailer.provider';
import { TemporalService } from 'nestjs-temporal-core';
+import { timer } from '@gitroom/helpers/utils/timer';
@Injectable()
export class EmailService {
@@ -37,7 +38,7 @@ export class EmailService {
to: string,
subject: string,
html: string,
- sendTo: 'top' | 'bottom',
+ addTo: 'top' | 'bottom',
replyTo?: string
) {
return this._temporalService.client
@@ -47,7 +48,7 @@ export class EmailService {
workflowId: 'send_email',
signal: 'sendEmail',
args: [{ queue: [] }],
- signalArgs: [{ to, subject, html, replyTo, sendTo }],
+ signalArgs: [{ to, subject, html, replyTo, addTo }],
workflowIdConflictPolicy: 'USE_EXISTING',
});
}
@@ -123,18 +124,27 @@ export class EmailService {
</div>
`;
- try {
- const sends = await this.emailService.sendEmail(
- to,
- subject,
- modifiedHtml,
- process.env.EMAIL_FROM_NAME,
- process.env.EMAIL_FROM_ADDRESS,
- replyTo
- );
- console.log(sends);
- } catch (err) {
- console.log(err);
+ let lastErr: unknown;
+ for (let attempt = 0; attempt < 3; attempt++) {
+ try {
+ const sends = await this.emailService.sendEmail(
+ to,
+ subject,
+ modifiedHtml,
+ process.env.EMAIL_FROM_NAME,
+ process.env.EMAIL_FROM_ADDRESS,
+ replyTo
+ );
+ console.log(sends);
+ return;
+ } catch (err) {
+ lastErr = err;
+ console.log(`Email attempt ${attempt + 1}/3 failed:`, err);
+ if (attempt < 2) {
+ await timer(700);
+ }
+ }
}
+ console.log(`Email to ${to} failed after 3 attempts:`, lastErr);
}
}