Harden milestone sharing and X publishing
This commit is contained in:
@@ -58,6 +58,22 @@ export type SocialMilestoneCard = {
|
||||
} | null;
|
||||
};
|
||||
|
||||
export function isCompleteSocialMilestoneCard(value: unknown): value is SocialMilestoneCard {
|
||||
if (!value || typeof value !== 'object') return false;
|
||||
const card = value as Partial<SocialMilestoneCard>;
|
||||
const trend = card.trend;
|
||||
return card.version === 'milestone-card-v2'
|
||||
&& typeof card.qrTitle === 'string'
|
||||
&& typeof card.totalScans === 'number'
|
||||
&& Number.isFinite(card.totalScans)
|
||||
&& typeof card.totalUniqueScans === 'number'
|
||||
&& Number.isFinite(card.totalUniqueScans)
|
||||
&& Boolean(trend)
|
||||
&& Array.isArray(trend?.points)
|
||||
&& trend.points.length >= 2
|
||||
&& trend.points.every(point => typeof point?.at === 'string' && typeof point?.total === 'number');
|
||||
}
|
||||
|
||||
export function socialLocale(value?: string | null): SocialLocale {
|
||||
return value === 'de' ? 'de' : 'en';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user