diff options
| author | tamaina <tamaina@hotmail.co.jp> | 2022-05-28 01:31:23 +0900 |
|---|---|---|
| committer | tamaina <tamaina@hotmail.co.jp> | 2022-05-28 01:31:23 +0900 |
| commit | fa99d9c6fee3a7d6f72e254e0aa55972cd6538fb (patch) | |
| tree | 43d941bbacc9cfaa911fc785fce0b34af4ef6fcc /packages/backend/src/services/fetch-instance-metadata.ts | |
| parent | Merge branch 'develop' into pizzax-indexeddb (diff) | |
| parent | fix(docs): correct information for drive upload (#8736) (diff) | |
| download | sharkey-fa99d9c6fee3a7d6f72e254e0aa55972cd6538fb.tar.gz sharkey-fa99d9c6fee3a7d6f72e254e0aa55972cd6538fb.tar.bz2 sharkey-fa99d9c6fee3a7d6f72e254e0aa55972cd6538fb.zip | |
Merge branch 'develop' into pizzax-indexeddb
Diffstat (limited to 'packages/backend/src/services/fetch-instance-metadata.ts')
| -rw-r--r-- | packages/backend/src/services/fetch-instance-metadata.ts | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/packages/backend/src/services/fetch-instance-metadata.ts b/packages/backend/src/services/fetch-instance-metadata.ts index d5294c5fe8..029c388dc2 100644 --- a/packages/backend/src/services/fetch-instance-metadata.ts +++ b/packages/backend/src/services/fetch-instance-metadata.ts @@ -1,5 +1,6 @@ import { DOMWindow, JSDOM } from 'jsdom'; import fetch from 'node-fetch'; +import tinycolor from 'tinycolor2'; import { getJson, getHtml, getAgentByUrl } from '@/misc/fetch.js'; import { Instance } from '@/models/entities/instance.js'; import { Instances } from '@/models/index.js'; @@ -208,16 +209,11 @@ async function fetchIconUrl(instance: Instance, doc: DOMWindow['document'] | nul } async function getThemeColor(doc: DOMWindow['document'] | null, manifest: Record<string, any> | null): Promise<string | null> { - if (doc) { - const themeColor = doc.querySelector('meta[name="theme-color"]')?.getAttribute('content'); + const themeColor = doc?.querySelector('meta[name="theme-color"]')?.getAttribute('content') || manifest?.theme_color; - if (themeColor) { - return themeColor; - } - } - - if (manifest) { - return manifest.theme_color; + if (themeColor) { + const color = new tinycolor(themeColor); + if (color.isValid()) return color.toHexString(); } return null; |