From d7161af8c6e0b7e7032d7d571830a8244a3492f2 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sun, 13 Aug 2023 20:57:32 +0900
Subject: [PATCH] Adjust card entity
---
megalodon/src/entities/card.ts | 18 ++++++++++--------
megalodon/src/friendica/api_client.ts | 17 ++++++++++++++++-
megalodon/src/friendica/entities/card.ts | 17 +++++++++--------
megalodon/src/mastodon/entities/card.ts | 18 ++++++++++--------
megalodon/src/pleroma/api_client.ts | 17 ++++++++++++++++-
megalodon/src/pleroma/entities/card.ts | 12 +++---------
6 files changed, 64 insertions(+), 35 deletions(-)
diff --git a/megalodon/src/entities/card.ts b/megalodon/src/entities/card.ts
index b39cbb8f2..1ef6f5e4d 100644
--- a/megalodon/src/entities/card.ts
+++ b/megalodon/src/entities/card.ts
@@ -4,13 +4,15 @@ namespace Entity {
title: string
description: string
type: 'link' | 'photo' | 'video' | 'rich'
- image?: string
- author_name?: string
- author_url?: string
- provider_name?: string
- provider_url?: string
- html?: string
- width?: number
- height?: number
+ image: string | null
+ author_name: string | null
+ author_url: string | null
+ provider_name: string | null
+ provider_url: string | null
+ html: string | null
+ width: number | null
+ height: number | null
+ embed_url: string | null
+ blurhash: string | null
}
}
diff --git a/megalodon/src/friendica/api_client.ts b/megalodon/src/friendica/api_client.ts
index c7e73f253..1f27fd6d2 100644
--- a/megalodon/src/friendica/api_client.ts
+++ b/megalodon/src/friendica/api_client.ts
@@ -578,7 +578,22 @@ namespace FriendicaAPI {
return a as MegalodonEntity.AsyncAttachment
}
}
- export const card = (c: Entity.Card): MegalodonEntity.Card => c
+ export const card = (c: Entity.Card): MegalodonEntity.Card => ({
+ url: c.url,
+ title: c.title,
+ description: c.description,
+ type: c.type,
+ image: c.image,
+ author_name: c.author_name,
+ author_url: c.author_url,
+ provider_name: c.provider_name,
+ provider_url: c.provider_url,
+ html: c.html,
+ width: c.width,
+ height: c.height,
+ embed_url: null,
+ blurhash: c.blurhash
+ })
export const context = (c: Entity.Context): MegalodonEntity.Context => ({
ancestors: Array.isArray(c.ancestors) ? c.ancestors.map(a => status(a)) : [],
descendants: Array.isArray(c.descendants) ? c.descendants.map(d => status(d)) : []
diff --git a/megalodon/src/friendica/entities/card.ts b/megalodon/src/friendica/entities/card.ts
index 48dda2a52..c23471983 100644
--- a/megalodon/src/friendica/entities/card.ts
+++ b/megalodon/src/friendica/entities/card.ts
@@ -4,13 +4,14 @@ namespace FriendicaEntity {
title: string
description: string
type: 'link' | 'photo' | 'video' | 'rich'
- image?: string
- author_name?: string
- author_url?: string
- provider_name?: string
- provider_url?: string
- html?: string
- width?: number
- height?: number
+ image: string | null
+ author_name: string
+ author_url: string
+ provider_name: string
+ provider_url: string
+ html: string
+ width: number
+ height: number
+ blurhash: string | null
}
}
diff --git a/megalodon/src/mastodon/entities/card.ts b/megalodon/src/mastodon/entities/card.ts
index e8ec0ec40..9058de7f7 100644
--- a/megalodon/src/mastodon/entities/card.ts
+++ b/megalodon/src/mastodon/entities/card.ts
@@ -4,13 +4,15 @@ namespace MastodonEntity {
title: string
description: string
type: 'link' | 'photo' | 'video' | 'rich'
- image?: string
- author_name?: string
- author_url?: string
- provider_name?: string
- provider_url?: string
- html?: string
- width?: number
- height?: number
+ image: string | null
+ author_name: string
+ author_url: string
+ provider_name: string
+ provider_url: string
+ html: string
+ width: number
+ height: number
+ embed_url: string
+ blurhash: string | null
}
}
diff --git a/megalodon/src/pleroma/api_client.ts b/megalodon/src/pleroma/api_client.ts
index 17a9567ad..99d964353 100644
--- a/megalodon/src/pleroma/api_client.ts
+++ b/megalodon/src/pleroma/api_client.ts
@@ -171,7 +171,22 @@ namespace PleromaAPI {
return a as MegalodonEntity.AsyncAttachment
}
}
- export const card = (c: Entity.Card): MegalodonEntity.Card => c
+ export const card = (c: Entity.Card): MegalodonEntity.Card => ({
+ url: c.url,
+ title: c.title,
+ description: c.description,
+ type: c.type,
+ image: c.image,
+ author_name: null,
+ author_url: null,
+ provider_name: c.provider_name,
+ provider_url: c.provider_url,
+ html: null,
+ width: null,
+ height: null,
+ embed_url: null,
+ blurhash: null
+ })
export const context = (c: Entity.Context): MegalodonEntity.Context => ({
ancestors: Array.isArray(c.ancestors) ? c.ancestors.map(a => status(a)) : [],
descendants: Array.isArray(c.descendants) ? c.descendants.map(d => status(d)) : []
diff --git a/megalodon/src/pleroma/entities/card.ts b/megalodon/src/pleroma/entities/card.ts
index 28d2013f4..9aca99a8c 100644
--- a/megalodon/src/pleroma/entities/card.ts
+++ b/megalodon/src/pleroma/entities/card.ts
@@ -4,14 +4,8 @@ namespace PleromaEntity {
title: string
description: string
type: 'link' | 'photo' | 'video' | 'rich'
- image?: string
- author_name?: string
- author_url?: string
- provider_name?: string
- provider_url?: string
- html?: string
- width?: number
- height?: number
- pleroma?: Object
+ image: string | null
+ provider_name: string
+ provider_url: string
}
}