summaryrefslogtreecommitdiff
path: root/src/job.ts
blob: b1198f8379b6811966067165c0330d10086775e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
export interface EmailInstruction {
  email: string;
  username: string;
  password: string;
  server: string;
}

export interface EmailFromInstruction extends EmailInstruction {
  send_port: number;
}

export interface EmailToInstruction extends EmailInstruction {
  read_port: number;
}

export interface EmailJob {
  from: EmailFromInstruction;
  to: EmailToInstruction;
  readRetry: Retry;
}

export interface Retry {
  retries: number;
  interval: number;
}

export const redact = <T extends EmailInstruction>(instruction: T): T => ({
  ...instruction,
  password: "REDACTED",
  username: "REDACTED",
});

export const redactJob = (job: EmailJob): EmailJob => ({
  ...job,
  from: redact(job.from),
  to: redact(job.to),
});