Skip to content

armgit / papra

Public Imported from GitHub
0

The minimalistic document archiving platform.

1.1 KB
Raw Blame
import { buildUrl } from '@corentinth/chisels';
import { triggerWebhook } from '@owlrelay/webhook';
import { getServerBaseUrl } from '../modules/config/config.models';
import { INTAKE_EMAILS_INGEST_ROUTE } from '../modules/intake-emails/intake-emails.constants';
import { runScriptWithDb } from './commons/run-script';

await runScriptWithDb({ scriptName: 'simulate-intake-email' }, async ({ config }) => {
  const { serverBaseUrl } = getServerBaseUrl({ config });
  const { webhookSecret } = config.intakeEmails;

  const webhookUrl = buildUrl({ baseUrl: serverBaseUrl, path: INTAKE_EMAILS_INGEST_ROUTE });

  await triggerWebhook({
    webhookUrl,
    webhookSecret,
    email: {
      from: { address: '[email protected]', name: 'Test' },
      to: [{ address: '[email protected]', name: 'Test' }],
      subject: 'Test',
      text: 'Hello, world!',
      html: '<p>Hello, world!</p>',
      attachments: [
        {
          filename: 'test.txt',
          content: new TextEncoder().encode('Hello, world!').buffer,
          mimeType: 'text/plain',
        },
      ],
    },
  });
});