• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

teableio / teable / 8421671885

25 Mar 2024 02:23PM UTC coverage: 79.959% (+53.9%) from 26.087%
8421671885

Pull #496

github

web-flow
Merge f587f00fb into 9313e45fb
Pull Request #496: fix: unexpected link convert

3265 of 3865 branches covered (84.48%)

63 of 63 new or added lines in 4 files covered. (100.0%)

762 existing lines in 27 files now uncovered.

25183 of 31495 relevant lines covered (79.96%)

1188.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

47.14
/apps/nestjs-backend/src/features/automation/actions/mail-sender/mail-sender.ts
1
import { Injectable, Logger, Scope } from '@nestjs/common';
2✔
2
import type { Almanac, Event, RuleResult } from 'json-rules-engine';
2✔
3
import MarkdownIt from 'markdown-it';
2✔
4
import { MailSenderService } from '../../../mail-sender/mail-sender.service';
2✔
5
import type { IActionResponse, IObjectArraySchema, ITemplateSchema } from '../action-core';
2✔
6
import { actionConst, ActionCore, ActionResponseStatus } from '../action-core';
2✔
7

2✔
8
export const markdownIt = MarkdownIt({
2✔
9
  html: true,
2✔
10
  breaks: true,
2✔
11
  // eslint-disable-next-line @typescript-eslint/no-var-requires
2✔
12
}).use(require('markdown-it-sanitizer'));
2✔
13

2✔
14
export interface IMailSenderSchema extends Record<string, unknown> {
2✔
15
  to: IObjectArraySchema;
2✔
16
  cc?: IObjectArraySchema;
2✔
17
  bcc?: IObjectArraySchema;
2✔
18
  replyTo?: IObjectArraySchema;
2✔
19
  subject: ITemplateSchema;
2✔
20
  message: ITemplateSchema;
2✔
21
}
2✔
22

2✔
23
export interface IMailSenderOptions {
2✔
24
  to: string[];
2✔
25
  cc?: string[];
2✔
26
  bcc?: string[];
2✔
27
  replyTo?: string[];
2✔
28
  subject: string;
2✔
29
  message: string;
2✔
30
}
2✔
31

2✔
32
@Injectable({ scope: Scope.REQUEST })
2✔
33
export class MailSender extends ActionCore {
2✔
UNCOV
34
  private logger = new Logger(MailSender.name);
×
UNCOV
35

×
UNCOV
36
  constructor(private readonly mailSenderService: MailSenderService) {
×
UNCOV
37
    super();
×
UNCOV
38
  }
×
UNCOV
39

×
UNCOV
40
  bindParams(id: string, params: IMailSenderSchema, priority?: number): this {
×
UNCOV
41
    return this.setName(id).setEvent({ type: id, params: params }).setPriority(priority);
×
UNCOV
42
  }
×
UNCOV
43

×
UNCOV
44
  onSuccess = async (event: Event, almanac: Almanac, _ruleResult: RuleResult): Promise<void> => {
×
UNCOV
45
    const { to, cc, bcc, replyTo, subject, message } =
×
UNCOV
46
      await this.parseInputSchema<IMailSenderOptions>(event.params as IMailSenderSchema, almanac);
×
UNCOV
47

×
UNCOV
48
    const html = markdownIt.render(message);
×
UNCOV
49

×
UNCOV
50
    const mailOptions = { to, cc, bcc, replyTo, subject, html };
×
UNCOV
51

×
UNCOV
52
    let outPut: IActionResponse<unknown>;
×
UNCOV
53
    await this.mailSenderService
×
UNCOV
54
      .sendMail(mailOptions)
×
UNCOV
55
      .then((senderResult) => {
×
UNCOV
56
        outPut = { data: { senderResult }, status: ActionResponseStatus.OK };
×
UNCOV
57
      })
×
UNCOV
58
      .catch((error) => {
×
59
        this.logger.error(error.message, error?.stack);
×
60
        outPut = {
×
61
          error: error.message,
×
62
          data: undefined,
×
63
          status: ActionResponseStatus.InternalServerError,
×
64
        };
×
65
      })
×
UNCOV
66
      .finally(() => {
×
UNCOV
67
        almanac.addRuntimeFact(`${actionConst.OutPutFlag}${this.name}`, outPut);
×
UNCOV
68
      });
×
UNCOV
69
  };
×
UNCOV
70
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc