mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
More Lysand protocol work, refactor keys, small refactoring overall
This commit is contained in:
parent
77a675afe6
commit
a1c0164e9d
11 changed files with 304 additions and 89 deletions
19
utils/content_types.ts
Normal file
19
utils/content_types.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { ContentFormat } from "~types/lysand/Object";
|
||||
|
||||
export const getBestContentType = (contents: ContentFormat[]) => {
|
||||
// Find the best content and content type
|
||||
if (contents.find(c => c.content_type === "text/x.misskeymarkdown")) {
|
||||
return (
|
||||
contents.find(c => c.content_type === "text/x.misskeymarkdown") ||
|
||||
null
|
||||
);
|
||||
} else if (contents.find(c => c.content_type === "text/html")) {
|
||||
return contents.find(c => c.content_type === "text/html") || null;
|
||||
} else if (contents.find(c => c.content_type === "text/markdown")) {
|
||||
return contents.find(c => c.content_type === "text/markdown") || null;
|
||||
} else if (contents.find(c => c.content_type === "text/plain")) {
|
||||
return contents.find(c => c.content_type === "text/plain") || null;
|
||||
} else {
|
||||
return contents[0] || null;
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue