-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrss.ts
More file actions
99 lines (94 loc) · 2.5 KB
/
Copy pathrss.ts
File metadata and controls
99 lines (94 loc) · 2.5 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
export interface RawRssFeed {
ID: bigint;
channel: bigint;
type: string;
link: string;
date: string;
structure: string;
roles: string;
use_embed: boolean;
embed: string;
silent_mention: boolean;
recent_errors: number;
enabled: boolean;
added_at: string;
}
export const VALID_RSS_FEED_TYPES = ["bluesky", "deviantart", "twitch", "web", "yt"] as const;
export type VALID_RSS_FEED_TYPES = (typeof VALID_RSS_FEED_TYPES)[number];
export interface RssFeedForCreation {
channelId: string;
type: VALID_RSS_FEED_TYPES;
link: string;
structure: string;
roles: string[];
useEmbed: boolean;
embed: {
author_text?: string;
title?: string;
footer_text?: string;
color?: number;
show_date_in_footer?: boolean;
enable_link_in_title?: boolean;
image_location?: "thumbnail" | "banner" | "none";
};
silentMention: boolean;
enabled: boolean;
}
export interface RssFeedForEdition {
id: string;
channelId: string;
structure: string;
roles: string[];
useEmbed: boolean;
embed: {
author_text?: string;
title?: string;
footer_text?: string;
color?: number;
show_date_in_footer?: boolean;
enable_link_in_title?: boolean;
image_location?: "thumbnail" | "banner" | "none";
};
silentMention: boolean;
enabled: boolean;
}
export interface DBRssFeed {
id: bigint;
channelId: bigint;
type: string;
link: string;
date: Date;
structure: string;
roles: bigint[];
useEmbed: boolean;
embed: {
author_text?: string;
title?: string;
footer_text?: string;
color?: number;
show_date_in_footer?: boolean;
enable_link_in_title?: boolean;
image_location?: "thumbnail" | "banner" | "none";
};
silentMention: boolean;
recentErrors: number;
enabled: boolean;
addedAt: Date;
}
export function rawToDBRssFeed(raw: RawRssFeed): DBRssFeed {
return {
id: raw.ID,
channelId: raw.channel,
type: raw.type,
link: raw.link,
date: new Date(raw.date),
structure: raw.structure,
roles: raw.roles ? raw.roles.split(";").map(BigInt) : [],
useEmbed: Boolean(raw.use_embed),
embed: JSON.parse(raw.embed),
silentMention: Boolean(raw.silent_mention),
recentErrors: raw.recent_errors,
enabled: Boolean(raw.enabled),
addedAt: new Date(raw.added_at),
};
}