Remove Truth Social-specific features

Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
marcin mikołajczak
2024-04-28 14:50:23 +02:00
parent 5ba66f79ba
commit 0308aec65b
163 changed files with 312 additions and 5471 deletions

View File

@@ -97,7 +97,6 @@ const baseAccountSchema = z.object({
roles: filteredArray(roleSchema),
source: z.object({
approved: z.boolean().catch(true),
chats_onboarded: z.boolean().catch(true),
fields: filteredArray(fieldSchema),
note: z.string().catch(''),
pleroma: z.object({
@@ -114,7 +113,6 @@ const baseAccountSchema = z.object({
url: z.string().url(),
username: z.string().catch(''),
verified: z.boolean().catch(false),
website: z.string().catch(''),
});
type BaseAccount = z.infer<typeof baseAccountSchema>;

View File

@@ -3,8 +3,6 @@ import punycode from 'punycode';
import DOMPurify from 'isomorphic-dompurify';
import { z } from 'zod';
import { groupSchema } from './group';
const IDNA_PREFIX = 'xn--';
/**
@@ -17,7 +15,6 @@ const cardSchema = z.object({
blurhash: z.string().nullable().catch(null),
description: z.string().catch(''),
embed_url: z.string().url().catch(''),
group: groupSchema.nullable().catch(null), // TruthSocial
height: z.number().catch(0),
html: z.string().catch(''),
image: z.string().nullable().catch(null),

View File

@@ -3,7 +3,7 @@ import { z } from 'zod';
import { attachmentSchema } from './attachment';
import { cardSchema } from './card';
import { customEmojiSchema } from './custom-emoji';
import { contentSchema, emojiSchema, filteredArray } from './utils';
import { contentSchema, filteredArray } from './utils';
const chatMessageSchema = z.object({
account_id: z.string(),
@@ -13,8 +13,6 @@ const chatMessageSchema = z.object({
content: contentSchema,
created_at: z.string().datetime().catch(new Date().toUTCString()),
emojis: filteredArray(customEmojiSchema),
expiration: z.number().optional().catch(undefined),
emoji_reactions: z.array(emojiSchema).min(1).nullable().catch(null),
id: z.string(),
unread: z.coerce.boolean(),
deleting: z.coerce.boolean(),

View File

@@ -1,15 +0,0 @@
import z from 'zod';
const groupTagSchema = z.object({
id: z.string(),
name: z.string(),
groups: z.number().optional(),
url: z.string().optional(),
uses: z.number().optional(),
pinned: z.boolean().optional().catch(false),
visible: z.boolean().optional().default(true),
});
type GroupTag = z.infer<typeof groupTagSchema>;
export { groupTagSchema, type GroupTag };

View File

@@ -1,7 +0,0 @@
import { groupSchema } from './group';
test('groupSchema with a TruthSocial group', async () => {
const data = await import('soapbox/__fixtures__/group-truthsocial.json');
const group = groupSchema.parse(data);
expect(group.display_name_html).toEqual('PATRIOT PATRIOTS');
});

View File

@@ -6,7 +6,6 @@ import { unescapeHTML } from 'soapbox/utils/html';
import { customEmojiSchema } from './custom-emoji';
import { groupRelationshipSchema } from './group-relationship';
import { groupTagSchema } from './group-tag';
import { filteredArray, makeCustomEmojiMap } from './utils';
const avatarMissing = require('soapbox/assets/images/avatar-missing.png');
@@ -20,7 +19,6 @@ const groupSchema = z.object({
display_name: z.string().catch(''),
domain: z.string().catch(''),
emojis: filteredArray(customEmojiSchema),
group_visibility: z.string().catch(''), // TruthSocial
header: z.string().catch(headerMissing),
header_static: z.string().catch(''),
id: z.coerce.string(),
@@ -30,18 +28,15 @@ const groupSchema = z.object({
owner: z.object({ id: z.string() }),
note: z.string().transform(note => note === '<p></p>' ? '' : note).catch(''),
relationship: groupRelationshipSchema.nullable().catch(null), // Dummy field to be overwritten later
slug: z.string().catch(''), // TruthSocial
source: z.object({
note: z.string(),
}).optional(), // TruthSocial
statuses_visibility: z.string().catch('public'),
tags: z.array(groupTagSchema).catch([]),
uri: z.string().catch(''),
url: z.string().catch(''),
}).transform(group => {
group.avatar_static = group.avatar_static || group.avatar;
group.header_static = group.header_static || group.header;
group.locked = group.locked || group.group_visibility === 'members_only'; // TruthSocial
const customEmojiMap = makeCustomEmojiMap(group.emojis);
return {

View File

@@ -11,7 +11,6 @@ export { emojiReactionSchema, type EmojiReaction } from './emoji-reaction';
export { groupSchema, type Group } from './group';
export { groupMemberSchema, type GroupMember } from './group-member';
export { groupRelationshipSchema, type GroupRelationship } from './group-relationship';
export { groupTagSchema, type GroupTag } from './group-tag';
export { instanceSchema, type Instance } from './instance';
export { mentionSchema, type Mention } from './mention';
export { moderationLogEntrySchema, type ModerationLogEntry } from './moderation-log-entry';

View File

@@ -10,7 +10,6 @@ const baseNotificationSchema = z.object({
created_at: z.string().datetime().catch(new Date().toUTCString()),
id: z.string(),
type: z.string(),
total_count: z.number().optional().catch(undefined), // TruthSocial
});
const mentionNotificationSchema = baseNotificationSchema.extend({

View File

@@ -4,7 +4,6 @@ const baseRuleSchema = z.object({
id: z.string(),
text: z.string().catch(''),
hint: z.string().catch(''),
rule_type: z.enum(['account', 'content', 'group']).nullable().catch(null),
});
const ruleSchema = z.preprocess((data: any) => {