Remove Truth Social-specific features
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
@ -86,30 +86,12 @@ describe('normalizeAccount()', () => {
|
||||
expect(result.verified).toBe(false);
|
||||
});
|
||||
|
||||
it('normalizes a verified Truth Social user', async () => {
|
||||
const account = await import('soapbox/__fixtures__/realDonaldTrump.json');
|
||||
const result = normalizeAccount(account);
|
||||
expect(result.verified).toBe(true);
|
||||
});
|
||||
|
||||
it('normalizes Fedibird location', async () => {
|
||||
const account = await import('soapbox/__fixtures__/fedibird-account.json');
|
||||
const result = normalizeAccount(account);
|
||||
expect(result.location).toBe('Texas, USA');
|
||||
});
|
||||
|
||||
it('normalizes Truth Social location', async () => {
|
||||
const account = await import('soapbox/__fixtures__/truthsocial-account.json');
|
||||
const result = normalizeAccount(account);
|
||||
expect(result.location).toBe('Texas');
|
||||
});
|
||||
|
||||
it('normalizes Truth Social website', async () => {
|
||||
const account = await import('soapbox/__fixtures__/truthsocial-account.json');
|
||||
const result = normalizeAccount(account);
|
||||
expect(result.website).toBe('https://soapbox.pub');
|
||||
});
|
||||
|
||||
it('sets display_name from username', () => {
|
||||
const account = { username: 'alex' };
|
||||
const result = normalizeAccount(account);
|
||||
|
||||
@ -27,7 +27,6 @@ export const AccountRecord = ImmutableRecord({
|
||||
avatar_static: '',
|
||||
birthday: '',
|
||||
bot: false,
|
||||
chats_onboarded: true,
|
||||
created_at: '',
|
||||
discoverable: false,
|
||||
display_name: '',
|
||||
@ -52,7 +51,6 @@ export const AccountRecord = ImmutableRecord({
|
||||
uri: '',
|
||||
url: '',
|
||||
username: '',
|
||||
website: '',
|
||||
verified: false,
|
||||
|
||||
// Internal fields
|
||||
@ -147,7 +145,7 @@ const getTags = (account: ImmutableMap<string, any>): ImmutableList<any> => {
|
||||
return ImmutableList(ImmutableList.isList(tags) ? tags : []);
|
||||
};
|
||||
|
||||
/** Normalize Truth Social/Pleroma verified */
|
||||
/** Normalize Pleroma verified */
|
||||
const normalizeVerified = (account: ImmutableMap<string, any>) => {
|
||||
return account.update('verified', verified => {
|
||||
return [
|
||||
@ -164,7 +162,7 @@ const normalizeDonor = (account: ImmutableMap<string, any>) => {
|
||||
return account.setIn(['pleroma', 'tags'], updated);
|
||||
};
|
||||
|
||||
/** Normalize Fedibird/Truth Social/Pleroma location */
|
||||
/** Normalize Fedibird/Pleroma location */
|
||||
const normalizeLocation = (account: ImmutableMap<string, any>) => {
|
||||
return account.update('location', location => {
|
||||
return [
|
||||
@ -265,10 +263,9 @@ const normalizeDiscoverable = (account: ImmutableMap<string, any>) => {
|
||||
return account.set('discoverable', discoverable);
|
||||
};
|
||||
|
||||
/** Normalize message acceptance between Pleroma and Truth Social. */
|
||||
/** Normalize message acceptance. */
|
||||
const normalizeMessageAcceptance = (account: ImmutableMap<string, any>) => {
|
||||
const acceptance = Boolean(account.getIn(['pleroma', 'accepts_chat_messages']) || account.get('accepting_messages'));
|
||||
return account.set('accepts_chat_messages', acceptance);
|
||||
return account.set('accepts_chat_messages', account.getIn(['pleroma', 'accepts_chat_messages']));
|
||||
};
|
||||
|
||||
/** Normalize undefined/null birthday to empty string. */
|
||||
|
||||
@ -6,10 +6,8 @@ import {
|
||||
} from 'immutable';
|
||||
|
||||
import { normalizeAttachment } from 'soapbox/normalizers/attachment';
|
||||
import { emojiReactionSchema } from 'soapbox/schemas';
|
||||
import { filteredArray } from 'soapbox/schemas/utils';
|
||||
|
||||
import type { Attachment, Card, Emoji, EmojiReaction } from 'soapbox/types/entities';
|
||||
import type { Attachment, Card, Emoji } from 'soapbox/types/entities';
|
||||
|
||||
export const ChatMessageRecord = ImmutableRecord({
|
||||
account_id: '',
|
||||
@ -20,7 +18,6 @@ export const ChatMessageRecord = ImmutableRecord({
|
||||
created_at: '',
|
||||
emojis: ImmutableList<Emoji>(),
|
||||
expiration: null as number | null,
|
||||
emoji_reactions: null as readonly EmojiReaction[] | null,
|
||||
id: '',
|
||||
unread: false,
|
||||
deleting: false,
|
||||
@ -40,11 +37,6 @@ const normalizeMedia = (status: ImmutableMap<string, any>) => {
|
||||
}
|
||||
};
|
||||
|
||||
const normalizeChatMessageEmojiReaction = (chatMessage: ImmutableMap<string, any>) => {
|
||||
const emojiReactions = ImmutableList(chatMessage.get('emoji_reactions') || []);
|
||||
return chatMessage.set('emoji_reactions', filteredArray(emojiReactionSchema).parse(emojiReactions.toJS()));
|
||||
};
|
||||
|
||||
/** Rewrite `<p></p>` to empty string. */
|
||||
const fixContent = (chatMessage: ImmutableMap<string, any>) => {
|
||||
if (chatMessage.get('content') === '<p></p>') {
|
||||
@ -58,7 +50,6 @@ export const normalizeChatMessage = (chatMessage: Record<string, any>) => {
|
||||
return ChatMessageRecord(
|
||||
ImmutableMap(fromJS(chatMessage)).withMutations(chatMessage => {
|
||||
normalizeMedia(chatMessage);
|
||||
normalizeChatMessageEmojiReaction(chatMessage);
|
||||
fixContent(chatMessage);
|
||||
}),
|
||||
);
|
||||
|
||||
@ -22,7 +22,6 @@ export const NotificationRecord = ImmutableRecord({
|
||||
status: null as EmbeddedEntity<Status>,
|
||||
target: null as EmbeddedEntity<Account>, // move
|
||||
type: '',
|
||||
total_count: null as number | null, // grouped notifications
|
||||
});
|
||||
|
||||
const normalizeType = (notification: ImmutableMap<string, any>) => {
|
||||
|
||||
Reference in New Issue
Block a user