Refactor codebase and standardize unstable prefix usage (#746)

### Description

This pull request standardizes the usage of Matrix event content keys by
replacing hardcoded property names and older constants with centralized,
unstable prefix constants imported from the `$unstable/prefixes` module.
This change improves maintainability and consistency across the
codebase, especially in handling experimental or non-standard Matrix
properties.

The most important changes are as follows:

##### Prefix Standardization and Centralization 
Replaced all hardcoded Matrix property names and older constants (e.g.,
`'com.beeper.per_message_profile'`, `'com.beeper.linkpreviews'`, etc.)
with corresponding constants from the `$unstable/prefixes` module
throughout the codebase, including message rendering, room creation,
user profiles, and input handling.

##### Message Content Handling
Updated all logic for reading, writing, and deleting Matrix event
content properties (e.g., per-message profiles, link previews, image
source packs, spoilers, blur hashes, forward metadata) to use the new
prefix constants, ensuring consistent access and mutation of event
content.

##### User Profile and Room Metadata
Updated user profile extended keys (such as bio, banner, pronouns,
timezone, animal identity) in `UserRoomProfile.tsx` to use the new
prefix constants, replacing all previous hardcoded or legacy key
strings.

##### Room Creation and Calls
Changed the room call state event type to use the new unstable prefix
constant in room creation utilities.

##### Code Clean-up
Removed now-unused imports of old constants from files where they have
been replaced with the new prefix-based constants.

These changes collectively improve the code's future compatibility with
evolving Matrix specifications and make it easier to update property
names as they stabilize.

#### Type of change

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

Shouldn't cause user facing changes

### Checklist:

- [ ] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings

### AI disclosure:

No AI usage
This commit is contained in:
7w1 authored and GitHub committed 2026-05-05 15:25:53 -05:00
commit 34fbfdacbe
33 files changed
+388 -172

No files matched your search

+2 -1
View File
@@ -11,6 +11,7 @@ import type { StateEvents } from '$types/matrix-sdk';
import { getViaServers } from '$plugins/via-servers';
import { getMxIdServer } from '$utils/mxIdHelper';
import { CreateRoomAccess } from './types';
import * as prefix from '$unstable/prefixes';
export const createRoomCreationContent = (
type: RoomType | undefined,
@@ -87,7 +88,7 @@ export const createRoomEncryptionState = () => ({
});
export const createRoomCallState = () => ({
type: 'org.matrix.msc3401.call',
type: prefix.MATRIX_UNSTABLE_ROOM_TYPE_CALL_PROPERTY_NAME,
state_key: '',
content: {},
});
+16 -11
View File
@@ -16,10 +16,7 @@ import type {
IVideoContent,
IVideoInfo,
} from '$types/matrix/common';
import {
MATRIX_SPOILER_PROPERTY_NAME,
MATRIX_SPOILER_REASON_PROPERTY_NAME,
} from '$types/matrix/common';
import * as prefix from '$unstable/prefixes';
import { FALLBACK_MIMETYPE, getBlobSafeMimeType } from '$utils/mimeTypes';
import { parseGeoUri, scaleYDimension } from '$utils/common';
import { useSetting } from '$state/hooks/settings';
@@ -133,7 +130,9 @@ const getUrlsFromContent = (
urls = urls.filter((url) => safeUrlsSet.has(url) && !url.startsWith(MATRIX_TO_BASE));
}
let bundleContent = content['com.beeper.linkpreviews'] as BundleContent[];
let bundleContent = content[
prefix.MATRIX_UNSTABLE_EMBEDDED_LINK_PREVIEW_PROPERTY_NAME
] as BundleContent[];
try {
bundleContent = bundleContent?.filter((bundle) => !!urls?.includes(bundle.matched_url));
if (renderUrlsPreview && bundleContent)
@@ -170,7 +169,7 @@ export function MText({
);
const isForwarded = useMemo(() => {
const forwardMeta = content['moe.sable.message.forward'];
const forwardMeta = content[prefix.MATRIX_SABLE_UNSTABLE_MESSAGE_FORWARD_META_PROPERTY_NAME];
return typeof forwardMeta === 'object';
}, [content]);
@@ -205,7 +204,13 @@ export function MText({
const { urls, bundleContent } = getUrlsFromContent(content, renderUrlsPreview);
if ((content['com.beeper.per_message_profile'] as PerMessageProfileBeeperFormat)?.has_fallback) {
if (
(
content[
prefix.MATRIX_UNSTABLE_PER_MESSAGE_PROFILE_PROPERTY_NAME
] as PerMessageProfileBeeperFormat
)?.has_fallback
) {
// unwrap per-message profile fallback if present
return (
<>
@@ -428,8 +433,8 @@ export function MImage({ content, renderImageContent, outlined }: MImageProps) {
mimeType: imgInfo?.mimetype,
url: mxcUrl,
encInfo: content.file,
markedAsSpoiler: content[MATRIX_SPOILER_PROPERTY_NAME],
spoilerReason: content[MATRIX_SPOILER_REASON_PROPERTY_NAME],
markedAsSpoiler: content[prefix.MATRIX_UNSTABLE_SPOILER_PROPERTY_NAME],
spoilerReason: content[prefix.MATRIX_UNSTABLE_SPOILER_REASON_PROPERTY_NAME],
})}
</AttachmentBox>
</Attachment>
@@ -500,8 +505,8 @@ export function MVideo({ content, renderAsFile, renderVideoContent, outlined }:
mimeType: safeMimeType,
url: mxcUrl,
encInfo: content.file,
markedAsSpoiler: content[MATRIX_SPOILER_PROPERTY_NAME],
spoilerReason: content[MATRIX_SPOILER_REASON_PROPERTY_NAME],
markedAsSpoiler: content[prefix.MATRIX_UNSTABLE_SPOILER_PROPERTY_NAME],
spoilerReason: content[prefix.MATRIX_UNSTABLE_SPOILER_REASON_PROPERTY_NAME],
})}
</AttachmentBox>
</Attachment>
@@ -25,7 +25,6 @@ import { BlurhashCanvas } from 'react-blurhash';
import FocusTrap from 'focus-trap-react';
import type { EncryptedAttachmentInfo } from 'browser-encrypt-attachment';
import type { IImageInfo } from '$types/matrix/common';
import { MATRIX_BLUR_HASH_PROPERTY_NAME } from '$types/matrix/common';
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
import { useMatrixClient } from '$hooks/useMatrixClient';
import { bytesToSize } from '$utils/common';
@@ -36,6 +35,7 @@ import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
import { ModalWide } from '$styles/Modal.css';
import { validBlurHash } from '$utils/blurHash';
import * as css from './style.css';
import { MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME } from '../../../../unstable/prefixes';
type RenderViewerProps = {
src: string;
@@ -84,7 +84,7 @@ export const ImageContent = as<'div', ImageContentProps>(
) => {
const mx = useMatrixClient();
const useAuthentication = useMediaAuthentication();
const blurHash = validBlurHash(info?.[MATRIX_BLUR_HASH_PROPERTY_NAME]);
const blurHash = validBlurHash(info?.[MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME]);
const [load, setLoad] = useState(false);
const [error, setError] = useState(false);
@@ -20,7 +20,6 @@ import classNames from 'classnames';
import { BlurhashCanvas } from 'react-blurhash';
import type { EncryptedAttachmentInfo } from 'browser-encrypt-attachment';
import type { IThumbnailContent, IVideoInfo } from '$types/matrix/common';
import { MATRIX_BLUR_HASH_PROPERTY_NAME } from '$types/matrix/common';
import { useMatrixClient } from '$hooks/useMatrixClient';
import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
import { bytesToSize, millisecondsToMinutesAndSeconds } from '$utils/common';
@@ -28,6 +27,7 @@ import { decryptFile, downloadEncryptedMedia, downloadMedia, mxcUrlToHttp } from
import { useMediaAuthentication } from '$hooks/useMediaAuthentication';
import { validBlurHash } from '$utils/blurHash';
import * as css from './style.css';
import { MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME } from '../../../../unstable/prefixes';
type RenderVideoProps = {
title: string;
@@ -69,7 +69,7 @@ export const VideoContent = as<'div', VideoContentProps>(
) => {
const mx = useMatrixClient();
const useAuthentication = useMediaAuthentication();
const blurHash = validBlurHash(info.thumbnail_info?.[MATRIX_BLUR_HASH_PROPERTY_NAME]);
const blurHash = validBlurHash(info.thumbnail_info?.[MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME]);
const [load, setLoad] = useState(false);
const [error, setError] = useState(false);
@@ -27,6 +27,7 @@ import { sanitizeCustomHtml, sanitizeText } from '$utils/sanitize';
import { createDebugLogger } from '$utils/debugLogger';
import * as Sentry from '@sentry/react';
import { isRoomPrivate } from '$utils/roomVisibility';
import * as prefix from '$unstable/prefixes';
const debugLog = createDebugLogger('MessageForward');
@@ -203,7 +204,7 @@ export function MessageForwardInternal({
const baseContent = { ...mEvent.getContent() };
delete baseContent['m.relates_to']; // remove relations from the forwarded message
delete baseContent['m.mentions']; // remove mentions from forwarded message
delete baseContent['com.beeper.per_message_profile']; // remove per-message profile as that could confuse clients in the target room
delete baseContent[prefix.MATRIX_UNSTABLE_PER_MESSAGE_PROFILE_PROPERTY_NAME]; // remove per-message profile as that could confuse clients in the target room
let content;
// handle privacy stuff
if (isRoomPrivate(mx, room)) {
@@ -212,13 +213,13 @@ export function MessageForwardInternal({
content = {
...baseContent,
...forwardedTextContent,
'moe.sable.message.forward': {
[prefix.MATRIX_SABLE_UNSTABLE_MESSAGE_FORWARD_META_PROPERTY_NAME]: {
v: 1,
is_forwarded: true,
original_timestamp: mEvent.getTs(),
original_event_private: true,
} satisfies ForwardMeta,
'com.famedly.app.forwarded': {
[prefix.MATRIX_UNSTABLE_MESSAGE_FORWARD_META_PROPERTY_NAME]: {
origin_server_ts: mEvent.getTs(),
} satisfies MSC2723ForwardMeta,
};
@@ -226,7 +227,7 @@ export function MessageForwardInternal({
content = {
...baseContent,
...forwardedTextContent,
'moe.sable.message.forward': {
[prefix.MATRIX_SABLE_UNSTABLE_MESSAGE_FORWARD_META_PROPERTY_NAME]: {
v: 1,
is_forwarded: true,
original_timestamp: mEvent.getTs(),
@@ -234,7 +235,7 @@ export function MessageForwardInternal({
original_event_id: eventId,
original_event_private: false,
} satisfies ForwardMeta,
'com.famedly.app.forwarded': {
[prefix.MATRIX_UNSTABLE_MESSAGE_FORWARD_META_PROPERTY_NAME]: {
event_id: eventId,
room_id: room.roomId,
origin_server_ts: mEvent.getTs(),
@@ -5,11 +5,11 @@ import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback';
import { useSetting } from '$state/hooks/settings';
import { settingsAtom } from '$state/settings';
import { encodeBlurHash } from '$utils/blurHash';
import { MATRIX_BLUR_HASH_PROPERTY_NAME } from '$types/matrix/common';
import { Attachment, AttachmentBox, AttachmentHeader } from '../message/attachment';
import { Image } from '../media';
import { UrlPreview } from './UrlPreview';
import { VideoContent } from '../message';
import { MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME } from '../../../unstable/prefixes';
interface OEmbed {
type: 'photo' | 'video' | 'link' | 'rich';
@@ -114,7 +114,7 @@ export const YoutubeElement = as<'div', YoutubeElementProps>(({ videoInfo, embed
mimeType="fake"
url={videoUrl}
info={{
thumbnail_info: { [MATRIX_BLUR_HASH_PROPERTY_NAME]: blurHash },
thumbnail_info: { [MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME]: blurHash },
}}
renderThumbnail={() => (
<Image
@@ -59,20 +59,21 @@ import { IgnoredUserAlert, MutualRoomsChip, OptionsChip, ServerChip, ShareChip }
import { UserHero, UserHeroName } from './UserHero';
import { KnownMembership } from '$types/matrix-sdk';
import * as css from './styles.css';
import * as prefix from '$unstable/prefixes';
const KNOWN_KEYS = new Set([
'moe.sable.app.bio',
'chat.commet.profile_bio',
'chat.commet.profile_banner',
'chat.commet.profile_status',
'io.fsky.nyx.pronouns',
'us.cloke.msc4175.tz',
'm.tz',
'moe.sable.app.name_color',
prefix.MATRIX_SABLE_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME,
prefix.MATRIX_COMMET_UNSTABLE_PROFILE_BIO_PROPERTY_NAME,
prefix.MATRIX_UNSTABLE_PROFILE_BANNER_PROPERTY_NAME,
prefix.MATRIX_COMMET_UNSTABLE_PROFILE_STATUS_PROPERTY_NAME,
prefix.MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME,
prefix.MATRIX_UNSTABLE_PROFILE_TIMEZONE_PROPERTY_NAME,
prefix.MATRIX_STABLE_PROFILE_TIMEZONE_PROPERTY_NAME,
prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_PROPERTY_NAME,
'avatar_url',
'displayname',
'kitty.meow.has_cats',
'kitty.meow.is_cat',
prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_IS_CAT_PROPERTY_NAME,
prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_HAS_CAT_PROPERTY_NAME,
]);
type UserExtendedSectionProps = {
@@ -142,8 +143,8 @@ function UserExtendedSection({
const bioContent = useMemo(() => {
let rawBio =
profile.extended?.['moe.sable.app.bio'] ||
profile.extended?.['chat.commet.profile_bio'] ||
profile.extended?.[prefix.MATRIX_SABLE_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME] ||
profile.extended?.[prefix.MATRIX_COMMET_UNSTABLE_PROFILE_BIO_PROPERTY_NAME] ||
profile.bio;
if (!rawBio) return null;
+25 -31
View File
@@ -128,7 +128,6 @@ import { getSupportedAudioExtension } from '$plugins/voice-recorder-kit/supporte
import { sanitizeText } from '$utils/sanitize';
import { PKitCommandMessageHandler } from '$plugins/pluralkit-handler/PKitCommandMessageHandler';
import { PKitProxyMessageHandler } from '$plugins/pluralkit-handler/PKitProxyMessageHandler';
import { MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME } from '$types/matrix/common';
import type { IGenericMSC4459, MSC4459ImagePackReference } from '$types/matrix/common';
import {
getImagePackReferencesForMxc,
@@ -152,6 +151,7 @@ import type {
AudioRecordingCompletePayload,
} from './AudioMessageRecorder';
import { AudioMessageRecorder } from './AudioMessageRecorder';
import * as prefix from '$unstable/prefixes';
// Returns the event ID of the most recent non-reaction/non-edit event in a thread,
// falling back to the thread root if no replies exist yet.
@@ -546,10 +546,8 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
// We intentionally mutate the objects here to avoid unnecessary copying
// mutating should be unproblematic here, since contents isn't a react component,
// or used for rendering
c['com.beeper.per_message_profile'] = convertPerMessageProfileToBeeperFormat(
perMessageProfile,
false
);
c[prefix.MATRIX_UNSTABLE_PER_MESSAGE_PROFILE_PROPERTY_NAME] =
convertPerMessageProfileToBeeperFormat(perMessageProfile, false);
});
}
@@ -827,11 +825,16 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
}
content['m.mentions'] = getMentionContent(Array.from(mentionData.users), mentionData.room);
content[MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME] = imagePacksUsedRef.current.toJSON();
content[prefix.MATRIX_UNSTABLE_IMAGE_SOURCE_PACK_PROPERTY_NAME] =
imagePacksUsedRef.current.toJSON();
const links = getLinks(serializedChildren);
content['com.beeper.linkpreviews'] = [];
links?.forEach((link) => content['com.beeper.linkpreviews'].push({ matched_url: link }));
content[prefix.MATRIX_UNSTABLE_EMBEDDED_LINK_PREVIEW_PROPERTY_NAME] = [];
links?.forEach((link) =>
content[prefix.MATRIX_UNSTABLE_EMBEDDED_LINK_PREVIEW_PROPERTY_NAME].push({
matched_url: link,
})
);
if (replyDraft || !customHtmlEqualsPlainText(formattedBody, body)) {
content.format = 'org.matrix.custom.html';
@@ -851,18 +854,19 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
if (pmpProxyingEnable && pluralkitProxyMessageHandler.isAProxiedMessage(plainText))
plainText = pluralkitProxyMessageHandler.stripProxyFromMessage(plainText) ?? plainText;
if (perMessageProfile) {
content['com.beeper.per_message_profile'] = convertPerMessageProfileToBeeperFormat(
perMessageProfile,
perMessageProfile.name.trim() !== ''
);
content[prefix.MATRIX_UNSTABLE_PER_MESSAGE_PROFILE_PROPERTY_NAME] =
convertPerMessageProfileToBeeperFormat(
perMessageProfile,
perMessageProfile.name.trim() !== ''
);
if (perMessageProfile.name.trim() !== '') {
// if a per-message profile is used, it must per spec include a fallback
const prefix = `${perMessageProfile.name}: `;
const pmpPrefix = `${perMessageProfile.name}: `;
if (!content.body.startsWith(prefix)) {
if (!content.body.startsWith(pmpPrefix)) {
// to prevent double-prefixing when the fallback is already present
content.body = prefix + content.body;
content.body = pmpPrefix + content.body;
}
/**
@@ -1171,12 +1175,8 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
};
// add the image pack reference
content[MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME] = getImagePackReferencesForMxcWrappedInMap(
mxc,
mx,
ImageUsage.Sticker,
room
);
content[prefix.MATRIX_UNSTABLE_IMAGE_SOURCE_PACK_PROPERTY_NAME] =
getImagePackReferencesForMxcWrappedInMap(mxc, mx, ImageUsage.Sticker, room);
/**
* the currently with the room associated per-message profile, if any, so that it can be included in the message content when sending.
@@ -1186,17 +1186,11 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
const perMessageProfile = await getCurrentlyUsedPerMessageProfileForRoom(mx, roomId);
if (perMessageProfile) {
content['com.beeper.per_message_profile'] = convertPerMessageProfileToBeeperFormat(
perMessageProfile,
false
);
content[prefix.MATRIX_UNSTABLE_PER_MESSAGE_PROFILE_PROPERTY_NAME] =
convertPerMessageProfileToBeeperFormat(perMessageProfile, false);
}
content[MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME] = getImagePackReferencesForMxcWrappedInMap(
mxc,
mx,
ImageUsage.Sticker,
room
);
content[prefix.MATRIX_UNSTABLE_IMAGE_SOURCE_PACK_PROPERTY_NAME] =
getImagePackReferencesForMxcWrappedInMap(mxc, mx, ImageUsage.Sticker, room);
if (replyDraft) {
content['m.relates_to'] = getReplyContent(replyDraft, room);
+8 -5
View File
@@ -2,7 +2,6 @@ import type { IContent, MatrixClient } from '$types/matrix-sdk';
import { MsgType } from '$types/matrix-sdk';
import to from 'await-to-js';
import type { IThumbnailContent } from '$types/matrix/common';
import { MATRIX_BLUR_HASH_PROPERTY_NAME, MATRIX_SPOILER_PROPERTY_NAME } from '$types/matrix/common';
import {
getImageFileUrl,
getThumbnail,
@@ -16,6 +15,10 @@ import type { TUploadItem } from '$state/room/roomInputDrafts';
import { encodeBlurHash } from '$utils/blurHash';
import { scaleYDimension } from '$utils/common';
import { createLogger } from '$utils/debug';
import {
MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME,
MATRIX_UNSTABLE_SPOILER_PROPERTY_NAME,
} from '../../../unstable/prefixes';
const log = createLogger('msgContent');
@@ -57,14 +60,14 @@ export const getImageMsgContent = async (
msgtype: MsgType.Image,
filename: file.name,
body: file.name,
[MATRIX_SPOILER_PROPERTY_NAME]: metadata.markedAsSpoiler,
[MATRIX_UNSTABLE_SPOILER_PROPERTY_NAME]: metadata.markedAsSpoiler,
};
if (imgEl) {
const blurHash = encodeBlurHash(imgEl, 512, scaleYDimension(imgEl.width, 512, imgEl.height));
content.info = {
...getImageInfo(imgEl, file),
[MATRIX_BLUR_HASH_PROPERTY_NAME]: blurHash,
[MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME]: blurHash,
};
}
if (encInfo) {
@@ -97,7 +100,7 @@ export const getVideoMsgContent = async (
msgtype: MsgType.Video,
filename: file.name,
body: file.name,
[MATRIX_SPOILER_PROPERTY_NAME]: metadata.markedAsSpoiler,
[MATRIX_UNSTABLE_SPOILER_PROPERTY_NAME]: metadata.markedAsSpoiler,
};
if (videoEl) {
const [thumbError, thumbContent] = await to(
@@ -109,7 +112,7 @@ export const getVideoMsgContent = async (
)
);
if (thumbContent && thumbContent.thumbnail_info) {
thumbContent.thumbnail_info[MATRIX_BLUR_HASH_PROPERTY_NAME] = encodeBlurHash(
thumbContent.thumbnail_info[MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME] = encodeBlurHash(
videoEl,
512,
scaleYDimension(videoEl.videoWidth, 512, videoEl.videoHeight)
@@ -9,6 +9,7 @@ import { Box, Switch, Text } from 'folds';
import { useSetAtom } from 'jotai';
import { useCallback } from 'react';
import { SequenceCardStyle } from '../styles.css';
import * as prefix from '$unstable/prefixes';
type AnimalCosmeticsProps = {
profile: UserProfile;
@@ -54,7 +55,12 @@ export function AnimalCosmetics({ profile, userId }: Readonly<AnimalCosmeticsPro
<Switch
variant="Primary"
value={isCat}
onChange={() => handleSaveField('kitty.meow.is_cat', !isCat)}
onChange={() =>
handleSaveField(
prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_IS_CAT_PROPERTY_NAME,
!isCat
)
}
/>
}
/>
@@ -68,7 +74,12 @@ export function AnimalCosmetics({ profile, userId }: Readonly<AnimalCosmeticsPro
<Switch
variant="Primary"
value={hasCats}
onChange={() => handleSaveField('kitty.meow.has_cats', !hasCats)}
onChange={() =>
handleSaveField(
prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_HAS_CAT_PROPERTY_NAME,
!hasCats
)
}
/>
}
/>
+43 -20
View File
@@ -50,6 +50,7 @@ import { BioEditor } from './BioEditor';
import { NameColorEditor } from './NameColorEditor';
import { StatusEditor } from './StatusEditor';
import { AnimalCosmetics } from './AnimalCosmetics';
import * as prefix from '$unstable/prefixes';
type PronounSet = {
summary: string;
@@ -258,7 +259,7 @@ function ProfileBanner({ profile }: Readonly<Pick<ProfileProps, 'profile'>>) {
if (imageFileURL) setStagedUrl(imageFileURL);
mx.setExtendedProfileProperty?.('chat.commet.profile_banner', mxc);
mx.setExtendedProfileProperty?.(prefix.MATRIX_UNSTABLE_PROFILE_BANNER_PROPERTY_NAME, mxc);
setImageFile(undefined);
},
[mx, imageFileURL]
@@ -269,7 +270,10 @@ function ProfileBanner({ profile }: Readonly<Pick<ProfileProps, 'profile'>>) {
setStagedUrl(undefined);
setImageFile(undefined);
await mx.setExtendedProfileProperty?.('chat.commet.profile_banner', null);
await mx.setExtendedProfileProperty?.(
prefix.MATRIX_UNSTABLE_PROFILE_BANNER_PROPERTY_NAME,
null
);
setAlertRemove(false);
};
@@ -539,9 +543,13 @@ function ProfileExtended({ profile, userId }: Readonly<ProfileProps>) {
focusId="name-color"
current={
profile.nameColor ||
(profile.extended?.['moe.sable.app.name_color'] as string | undefined)
(profile.extended?.[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_PROPERTY_NAME] as
| string
| undefined)
}
onSave={(color) =>
handleSaveField(prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_PROPERTY_NAME, color)
}
onSave={(color) => handleSaveField('moe.sable.app.name_color', color)}
/>
<NameColorEditor
title="Dark theme Global Name Color"
@@ -549,9 +557,13 @@ function ProfileExtended({ profile, userId }: Readonly<ProfileProps>) {
focusId="name-color-dark-theme"
current={
profile.nameColorDark ||
(profile.extended?.['moe.sable.app.name_color_dark_theme'] as string | undefined)
(profile.extended?.[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_DARK_PROPERTY_NAME] as
| string
| undefined)
}
onSave={(color) =>
handleSaveField(prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_DARK_PROPERTY_NAME, color)
}
onSave={(color) => handleSaveField('moe.sable.app.name_color_dark_theme', color)}
/>
<NameColorEditor
title="Light theme Global Name Color"
@@ -559,9 +571,13 @@ function ProfileExtended({ profile, userId }: Readonly<ProfileProps>) {
focusId="name-color-light-theme"
current={
profile.nameColorLight ||
(profile.extended?.['moe.sable.app.name_color_light_theme'] as string | undefined)
(profile.extended?.[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_LIGHT_PROPERTY_NAME] as
| string
| undefined)
}
onSave={(color) =>
handleSaveField(prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_LIGHT_PROPERTY_NAME, color)
}
onSave={(color) => handleSaveField('moe.sable.app.name_color_light_theme', color)}
/>
</SequenceCard>
<SequenceCard
@@ -573,7 +589,7 @@ function ProfileExtended({ profile, userId }: Readonly<ProfileProps>) {
<PronounEditor
title="Pronouns"
current={pronouns}
onSave={(p) => handleSaveField('io.fsky.nyx.pronouns', p)}
onSave={(p) => handleSaveField(prefix.MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME, p)}
/>
</SequenceCard>
<SequenceCard
@@ -585,8 +601,8 @@ function ProfileExtended({ profile, userId }: Readonly<ProfileProps>) {
<TimezoneEditor
current={profile.timezone}
onSave={(tz) => {
handleSaveField('us.cloke.msc4175.tz', tz);
handleSaveField('m.tz', tz);
handleSaveField(prefix.MATRIX_UNSTABLE_PROFILE_TIMEZONE_PROPERTY_NAME, tz);
handleSaveField(prefix.MATRIX_STABLE_PROFILE_TIMEZONE_PROPERTY_NAME, tz);
}}
/>
</SequenceCard>
@@ -598,17 +614,24 @@ function ProfileExtended({ profile, userId }: Readonly<ProfileProps>) {
>
<BioEditor
value={
(profile.extended?.['gay.fomx.biography'] as MSC4440Bio | undefined)?.['m.text']?.[0]
?.body ||
(profile.extended?.['moe.sable.app.bio'] as string | undefined) ||
(profile.extended?.['chat.commet.profile_bio'] as string | undefined) ||
(
profile.extended?.[prefix.MATRIX_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME] as
| MSC4440Bio
| undefined
)?.['m.text']?.[0]?.body ||
(profile.extended?.[prefix.MATRIX_SABLE_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME] as
| string
| undefined) ||
(profile.extended?.[prefix.MATRIX_COMMET_UNSTABLE_PROFILE_BIO_PROPERTY_NAME] as
| string
| undefined) ||
profile.bio
}
onSave={(htmlBio, plainTextBio) => {
handleSaveField('moe.sable.app.bio', htmlBio);
handleSaveField(prefix.MATRIX_SABLE_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME, htmlBio);
// MSC4440
handleSaveField('gay.fomx.biography', {
handleSaveField(prefix.MATRIX_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME, {
'm.text': [
{
body: htmlBio,
@@ -621,7 +644,7 @@ function ProfileExtended({ profile, userId }: Readonly<ProfileProps>) {
} satisfies MSC4440Bio);
const cleanedHtml = htmlBio.replaceAll('<br/></blockquote>', '</blockquote>');
handleSaveField('chat.commet.profile_bio', {
handleSaveField(prefix.MATRIX_COMMET_UNSTABLE_PROFILE_BIO_PROPERTY_NAME, {
format: 'org.matrix.custom.html',
formatted_body: cleanedHtml,
});
@@ -640,7 +663,7 @@ function ProfileExtended({ profile, userId }: Readonly<ProfileProps>) {
focusId="user-hero-color"
current={profile?.heroColorScheme?.color}
onSave={(color) =>
handleSaveField('chat.commet.profile_color_scheme', {
handleSaveField(prefix.MATRIX_COMMET_UNSTABLE_PROFILE_COLOR_SCHEME_PROPERTY_NAME, {
color,
brightness: color ? profile?.heroColorScheme?.brightness : null,
})
@@ -649,7 +672,7 @@ function ProfileExtended({ profile, userId }: Readonly<ProfileProps>) {
<IconButton
variant={profile?.heroColorScheme?.brightness === 'dark' ? 'Primary' : 'Warning'}
onClick={() =>
handleSaveField('chat.commet.profile_color_scheme', {
handleSaveField(prefix.MATRIX_COMMET_UNSTABLE_PROFILE_COLOR_SCHEME_PROPERTY_NAME, {
color: profile?.heroColorScheme?.color,
brightness: profile?.heroColorScheme?.brightness === 'dark' ? 'light' : 'dark',
})
+13 -10
View File
@@ -9,6 +9,7 @@ import { ReactEditor } from 'slate-react';
import { getMxIdLocalPart, toggleReaction } from '$utils/matrix';
import { getMemberDisplayName, getEditedEvent } from '$utils/room';
import { createMentionElement, moveCursor } from '$components/editor';
import * as prefix from '$unstable/prefixes';
export interface UseTimelineActionsOptions {
room: Room;
@@ -68,18 +69,20 @@ export function useTimelineActions({
const cleanExtended = cachedData?.extended ? { ...cachedData.extended } : undefined;
if (cleanExtended) {
delete cleanExtended['io.fsky.nyx.pronouns'];
delete cleanExtended['moe.sable.app.bio'];
delete cleanExtended['chat.commet.profile_bio'];
delete cleanExtended['chat.commet.profile_status'];
delete cleanExtended['us.cloke.msc4175.tz'];
delete cleanExtended['m.tz'];
delete cleanExtended['chat.commet.profile_banner'];
delete cleanExtended['moe.sable.app.name_color'];
delete cleanExtended[prefix.MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME];
delete cleanExtended[prefix.MATRIX_SABLE_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME];
delete cleanExtended[prefix.MATRIX_COMMET_UNSTABLE_PROFILE_BIO_PROPERTY_NAME];
delete cleanExtended[prefix.MATRIX_COMMET_UNSTABLE_PROFILE_STATUS_PROPERTY_NAME];
delete cleanExtended[prefix.MATRIX_UNSTABLE_PROFILE_TIMEZONE_PROPERTY_NAME];
delete cleanExtended[prefix.MATRIX_STABLE_PROFILE_TIMEZONE_PROPERTY_NAME];
delete cleanExtended[prefix.MATRIX_UNSTABLE_PROFILE_BANNER_PROPERTY_NAME];
delete cleanExtended[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_PROPERTY_NAME];
delete cleanExtended[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_DARK_PROPERTY_NAME];
delete cleanExtended[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_LIGHT_PROPERTY_NAME];
delete cleanExtended.avatar_url;
delete cleanExtended.displayname;
delete cleanExtended['kitty.meow.has_cats'];
delete cleanExtended['kitty.meow.is_cat'];
delete cleanExtended[prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_HAS_CAT_PROPERTY_NAME];
delete cleanExtended[prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_IS_CAT_PROPERTY_NAME];
}
openUserRoomProfile(
+6 -4
View File
@@ -3,6 +3,7 @@ import type { AccountDataCompatVersion } from '$types/matrix/accountData';
import type { PronounSet } from '$utils/pronouns';
import type { MatrixClient } from '$types/matrix-sdk';
import { CustomAccountDataEvent } from '$types/matrix/accountData';
import { MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME } from '$unstable/prefixes';
const ACCOUNT_DATA_PREFIX = CustomAccountDataEvent.SablePerProfileMessageProfiles;
@@ -53,7 +54,7 @@ export type PerMessageProfileBeeperFormat = {
/**
* using the unstable prefix for pronouns, under which it is also stored in profiles
*/
'io.fsky.nyx.pronouns'?: PronounSet[];
[MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME]?: PronounSet[];
has_fallback?: boolean;
};
@@ -72,14 +73,15 @@ export function convertPerMessageProfileToBeeperFormat(
id: profile.id,
displayname: profile.name,
avatar_url: profile.avatarUrl,
'io.fsky.nyx.pronouns': profile.pronouns,
[MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME]: profile.pronouns,
has_fallback,
};
// delete empty fields
// to-do maybe find a better way of doing it
if (!profile.name || profile?.name.trim().length === 0) delete beeperPMP.displayname;
if (!profile.avatarUrl) delete beeperPMP.avatar_url;
if (!profile.pronouns || profile.pronouns?.length === 0) delete beeperPMP['io.fsky.nyx.pronouns'];
if (!profile.pronouns || profile.pronouns?.length === 0)
delete beeperPMP[MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME];
if (!has_fallback) delete beeperPMP.has_fallback;
return beeperPMP;
}
@@ -99,7 +101,7 @@ export function convertBeeperFormatToOurPerMessageProfile(
id: beeperProfile.id,
name: beeperProfile.displayname ?? '',
avatarUrl: beeperProfile.avatar_url,
pronouns: beeperProfile['io.fsky.nyx.pronouns'],
pronouns: beeperProfile[MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME],
};
}
+39 -27
View File
@@ -14,6 +14,7 @@ import type { PronounSet } from '$utils/pronouns';
import { useMatrixClient } from './useMatrixClient';
import { ThemeKind, useActiveTheme } from './useTheme';
import { CustomStateEvent } from '$types/matrix/room';
import * as prefix from '$unstable/prefixes';
const inFlightProfiles = new Map<string, Promise<Record<string, unknown>>>();
@@ -40,24 +41,26 @@ export type UserProfile = {
};
const normalizeInfo = (info: Record<string, unknown>): UserProfile => {
const msc4440Bio = info['gay.fomx.biography'] as MSC4440Bio | undefined;
const msc4440Bio = info[prefix.MATRIX_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME] as
| MSC4440Bio
| undefined;
const knownKeys = new Set([
'avatar_url',
'displayname',
'io.fsky.nyx.pronouns',
'us.cloke.msc4175.tz',
'm.tz',
'moe.sable.app.bio',
'chat.commet.profile_bio',
'gay.fomx.biography',
'chat.commet.profile_banner',
'chat.commet.profile_status',
'moe.sable.app.name_color',
'moe.sable.app.name_color_dark_theme',
'moe.sable.app.name_color_light_theme',
'chat.commet.profile_color_scheme',
'kitty.meow.has_cats',
'kitty.meow.is_cat',
prefix.MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME,
prefix.MATRIX_STABLE_PROFILE_TIMEZONE_PROPERTY_NAME,
prefix.MATRIX_UNSTABLE_PROFILE_TIMEZONE_PROPERTY_NAME,
prefix.MATRIX_SABLE_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME,
prefix.MATRIX_COMMET_UNSTABLE_PROFILE_BIO_PROPERTY_NAME,
prefix.MATRIX_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME,
prefix.MATRIX_UNSTABLE_PROFILE_BANNER_PROPERTY_NAME,
prefix.MATRIX_COMMET_UNSTABLE_PROFILE_STATUS_PROPERTY_NAME,
prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_PROPERTY_NAME,
prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_LIGHT_PROPERTY_NAME,
prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_DARK_PROPERTY_NAME,
prefix.MATRIX_COMMET_UNSTABLE_PROFILE_COLOR_SCHEME_PROPERTY_NAME,
prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_HAS_CAT_PROPERTY_NAME,
prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_IS_CAT_PROPERTY_NAME,
]);
const extended: Record<string, unknown> = {};
@@ -70,20 +73,29 @@ const normalizeInfo = (info: Record<string, unknown>): UserProfile => {
return {
avatarUrl: info.avatar_url as string | undefined,
displayName: info.displayname as string | undefined,
pronouns: info['io.fsky.nyx.pronouns'] as PronounSet[] | undefined,
timezone: (info['us.cloke.msc4175.tz'] || info['m.tz']) as string | undefined,
pronouns: info[prefix.MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME] as
| PronounSet[]
| undefined,
timezone: (info[prefix.MATRIX_UNSTABLE_PROFILE_TIMEZONE_PROPERTY_NAME] ||
info[prefix.MATRIX_STABLE_PROFILE_TIMEZONE_PROPERTY_NAME]) as string | undefined,
bio:
msc4440Bio?.['m.text']?.[0]?.body ||
(info['moe.sable.app.bio'] as string | undefined) ||
(info['chat.commet.profile_bio'] as string | undefined),
status: info['chat.commet.profile_status'] as string | undefined,
bannerUrl: info['chat.commet.profile_banner'] as string | undefined,
nameColor: info['moe.sable.app.name_color'] as string | undefined,
nameColorDark: info['moe.sable.app.name_color_dark_theme'] as string | undefined,
nameColorLight: info['moe.sable.app.name_color_light_theme'] as string | undefined,
heroColorScheme: info['chat.commet.profile_color_scheme'] as Record<string, string> | undefined,
isCat: info['kitty.meow.is_cat'] === true,
hasCats: info['kitty.meow.has_cats'] === true,
(info[prefix.MATRIX_SABLE_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME] as string | undefined) ||
(info[prefix.MATRIX_COMMET_UNSTABLE_PROFILE_BIO_PROPERTY_NAME] as string | undefined),
status: info[prefix.MATRIX_COMMET_UNSTABLE_PROFILE_STATUS_PROPERTY_NAME] as string | undefined,
bannerUrl: info[prefix.MATRIX_UNSTABLE_PROFILE_BANNER_PROPERTY_NAME] as string | undefined,
nameColor: info[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_PROPERTY_NAME] as string | undefined,
nameColorDark: info[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_DARK_PROPERTY_NAME] as
| string
| undefined,
nameColorLight: info[prefix.MATRIX_SABLE_UNSTABLE_NAME_COLOR_LIGHT_PROPERTY_NAME] as
| string
| undefined,
heroColorScheme: info[prefix.MATRIX_COMMET_UNSTABLE_PROFILE_COLOR_SCHEME_PROPERTY_NAME] as
| Record<string, string>
| undefined,
isCat: info[prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_IS_CAT_PROPERTY_NAME] === true,
hasCats: info[prefix.MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_HAS_CAT_PROPERTY_NAME] === true,
extended,
_fetched: true,
};
+2 -2
View File
@@ -1,8 +1,8 @@
import { MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME } from '$types/matrix/common';
import type { MatrixReactionEvent } from '$types/matrix/common';
import type { MatrixClient, Room } from 'matrix-js-sdk';
import { ImageUsage } from '$plugins/custom-emoji';
import { getImagePackReferencesForMxcWrappedInMap } from './msc4459helper';
import { MATRIX_UNSTABLE_IMAGE_SOURCE_PACK_PROPERTY_NAME } from '$unstable/prefixes';
export const getReactionContent = (
eventId: string,
@@ -18,7 +18,7 @@ export const getReactionContent = (
},
shortcode,
'com.beeper.reaction.shortcode': shortcode,
[MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME]: getImagePackReferencesForMxcWrappedInMap(
[MATRIX_UNSTABLE_IMAGE_SOURCE_PACK_PROPERTY_NAME]: getImagePackReferencesForMxcWrappedInMap(
key,
matrixClient,
ImageUsage.Emoticon,
+14 -13
View File
@@ -4,6 +4,7 @@ import type { InCinnySpacesContent } from '$hooks/useSidebarItems';
import type { MemberPowerTag } from '$types/matrix/room';
import type { RoomAbbreviationsContent } from '$utils/abbreviations';
import type { PronounSet } from '$utils/pronouns';
import type * as prefix from '$unstable/prefixes';
type PowerLevelTagsEventContent = Record<number, MemberPowerTag>;
@@ -33,21 +34,21 @@ type RoomCosmeticsPronounsEventContent = {
declare module 'matrix-js-sdk/lib/@types/event' {
interface StateEvents {
'im.ponies.room_emotes': PackContent;
'in.cinny.room.power_level_tags': PowerLevelTagsEventContent;
'im.vector.modular.widgets': RoomWidgetEventContent;
'moe.sable.room.cosmetics.color': RoomCosmeticsColorEventContent;
'moe.sable.room.cosmetics.font': RoomCosmeticsFontEventContent;
'moe.sable.room.cosmetics.pronouns': RoomCosmeticsPronounsEventContent;
'moe.sable.room.abbreviations': RoomAbbreviationsContent;
[prefix.MATRIX_UNSTABLE_STATE_ROOM_EMOTES_PROPERTY_NAME]: PackContent;
[prefix.MATRIX_CINNY_UNSTABLE_STATE_ROOM_POWER_LEVELS_LABEL_PROPERTY_NAME]: PowerLevelTagsEventContent;
[prefix.MATRIX_ELEMENT_UNSTABLE_STATE_ROOM_WIDGET_PROPERTY_NAME]: RoomWidgetEventContent;
[prefix.MATRIX_SABLE_UNSTABLE_STATE_COSMETICS_MEMBER_COLOR_PROPERTY_NAME]: RoomCosmeticsColorEventContent;
[prefix.MATRIX_SABLE_UNSTABLE_STATE_COSMETICS_MEMBER_FONT_PROPERTY_NAME]: RoomCosmeticsFontEventContent;
[prefix.MATRIX_SABLE_UNSTABLE_STATE_COSMETICS_MEMBER_PRONOUNS_PROPERTY_NAME]: RoomCosmeticsPronounsEventContent;
[prefix.MATRIX_SABLE_UNSTABLE_STATE_ROOM_ABBREVIATIONS_PROPERTY_NAME]: RoomAbbreviationsContent;
}
interface AccountDataEvents {
'in.cinny.spaces': InCinnySpacesContent;
'io.element.recent_emoji': IRecentEmojiContent;
'im.ponies.user_emotes': PackContent;
'im.ponies.emote_rooms': EmoteRoomsContent;
'moe.sable.app.nicknames': Record<string, string>;
'moe.sable.app.settings': Record<string, unknown>;
[prefix.MATRIX_CINNY_UNSTABLE_ACCOUNT_SPACES_PROPERTY_NAME]: InCinnySpacesContent;
[prefix.MATRIX_ELEMENT_UNSTABLE_ACCOUNT_RECENT_EMOJIS_PROPERTY_NAME]: IRecentEmojiContent;
[prefix.MATRIX_UNSTABLE_ACCOUNT_USER_EMOTES_PROPERTY_NAME]: PackContent;
[prefix.MATRIX_UNSTABLE_ACCOUNT_EMOTE_ROOMS_PROPERTY_NAME]: EmoteRoomsContent;
[prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_NICKNAMES_PROPERTY_NAME]: Record<string, string>;
[prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_SETTINGS_PROPERTY_NAME]: Record<string, unknown>;
}
}
+11 -9
View File
@@ -1,13 +1,15 @@
import * as prefix from '$unstable/prefixes';
export const CustomAccountDataEvent = {
CinnySpaces: 'in.cinny.spaces',
ElementRecentEmoji: 'io.element.recent_emoji',
PoniesUserEmotes: 'im.ponies.user_emotes',
PoniesEmoteRooms: 'im.ponies.emote_rooms',
SableNicknames: 'moe.sable.app.nicknames',
SablePinStatus: 'moe.sable.app.pins_read_marker',
// because of a mistake hasn't been renamed in time
SablePerProfileMessageProfiles: 'fyi.cisnt.permessageprofile',
SableSettings: 'moe.sable.app.settings',
CinnySpaces: prefix.MATRIX_CINNY_UNSTABLE_ACCOUNT_SPACES_PROPERTY_NAME,
ElementRecentEmoji: prefix.MATRIX_ELEMENT_UNSTABLE_ACCOUNT_RECENT_EMOJIS_PROPERTY_NAME,
PoniesUserEmotes: prefix.MATRIX_UNSTABLE_ACCOUNT_USER_EMOTES_PROPERTY_NAME,
PoniesEmoteRooms: prefix.MATRIX_UNSTABLE_ACCOUNT_EMOTE_ROOMS_PROPERTY_NAME,
SableNicknames: prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_NICKNAMES_PROPERTY_NAME,
SablePinStatus: prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_PIN_STATUS_PROPERTY_NAME,
SablePerProfileMessageProfiles:
prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_PER_MESSAGE_PROFILES_PROPERTY_NAME,
SableSettings: prefix.MATRIX_SABLE_UNSTABLE_ACCOUNT_SETTINGS_PROPERTY_NAME,
} as const;
export type CustomAccountDataEvent =
(typeof CustomAccountDataEvent)[keyof typeof CustomAccountDataEvent];
+14 -13
View File
@@ -2,19 +2,14 @@ import type { SerializableMap } from '$types/wrapper/SerializableMap';
import type { SerializableSet } from '$types/wrapper/SerializableSet';
import type { EncryptedAttachmentInfo } from 'browser-encrypt-attachment';
import type { MsgType } from '$types/matrix-sdk';
export const MATRIX_BLUR_HASH_PROPERTY_NAME = 'xyz.amorgan.blurhash';
export const MATRIX_SPOILER_PROPERTY_NAME = 'page.codeberg.everypizza.msc4193.spoiler';
export const MATRIX_SPOILER_REASON_PROPERTY_NAME =
'page.codeberg.everypizza.msc4193.spoiler.reason';
export const MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME = 'com.beeper.msc4459.image_source_packs';
import type * as prefix from '$unstable/prefixes';
export type IImageInfo = {
w?: number;
h?: number;
mimetype?: string;
size?: number;
[MATRIX_BLUR_HASH_PROPERTY_NAME]?: string;
[prefix.MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME]?: string;
};
export type MatrixRelatesTo = {
@@ -59,11 +54,17 @@ export type MatrixReactionEvent = {
/**
* a map of image pack references
*/
[MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME]?: SerializableMap<string, MSC4459ImagePackReference>;
[prefix.MATRIX_UNSTABLE_IMAGE_SOURCE_PACK_PROPERTY_NAME]?: SerializableMap<
string,
MSC4459ImagePackReference
>;
};
export interface IGenericMSC4459 {
[MATRIX_IMAGE_SOURCE_PACK_PROPERTY_NAME]?: SerializableMap<string, MSC4459ImagePackReference>;
[prefix.MATRIX_UNSTABLE_IMAGE_SOURCE_PACK_PROPERTY_NAME]?: SerializableMap<
string,
MSC4459ImagePackReference
>;
}
export type IVideoInfo = {
@@ -102,8 +103,8 @@ export type IImageContent = {
url?: string;
info?: IImageInfo & IThumbnailContent;
file?: IEncryptedFile;
[MATRIX_SPOILER_PROPERTY_NAME]?: boolean;
[MATRIX_SPOILER_REASON_PROPERTY_NAME]?: string;
[prefix.MATRIX_UNSTABLE_SPOILER_PROPERTY_NAME]?: boolean;
[prefix.MATRIX_UNSTABLE_SPOILER_REASON_PROPERTY_NAME]?: string;
};
export type IVideoContent = {
@@ -113,8 +114,8 @@ export type IVideoContent = {
url?: string;
info?: IVideoInfo & IThumbnailContent;
file?: IEncryptedFile;
[MATRIX_SPOILER_PROPERTY_NAME]?: boolean;
[MATRIX_SPOILER_REASON_PROPERTY_NAME]?: string;
[prefix.MATRIX_UNSTABLE_SPOILER_PROPERTY_NAME]?: boolean;
[prefix.MATRIX_UNSTABLE_SPOILER_REASON_PROPERTY_NAME]?: string;
};
export type IAudioContent = {
+6
View File
@@ -0,0 +1,6 @@
// a list of constants for unstable prefixes used
// central list to be used throughout the codebase
export * from './prefixes/msc/index';
export * from './prefixes/sable/index';
export * from './prefixes/misc';
+17
View File
@@ -0,0 +1,17 @@
/**
* unstable prefix for profile banners
*/
export const MATRIX_UNSTABLE_PROFILE_BANNER_PROPERTY_NAME = 'chat.commet.profile_banner';
export const MATRIX_COMMET_UNSTABLE_PROFILE_COLOR_SCHEME_PROPERTY_NAME =
'chat.commet.profile_color_scheme';
/**
* @deprecated
*/
export const MATRIX_COMMET_UNSTABLE_PROFILE_BIO_PROPERTY_NAME = 'chat.commet.profile_bio';
export const MATRIX_COMMET_UNSTABLE_PROFILE_STATUS_PROPERTY_NAME = 'chat.commet.profile_status';
export const MATRIX_CINNY_UNSTABLE_ACCOUNT_SPACES_PROPERTY_NAME = 'in.cinny.spaces';
export const MATRIX_CINNY_UNSTABLE_STATE_ROOM_POWER_LEVELS_LABEL_PROPERTY_NAME =
'in.cinny.room.power_level_tags';
export const MATRIX_ELEMENT_UNSTABLE_ACCOUNT_RECENT_EMOJIS_PROPERTY_NAME =
'io.element.recent_emoji';
export const MATRIX_ELEMENT_UNSTABLE_STATE_ROOM_WIDGET_PROPERTY_NAME = 'im.vector.modular.widgets';
+10
View File
@@ -0,0 +1,10 @@
// account data related unstable prefixes
// don't import this file directly, import '$unstable/prefixes'
// partly migrated from src/types/matrix/accountData.ts
/**
* @deprecated no longer part of MSC
*/
export const MATRIX_UNSTABLE_ACCOUNT_USER_EMOTES_PROPERTY_NAME = 'im.ponies.user_emotes';
export const MATRIX_UNSTABLE_ACCOUNT_EMOTE_ROOMS_PROPERTY_NAME = 'im.ponies.emote_rooms';
+39
View File
@@ -0,0 +1,39 @@
// event related unstable prefixes
// don't import this file directly, import '$unstable/prefixes'
/**
* unstable prefix for blur hashes
*/
export const MATRIX_UNSTABLE_BLUR_HASH_PROPERTY_NAME = 'xyz.amorgan.blurhash';
/**
* unstable prefix for media spoilers
* defined in MSC4193 https://github.com/matrix-org/matrix-spec-proposals/pull/4193
*/
export const MATRIX_UNSTABLE_SPOILER_PROPERTY_NAME = 'page.codeberg.everypizza.msc4193.spoiler';
/**
* unstable prefix for media spoilers reasons
* defined in MSC4193 https://github.com/matrix-org/matrix-spec-proposals/pull/4193
*/
export const MATRIX_UNSTABLE_SPOILER_REASON_PROPERTY_NAME =
'page.codeberg.everypizza.msc4193.spoiler.reason';
/**
* unstable prefix for image pack references
* defined in MSC4459 https://github.com/matrix-org/matrix-spec-proposals/pull/4259
*/
export const MATRIX_UNSTABLE_IMAGE_SOURCE_PACK_PROPERTY_NAME =
'com.beeper.msc4459.image_source_packs';
/**
* unstable prefix for per-message profiles
* defined in MSC4144 https://github.com/matrix-org/matrix-spec-proposals/pull/4144
*/
export const MATRIX_UNSTABLE_PER_MESSAGE_PROFILE_PROPERTY_NAME = 'com.beeper.per_message_profile';
/**
* unstable prefix for embedded link previews
*/
export const MATRIX_UNSTABLE_EMBEDDED_LINK_PREVIEW_PROPERTY_NAME = 'com.beeper.linkpreviews';
/**
* unstable prefix for message forwards meta
* defined in MSC2723 https://github.com/matrix-org/matrix-spec-proposals/pull/2723
*/
export const MATRIX_UNSTABLE_MESSAGE_FORWARD_META_PROPERTY_NAME = 'com.famedly.app.forwarded';
+7
View File
@@ -0,0 +1,7 @@
// unstable prefixes defined in MSCs
// don't import this file directly, import '$unstable/prefixes'
export * from './event_misc';
export * from './profile';
export * from './accountdata';
export * from './state_events';
+16
View File
@@ -0,0 +1,16 @@
// profile related unstable prefixes
// don't import this file directly, import '$unstable/prefixes'
/**
* unstable prefix for profile pronouns
*/
export const MATRIX_UNSTABLE_PROFILE_PRONOUNS_PROPERTY_NAME = 'io.fsky.nyx.pronouns';
/**
* unstable prefix for profile biography
* defined in MSC4440 https://github.com/matrix-org/matrix-spec-proposals/pull/4440
*/
export const MATRIX_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME = 'gay.fomx.biography';
export const MATRIX_UNSTABLE_PROFILE_TIMEZONE_PROPERTY_NAME = 'us.cloke.msc4175.tz';
export const MATRIX_STABLE_PROFILE_TIMEZONE_PROPERTY_NAME = 'm.tz';
@@ -0,0 +1,9 @@
// state event related unstable prefixes
// don't import this file directly, import '$unstable/prefixes'
export const MATRIX_UNSTABLE_STATE_ROOM_EMOTES_PROPERTY_NAME = 'im.ponies.room_emotes';
/**
* unstable prefix for call rooms
* defined in MSC3401 https://github.com/matrix-org/matrix-spec-proposals/pull/3401
*/
export const MATRIX_UNSTABLE_ROOM_TYPE_CALL_PROPERTY_NAME = 'org.matrix.msc3401.call';
@@ -0,0 +1,13 @@
// account data related unstable prefixes
// don't import this file directly, import '$unstable/prefixes'
// partly migrated from src/types/matrix/accountData.ts
export const MATRIX_SABLE_UNSTABLE_ACCOUNT_NICKNAMES_PROPERTY_NAME = 'moe.sable.app.nicknames';
export const MATRIX_SABLE_UNSTABLE_ACCOUNT_PIN_STATUS_PROPERTY_NAME =
'moe.sable.app.pins_read_marker';
export const MATRIX_SABLE_UNSTABLE_ACCOUNT_SETTINGS_PROPERTY_NAME = 'moe.sable.app.settings';
/**
* the prefix which is used to save used per message profiles to the account data
*/
export const MATRIX_SABLE_UNSTABLE_ACCOUNT_PER_MESSAGE_PROFILES_PROPERTY_NAME =
'fyi.cisnt.permessageprofile';
@@ -0,0 +1,4 @@
// event related unstable prefixes
// don't import this file directly, import '$unstable/prefixes'
export const MATRIX_SABLE_UNSTABLE_MESSAGE_FORWARD_META_PROPERTY_NAME = 'moe.sable.message.forward';
+7
View File
@@ -0,0 +1,7 @@
// unstable prefixes NOT defined in MSCs but used for sable
// don't import this file directly, import '$unstable/prefixes'
export * from './profile';
export * from './event_misc';
export * from './accountdata';
export * from './state_events';
+14
View File
@@ -0,0 +1,14 @@
// unstable prefixes NOT defined in MSCs but used for sable
// don't import this file directly, import '$unstable/prefixes'
/**
* @deprecated in favor of MSC4440
*/
export const MATRIX_SABLE_UNSTABLE_PROFILE_BIOGRAPHY_PROPERTY_NAME = 'moe.sable.app.bio';
export const MATRIX_SABLE_UNSTABLE_NAME_COLOR_PROPERTY_NAME = 'moe.sable.app.name_color';
export const MATRIX_SABLE_UNSTABLE_NAME_COLOR_DARK_PROPERTY_NAME =
'moe.sable.app.name_color_dark_theme';
export const MATRIX_SABLE_UNSTABLE_NAME_COLOR_LIGHT_PROPERTY_NAME =
'moe.sable.app.name_color_light_theme';
export const MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_IS_CAT_PROPERTY_NAME = 'kitty.meow.is_cat';
export const MATRIX_SABLE_UNSTABLE_ANIMAL_IDENTITY_HAS_CAT_PROPERTY_NAME = 'kitty.meow.has_cat';
@@ -0,0 +1,11 @@
// state event related unstable prefixes
// don't import this file directly, import '$unstable/prefixes'
export const MATRIX_SABLE_UNSTABLE_STATE_COSMETICS_MEMBER_COLOR_PROPERTY_NAME =
'moe.sable.room.cosmetics.color';
export const MATRIX_SABLE_UNSTABLE_STATE_COSMETICS_MEMBER_FONT_PROPERTY_NAME =
'moe.sable.room.cosmetics.font';
export const MATRIX_SABLE_UNSTABLE_STATE_COSMETICS_MEMBER_PRONOUNS_PROPERTY_NAME =
'moe.sable.room.cosmetics.pronouns';
export const MATRIX_SABLE_UNSTABLE_STATE_ROOM_ABBREVIATIONS_PROPERTY_NAME =
'moe.sable.room.abbreviations';
+2 -1
View File
@@ -23,7 +23,8 @@
"$pages/*": ["./src/app/pages/*"],
"$types/*": ["./src/types/*"],
"$public/*": ["./public/*"],
"$client/*": ["./src/client/*"]
"$client/*": ["./src/client/*"],
"$unstable/*": ["./src/unstable/*"]
},
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
+1
View File
@@ -145,6 +145,7 @@ export default defineConfig(({ command }) => ({
$types: path.resolve(__dirname, 'src/types'),
$public: path.resolve(__dirname, 'public'),
$client: path.resolve(__dirname, 'src/client'),
$unstable: path.resolve(__dirname, 'src/unstable'),
},
},
server: {
+1
View File
@@ -20,6 +20,7 @@ export default defineConfig({
$types: path.resolve(__dirname, 'src/types'),
$public: path.resolve(__dirname, 'public'),
$client: path.resolve(__dirname, 'src/client'),
$unstable: path.resolve(__dirname, 'src/unstable'),
},
},
define: {