1 | import { htmlToText } from "html-to-text";
|
2 | import { RawUser } from "./raw-user";
|
3 | import { unixToIsoString } from "./unix-to-iso-string";
|
4 | import { User } from "./user";
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export function normalizeRawUser({ rawUser }: { rawUser: RawUser }): User {
|
10 |
|
11 | const createdAt = unixToIsoString({ time: rawUser.created });
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | const about = rawUser.about
|
17 | ? htmlToText(rawUser.about, { wordwrap: false })
|
18 | : undefined;
|
19 |
|
20 | return {
|
21 | id: rawUser.id,
|
22 | createdAt,
|
23 | karma: rawUser.karma,
|
24 | about,
|
25 | submittedIds: rawUser.submitted,
|
26 | };
|
27 | }
|