mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 13:05:32 +09:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b6ae13919 | ||
|
|
7197371123 | ||
|
|
70fd9e6331 |
No files matched your search
@@ -33,7 +33,6 @@ import {
|
||||
StartThreadFromMessageRequest,
|
||||
StartThreadRequest,
|
||||
ThreadChannelResponse,
|
||||
ThreadLocationQuery,
|
||||
ThreadMemberGetQuery,
|
||||
ThreadMemberListResponse,
|
||||
ThreadMembersListQuery,
|
||||
@@ -389,7 +388,6 @@ export function ThreadController(app: HonoApp) {
|
||||
RateLimitMiddleware(RateLimitConfigs.CHANNEL_THREAD_MEMBER_PUT),
|
||||
LoginRequired,
|
||||
Validator('param', ChannelIdParam),
|
||||
Validator('query', ThreadLocationQuery),
|
||||
OpenAPI({
|
||||
operationId: 'join_thread',
|
||||
summary: 'Join a thread',
|
||||
@@ -415,7 +413,6 @@ export function ThreadController(app: HonoApp) {
|
||||
RateLimitMiddleware(RateLimitConfigs.CHANNEL_THREAD_MEMBER_DELETE),
|
||||
LoginRequired,
|
||||
Validator('param', ChannelIdParam),
|
||||
Validator('query', ThreadLocationQuery),
|
||||
OpenAPI({
|
||||
operationId: 'leave_thread',
|
||||
summary: 'Leave a thread',
|
||||
@@ -474,7 +471,6 @@ export function ThreadController(app: HonoApp) {
|
||||
LoginRequired,
|
||||
SelfThreadMemberAlias('join'),
|
||||
Validator('param', ChannelIdUserIdParam),
|
||||
Validator('query', ThreadLocationQuery),
|
||||
OpenAPI({
|
||||
operationId: 'add_thread_member',
|
||||
summary: 'Add a thread member',
|
||||
@@ -504,7 +500,6 @@ export function ThreadController(app: HonoApp) {
|
||||
LoginRequired,
|
||||
SelfThreadMemberAlias('leave'),
|
||||
Validator('param', ChannelIdUserIdParam),
|
||||
Validator('query', ThreadLocationQuery),
|
||||
OpenAPI({
|
||||
operationId: 'remove_thread_member',
|
||||
summary: 'Remove a thread member',
|
||||
|
||||
@@ -5850,13 +5850,6 @@
|
||||
"required": true,
|
||||
"schema": {"description": "The ID of the channel", "$ref": "#/components/schemas/SnowflakeType"},
|
||||
"description": "The ID of the channel"
|
||||
},
|
||||
{
|
||||
"name": "location",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {"description": "Accepted and ignored", "type": "string", "maxLength": 100},
|
||||
"description": "Accepted and ignored"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -5915,13 +5908,6 @@
|
||||
"required": true,
|
||||
"schema": {"description": "The ID of the channel", "$ref": "#/components/schemas/SnowflakeType"},
|
||||
"description": "The ID of the channel"
|
||||
},
|
||||
{
|
||||
"name": "location",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {"description": "Accepted and ignored", "type": "string", "maxLength": 100},
|
||||
"description": "Accepted and ignored"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -6140,13 +6126,6 @@
|
||||
"required": true,
|
||||
"schema": {"description": "The ID of the user", "$ref": "#/components/schemas/SnowflakeType"},
|
||||
"description": "The ID of the user"
|
||||
},
|
||||
{
|
||||
"name": "location",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {"description": "Accepted and ignored", "type": "string", "maxLength": 100},
|
||||
"description": "Accepted and ignored"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -6212,13 +6191,6 @@
|
||||
"required": true,
|
||||
"schema": {"description": "The ID of the user", "$ref": "#/components/schemas/SnowflakeType"},
|
||||
"description": "The ID of the user"
|
||||
},
|
||||
{
|
||||
"name": "location",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"schema": {"description": "Accepted and ignored", "type": "string", "maxLength": 100},
|
||||
"description": "Accepted and ignored"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -31490,8 +31462,7 @@
|
||||
"maximum": 21600,
|
||||
"description": "Seconds a user has to wait before sending another message (0-21600)",
|
||||
"$ref": "#/components/schemas/Int32Type"
|
||||
},
|
||||
"location": {"description": "Accepted and ignored", "type": "string", "maxLength": 100}
|
||||
}
|
||||
},
|
||||
"required": ["name"]
|
||||
},
|
||||
@@ -36252,8 +36223,7 @@
|
||||
},
|
||||
"description": "The first message of the post",
|
||||
"$ref": "#/components/schemas/ForumThreadMessageRequest"
|
||||
},
|
||||
"location": {"description": "Accepted and ignored", "type": "string", "maxLength": 100}
|
||||
}
|
||||
},
|
||||
"required": ["name", "message"],
|
||||
"x-fluxer-experiment": "channel_threads"
|
||||
@@ -36272,8 +36242,7 @@
|
||||
"invitable": {
|
||||
"description": "Whether non-moderators can add other non-moderators (private threads)",
|
||||
"type": "boolean"
|
||||
},
|
||||
"location": {"description": "Accepted and ignored", "type": "string", "maxLength": 100}
|
||||
}
|
||||
},
|
||||
"required": ["name", "type"]
|
||||
},
|
||||
|
||||
@@ -8,6 +8,7 @@ import {applyPatchToRow, buildPatchFromData, executeVersionedUpdate} from '@app/
|
||||
import type {UserRow} from '@app/api/database/types/UserTypes';
|
||||
import {EMPTY_USER_ROW, USER_COLUMNS} from '@app/api/database/types/UserTypes';
|
||||
import {emitAccountChangedIfRelevant} from '@app/api/infrastructure/activity/AccountChangeEvents';
|
||||
import {getInstanceProductName} from '@app/api/instance/ProductName';
|
||||
import {User} from '@app/api/models/User';
|
||||
import {Users} from '@app/api/Tables';
|
||||
import {shiftGiftExtensionPastPremiumUntil} from '@app/api/user/GiftExtensionShift';
|
||||
@@ -67,7 +68,7 @@ export class UserDataRepository {
|
||||
return new User({
|
||||
...EMPTY_USER_ROW,
|
||||
user_id: createUserID(FLUXER_BOT_USER_ID),
|
||||
username: 'Fluxer',
|
||||
username: getInstanceProductName(),
|
||||
discriminator: 0,
|
||||
bot: true,
|
||||
system: true,
|
||||
|
||||
@@ -31,6 +31,7 @@ interface TokenDef {
|
||||
lightness?: number;
|
||||
alpha?: number;
|
||||
useSaturationFactor?: boolean;
|
||||
instanceOverride?: string;
|
||||
}
|
||||
|
||||
interface Config {
|
||||
@@ -457,10 +458,28 @@ hsl(258, calc(10% * var(--saturation-factor)), 2%) 10%
|
||||
{name: '--control-button-active-text', value: 'var(--text-primary)'},
|
||||
{name: '--control-button-danger-text', hue: 1, saturation: 77, useSaturationFactor: true, lightness: 60},
|
||||
{name: '--control-button-danger-hover-bg', hue: 1, saturation: 77, useSaturationFactor: true, lightness: 20},
|
||||
{name: '--brand-primary', family: 'brand', lightness: 55},
|
||||
{name: '--brand-secondary', family: 'brand', saturation: 60, lightness: 49},
|
||||
{name: '--brand-primary-light', family: 'brand', saturation: 100, lightness: 84},
|
||||
{name: '--brand-primary-fill', hue: 0, saturation: 0, lightness: 100},
|
||||
{name: '--brand-primary', family: 'brand', lightness: 55, instanceOverride: '--instance-brand-primary'},
|
||||
{
|
||||
name: '--brand-secondary',
|
||||
family: 'brand',
|
||||
saturation: 60,
|
||||
lightness: 49,
|
||||
instanceOverride: '--instance-brand-secondary',
|
||||
},
|
||||
{
|
||||
name: '--brand-primary-light',
|
||||
family: 'brand',
|
||||
saturation: 100,
|
||||
lightness: 84,
|
||||
instanceOverride: '--instance-brand-primary-light',
|
||||
},
|
||||
{
|
||||
name: '--brand-primary-fill',
|
||||
hue: 0,
|
||||
saturation: 0,
|
||||
lightness: 100,
|
||||
instanceOverride: '--instance-brand-primary-fill',
|
||||
},
|
||||
{name: '--status-online', family: 'statusOnline', lightness: 40},
|
||||
{name: '--status-idle', family: 'statusIdle', lightness: 50},
|
||||
{name: '--status-dnd', family: 'statusDnd', lightness: 60},
|
||||
@@ -474,7 +493,13 @@ hsl(258, calc(10% * var(--saturation-factor)), 2%) 10%
|
||||
{name: '--plutonium-icon', family: 'brandIcon', lightness: 50},
|
||||
{name: '--invite-verified-icon-color', value: 'var(--text-on-brand-primary)'},
|
||||
{name: '--text-link', family: 'link', lightness: 70},
|
||||
{name: '--text-on-brand-primary', hue: 0, saturation: 0, lightness: 98},
|
||||
{
|
||||
name: '--text-on-brand-primary',
|
||||
hue: 0,
|
||||
saturation: 0,
|
||||
lightness: 98,
|
||||
instanceOverride: '--instance-text-on-brand-primary',
|
||||
},
|
||||
...DARK_CODE_TOKENS,
|
||||
{name: '--text-selection', hue: 198, saturation: 92, useSaturationFactor: true, lightness: 70, alpha: 0.35},
|
||||
{name: '--markup-mention-text', value: 'var(--text-link)'},
|
||||
@@ -792,6 +817,7 @@ interface OutputToken {
|
||||
alpha?: number;
|
||||
useSaturationFactor?: boolean;
|
||||
value?: string;
|
||||
instanceOverride?: string;
|
||||
}
|
||||
|
||||
function clamp01(value: number): number {
|
||||
@@ -866,6 +892,7 @@ function expandTokens(defs: Array<TokenDef>, scales: Record<string, Scale>): Arr
|
||||
lightness: def.lightness,
|
||||
alpha: def.alpha,
|
||||
useSaturationFactor: def.useSaturationFactor,
|
||||
instanceOverride: def.instanceOverride,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -919,7 +946,8 @@ function formatTone(token: OutputToken, families: Record<string, ColorFamily>):
|
||||
|
||||
function formatValue(token: OutputToken, families: Record<string, ColorFamily>): string {
|
||||
if (token.type === 'tone') {
|
||||
return formatTone(token, families);
|
||||
const tone = formatTone(token, families);
|
||||
return token.instanceOverride ? `var(${token.instanceOverride}, ${tone})` : tone;
|
||||
}
|
||||
return token.value!.trim();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import {usePlatformClasses} from '@app/features/app/hooks/usePlatformClasses';
|
||||
import {useServiceWorkerBadge} from '@app/features/app/hooks/useServiceWorkerBadge';
|
||||
import {useTabKeyFocusGuard} from '@app/features/app/hooks/useTabKeyFocusGuard';
|
||||
import {type LayoutVariant, LayoutVariantProvider} from '@app/features/app/state/LayoutVariantContext';
|
||||
import RuntimeConfig from '@app/features/app/state/RuntimeConfig';
|
||||
import RuntimeCrash from '@app/features/app/state/RuntimeCrash';
|
||||
import {showMyselfTypingHelper} from '@app/features/devtools/utils/ShowMyselfTypingHelper';
|
||||
import GatewayConnection from '@app/features/gateway/transport/GatewayConnection';
|
||||
@@ -190,6 +191,9 @@ export const AppWrapper = observer(({children}: AppWrapperProps) => {
|
||||
messageGutter: Accessibility.messageGutter,
|
||||
messageGroupSpacing: Accessibility.getMessageGroupSpacingValue(messageDisplayCompact),
|
||||
hdrDisplayMode: Accessibility.hdrDisplayMode,
|
||||
instanceThemeColor: RuntimeConfig.isSelfHosted()
|
||||
? (RuntimeConfig.getSnapshotOrNull()?.appPublic.branding.theme_color ?? null)
|
||||
: null,
|
||||
});
|
||||
useCustomThemeStyle({
|
||||
enabledThemeCss: ThemeLibrary.activeThemeCss,
|
||||
|
||||
@@ -27,6 +27,7 @@ import {UserProfileBadges} from '@app/features/user/components/popouts/UserProfi
|
||||
import type {Profile} from '@app/features/user/models/Profile';
|
||||
import Users from '@app/features/user/state/Users';
|
||||
import * as NicknameUtils from '@app/features/user/utils/NicknameUtils';
|
||||
import {FLUXERBOT_ID} from '@fluxer/constants/src/AppConstants';
|
||||
import {RelationshipTypes} from '@fluxer/constants/src/UserConstants';
|
||||
import {msg, ph, plural} from '@lingui/core/macro';
|
||||
import {Trans, useLingui} from '@lingui/react/macro';
|
||||
@@ -96,7 +97,9 @@ export const DMWelcomeSection: React.FC<DMWelcomeSectionProps> = observer(functi
|
||||
return null;
|
||||
}
|
||||
const displayName = NicknameUtils.getNickname(user, null, channel?.id);
|
||||
const fluxerTag = NicknameUtils.formatTagForStreamerMode(user.tag);
|
||||
const fluxerTag = NicknameUtils.formatTagForStreamerMode(
|
||||
user.id === FLUXERBOT_ID ? `${displayName}#${user.discriminator}` : user.tag,
|
||||
);
|
||||
const handleSendFriendRequest = () => {
|
||||
RelationshipActionUtils.sendFriendRequest(i18n, user.id);
|
||||
};
|
||||
|
||||
@@ -55,6 +55,7 @@ function ThemedApp({
|
||||
messageGutter: 16,
|
||||
messageGroupSpacing: groupSpacing,
|
||||
hdrDisplayMode: HdrDisplayMode.FULL,
|
||||
instanceThemeColor: null,
|
||||
});
|
||||
return (
|
||||
<MeasuringChild
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import {HdrDisplayMode} from '@app/features/accessibility/state/Accessibility';
|
||||
import {remFromPx} from '@app/features/theme/layout/RemFromPx';
|
||||
import {getInstanceBrandVariables, INSTANCE_BRAND_VARIABLES} from '@app/features/theme/utils/InstanceBrandColors';
|
||||
import {useLayoutEffect} from 'react';
|
||||
|
||||
interface ThemeCssVariablesOptions {
|
||||
@@ -14,6 +15,7 @@ interface ThemeCssVariablesOptions {
|
||||
messageGutter: number;
|
||||
messageGroupSpacing: number;
|
||||
hdrDisplayMode: HdrDisplayMode;
|
||||
instanceThemeColor: string | null;
|
||||
}
|
||||
|
||||
export function useThemeCssVariables({
|
||||
@@ -26,6 +28,7 @@ export function useThemeCssVariables({
|
||||
messageGutter,
|
||||
messageGroupSpacing,
|
||||
hdrDisplayMode,
|
||||
instanceThemeColor,
|
||||
}: ThemeCssVariablesOptions): void {
|
||||
useLayoutEffect(() => {
|
||||
const htmlNode = document.documentElement;
|
||||
@@ -63,6 +66,20 @@ export function useThemeCssVariables({
|
||||
messageGroupSpacing,
|
||||
hdrDisplayMode,
|
||||
]);
|
||||
useLayoutEffect(() => {
|
||||
if (instanceThemeColor === null) return;
|
||||
const variables = getInstanceBrandVariables(instanceThemeColor);
|
||||
if (variables === null) return;
|
||||
const htmlNode = document.documentElement;
|
||||
for (const name of INSTANCE_BRAND_VARIABLES) {
|
||||
htmlNode.style.setProperty(name, variables[name]);
|
||||
}
|
||||
return () => {
|
||||
for (const name of INSTANCE_BRAND_VARIABLES) {
|
||||
htmlNode.style.removeProperty(name);
|
||||
}
|
||||
};
|
||||
}, [instanceThemeColor]);
|
||||
useLayoutEffect(() => {
|
||||
const htmlNode = document.documentElement;
|
||||
return () => {
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
export const INSTANCE_BRAND_VARIABLES = [
|
||||
'--instance-brand-primary',
|
||||
'--instance-brand-secondary',
|
||||
'--instance-brand-primary-light',
|
||||
'--instance-brand-primary-fill',
|
||||
'--instance-text-on-brand-primary',
|
||||
] as const;
|
||||
|
||||
type InstanceBrandVariable = (typeof INSTANCE_BRAND_VARIABLES)[number];
|
||||
|
||||
const HEX_COLOR_PATTERN = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
|
||||
|
||||
function parseHexColor(value: string): [number, number, number] | null {
|
||||
const trimmed = value.trim();
|
||||
if (!HEX_COLOR_PATTERN.test(trimmed)) return null;
|
||||
const digits =
|
||||
trimmed.length === 4
|
||||
? trimmed
|
||||
.slice(1)
|
||||
.split('')
|
||||
.map((digit) => digit + digit)
|
||||
.join('')
|
||||
: trimmed.slice(1);
|
||||
return [
|
||||
Number.parseInt(digits.slice(0, 2), 16),
|
||||
Number.parseInt(digits.slice(2, 4), 16),
|
||||
Number.parseInt(digits.slice(4, 6), 16),
|
||||
];
|
||||
}
|
||||
|
||||
function rgbToHsl(red: number, green: number, blue: number): [number, number, number] {
|
||||
const r = red / 255;
|
||||
const g = green / 255;
|
||||
const b = blue / 255;
|
||||
const max = Math.max(r, g, b);
|
||||
const min = Math.min(r, g, b);
|
||||
const lightness = (max + min) / 2;
|
||||
const delta = max - min;
|
||||
if (delta === 0) return [0, 0, lightness * 100];
|
||||
const saturation = delta / (1 - Math.abs(2 * lightness - 1));
|
||||
let hue: number;
|
||||
if (max === r) {
|
||||
hue = ((g - b) / delta) % 6;
|
||||
} else if (max === g) {
|
||||
hue = (b - r) / delta + 2;
|
||||
} else {
|
||||
hue = (r - g) / delta + 4;
|
||||
}
|
||||
return [(hue * 60 + 360) % 360, saturation * 100, lightness * 100];
|
||||
}
|
||||
|
||||
function relativeLuminance(red: number, green: number, blue: number): number {
|
||||
const linear = (channel: number) => {
|
||||
const value = channel / 255;
|
||||
return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
||||
};
|
||||
return 0.2126 * linear(red) + 0.7152 * linear(green) + 0.0722 * linear(blue);
|
||||
}
|
||||
|
||||
function formatNumber(value: number): string {
|
||||
return String(Math.round(value * 100) / 100);
|
||||
}
|
||||
|
||||
function hsl(hue: number, saturation: number, lightness: number): string {
|
||||
return `hsl(${formatNumber(hue)}, calc(${formatNumber(saturation)}% * var(--saturation-factor)), ${formatNumber(lightness)}%)`;
|
||||
}
|
||||
|
||||
export function getInstanceBrandVariables(themeColor: string): Record<InstanceBrandVariable, string> | null {
|
||||
const rgb = parseHexColor(themeColor);
|
||||
if (rgb === null) return null;
|
||||
const [hue, saturation, lightness] = rgbToHsl(...rgb);
|
||||
const luminance = relativeLuminance(...rgb);
|
||||
const prefersDarkText = (luminance + 0.05) / 0.05 > 1.05 / (luminance + 0.05);
|
||||
return {
|
||||
'--instance-brand-primary': hsl(hue, saturation, lightness),
|
||||
'--instance-brand-secondary': hsl(hue, saturation * (6 / 7), lightness * 0.89),
|
||||
'--instance-brand-primary-light': hsl(hue, saturation, lightness + (100 - lightness) * 0.65),
|
||||
'--instance-brand-primary-fill': prefersDarkText ? 'hsl(0, 0%, 8%)' : 'hsl(0, 0%, 100%)',
|
||||
'--instance-text-on-brand-primary': prefersDarkText ? 'hsl(0, 0%, 8%)' : 'hsl(0, 0%, 98%)',
|
||||
};
|
||||
}
|
||||
@@ -64,12 +64,14 @@ const AvatarComponent = React.forwardRef<HTMLDivElement, AvatarProps>(
|
||||
const {i18n} = useLingui();
|
||||
const userId = user.id;
|
||||
const userAvatar = user.avatar;
|
||||
const systemAvatarUrl = AvatarUtils.getSystemUserBrandingAvatarURL(userId);
|
||||
const guildMember = GuildMembers.getMember(guildId || '', userId);
|
||||
const hasGuildMemberAvatarSource = Boolean(guildId) && guildMember != null;
|
||||
const memberAvatar = guildMember?.avatar ?? null;
|
||||
const memberAvatarUnset = guildMember?.isAvatarUnset() ?? false;
|
||||
const avatarUrl = useMemo(() => {
|
||||
if (customAvatarUrl !== undefined) return customAvatarUrl;
|
||||
if (systemAvatarUrl !== null) return systemAvatarUrl;
|
||||
if (guildId && hasGuildMemberAvatarSource) {
|
||||
return AvatarUtils.getGuildMemberDisplayAvatarURL({
|
||||
guildId,
|
||||
@@ -88,11 +90,13 @@ const AvatarComponent = React.forwardRef<HTMLDivElement, AvatarProps>(
|
||||
memberAvatar,
|
||||
memberAvatarUnset,
|
||||
mediaSize,
|
||||
systemAvatarUrl,
|
||||
userAvatar,
|
||||
userId,
|
||||
]);
|
||||
const hoverAvatarUrl = useMemo(() => {
|
||||
if (customHoverAvatarUrl !== undefined) return customHoverAvatarUrl;
|
||||
if (systemAvatarUrl !== null) return systemAvatarUrl;
|
||||
if (guildId && hasGuildMemberAvatarSource) {
|
||||
return AvatarUtils.getGuildMemberDisplayAvatarURL({
|
||||
guildId,
|
||||
@@ -111,6 +115,7 @@ const AvatarComponent = React.forwardRef<HTMLDivElement, AvatarProps>(
|
||||
memberAvatar,
|
||||
memberAvatarUnset,
|
||||
mediaSize,
|
||||
systemAvatarUrl,
|
||||
userAvatar,
|
||||
userId,
|
||||
]);
|
||||
|
||||
+15
-4
@@ -1,11 +1,14 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import RuntimeConfig from '@app/features/app/state/RuntimeConfig';
|
||||
import {getUserAccentColor} from '@app/features/theme/utils/AccentColorUtils';
|
||||
import {ProfileBody} from '@app/features/user/components/modals/user_profile_modal/ProfileBody';
|
||||
import {ProfileMediaHeader} from '@app/features/user/components/modals/user_profile_modal/ProfileMediaHeader';
|
||||
import type {ProfileModalContentProps} from '@app/features/user/components/modals/user_profile_modal/UserProfileModalShared';
|
||||
import * as AvatarUtils from '@app/features/user/utils/AvatarUtils';
|
||||
import * as ProfileDisplayUtils from '@app/features/user/utils/ProfileDisplayUtils';
|
||||
import {resolveProfileGuildMembership, toProfileDisplayContext} from '@app/features/user/utils/ProfileGuildMembership';
|
||||
import {FLUXERBOT_ID} from '@fluxer/constants/src/AppConstants';
|
||||
import {
|
||||
MEDIA_PROXY_AVATAR_SIZE_PROFILE,
|
||||
MEDIA_PROXY_PROFILE_BANNER_SIZE_MODAL,
|
||||
@@ -26,7 +29,12 @@ export const ProfileModalContent: React.FC<ProfileModalContentProps> = observer(
|
||||
showProfileDataWarning,
|
||||
}) => {
|
||||
const effectiveProfile = profile?.getEffectiveProfile() ?? null;
|
||||
const bannerColor = getUserAccentColor(user, effectiveProfile?.accent_color);
|
||||
const isSystemUser = user.id === FLUXERBOT_ID;
|
||||
const systemThemeColor =
|
||||
isSystemUser && RuntimeConfig.isSelfHosted()
|
||||
? RuntimeConfig.getSnapshotOrNull()?.appPublic.branding.theme_color
|
||||
: null;
|
||||
const bannerColor = systemThemeColor ?? getUserAccentColor(user, effectiveProfile?.accent_color);
|
||||
const membership = resolveProfileGuildMembership(profile);
|
||||
const profileContext = useMemo<ProfileDisplayUtils.ProfileDisplayContext>(
|
||||
() =>
|
||||
@@ -38,10 +46,13 @@ export const ProfileModalContent: React.FC<ProfileModalContentProps> = observer(
|
||||
}),
|
||||
[user, profile, membership],
|
||||
);
|
||||
const {avatarUrl, hoverAvatarUrl} = useMemo(
|
||||
const {avatarUrl: profileAvatarUrl, hoverAvatarUrl: profileHoverAvatarUrl} = useMemo(
|
||||
() => ProfileDisplayUtils.getProfileAvatarUrls(profileContext, previewOverrides, MEDIA_PROXY_AVATAR_SIZE_PROFILE),
|
||||
[profileContext, previewOverrides],
|
||||
);
|
||||
const systemAvatarUrl = AvatarUtils.getSystemUserBrandingAvatarURL(user.id);
|
||||
const avatarUrl = systemAvatarUrl ?? profileAvatarUrl;
|
||||
const hoverAvatarUrl = systemAvatarUrl ?? profileHoverAvatarUrl;
|
||||
const {bannerUrl, hoverBannerUrl} = useMemo(
|
||||
() =>
|
||||
ProfileDisplayUtils.getProfileBannerUrls(
|
||||
@@ -59,8 +70,8 @@ export const ProfileModalContent: React.FC<ProfileModalContentProps> = observer(
|
||||
profileContext={profileContext}
|
||||
previewOverrides={previewOverrides}
|
||||
bannerColor={bannerColor}
|
||||
bannerUrl={bannerUrl}
|
||||
hoverBannerUrl={hoverBannerUrl}
|
||||
bannerUrl={isSystemUser ? null : bannerUrl}
|
||||
hoverBannerUrl={isSystemUser ? null : hoverBannerUrl}
|
||||
avatarUrl={avatarUrl}
|
||||
hoverAvatarUrl={hoverAvatarUrl}
|
||||
renderActionButtons={renderActionButtons}
|
||||
|
||||
@@ -18,6 +18,7 @@ import {
|
||||
parseAvatarHash,
|
||||
} from '@app/features/user/utils/AvatarMediaUtils';
|
||||
import {getDefaultAvatarAssetURL} from '@app/features/user/utils/DefaultAvatars';
|
||||
import {FLUXERBOT_ID} from '@fluxer/constants/src/AppConstants';
|
||||
import {
|
||||
MEDIA_PROXY_AVATAR_SIZE_DEFAULT,
|
||||
MEDIA_PROXY_ICON_SIZE_DEFAULT,
|
||||
@@ -75,6 +76,12 @@ const getViewportSplashSize = (): MediaProxyImageSize => {
|
||||
|
||||
export const getDefaultAvatarURLForIndex = (index: number): string => getDefaultAvatarAssetURL(index);
|
||||
|
||||
export function getSystemUserBrandingAvatarURL(userId: string): string | null {
|
||||
if (userId !== FLUXERBOT_ID || !RuntimeConfig.isSelfHosted()) return null;
|
||||
const branding = RuntimeConfig.getSnapshotOrNull()?.appPublic.branding;
|
||||
return branding?.icon_url ?? branding?.logo_url ?? null;
|
||||
}
|
||||
|
||||
export function getDefaultAvatarPrimaryColor(id: string) {
|
||||
return getSharedDefaultAvatarPrimaryColor(id);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import RuntimeConfig from '@app/features/app/state/RuntimeConfig';
|
||||
import Channels from '@app/features/channel/state/Channels';
|
||||
import GuildMembers from '@app/features/member/state/GuildMembers';
|
||||
import SelectedGuild from '@app/features/navigation/state/SelectedGuild';
|
||||
@@ -8,6 +9,7 @@ import StreamerMode from '@app/features/streamer_mode/state/StreamerMode';
|
||||
import {noteText} from '@app/features/theme/fonts/ScriptFontLoader';
|
||||
import type {User} from '@app/features/user/models/User';
|
||||
import {formatUserTag} from '@app/features/user/utils/UserTagUtils';
|
||||
import {FLUXERBOT_ID} from '@fluxer/constants/src/AppConstants';
|
||||
|
||||
export interface UserDisplayNameLike {
|
||||
username: string;
|
||||
@@ -51,6 +53,10 @@ export function getDisplayName(user: UserDisplayNameLike): string {
|
||||
}
|
||||
|
||||
export function getNickname(user: User, guildId?: string | null, channelId?: string): string {
|
||||
if (user.id === FLUXERBOT_ID) {
|
||||
const productName = RuntimeConfig.getSnapshotOrNull()?.appPublic.branding.product_name;
|
||||
if (productName) return formatNicknameForStreamerMode(productName);
|
||||
}
|
||||
let name = user.displayName || user.globalName || user.username || user.id || '';
|
||||
const relationship = Relationships.getRelationship(user.id);
|
||||
if (relationship?.nickname) {
|
||||
|
||||
@@ -84,12 +84,6 @@ Joining a locked thread needs an enrolled authenticator while the guild [MFA lev
|
||||
| --- | --- | --- |
|
||||
| channel_id | snowflake | The ID of the thread |
|
||||
|
||||
### Query parameters
|
||||
|
||||
| Field | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| location? | string | A value Fluxer accepts and ignores (max 100 characters) |
|
||||
|
||||
### Response
|
||||
|
||||
| Status | Body | Condition |
|
||||
@@ -131,12 +125,6 @@ Adding to a locked thread needs an enrolled authenticator while the guild [MFA l
|
||||
| channel_id | snowflake | The ID of the thread |
|
||||
| user_id | snowflake | The ID of the user to add |
|
||||
|
||||
### Query parameters
|
||||
|
||||
| Field | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| location? | string | A value Fluxer accepts and ignores (max 100 characters) |
|
||||
|
||||
### Response
|
||||
|
||||
| Status | Body | Condition |
|
||||
@@ -176,12 +164,6 @@ A timed-out member can leave a thread. A member who can no longer view the threa
|
||||
| --- | --- | --- |
|
||||
| channel_id | snowflake | The ID of the thread |
|
||||
|
||||
### Query parameters
|
||||
|
||||
| Field | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| location? | string | A value Fluxer accepts and ignores (max 100 characters) |
|
||||
|
||||
### Response
|
||||
|
||||
| Status | Body | Condition |
|
||||
@@ -219,12 +201,6 @@ Removing a member needs an enrolled authenticator while the guild [MFA level](/h
|
||||
| channel_id | snowflake | The ID of the thread |
|
||||
| user_id | snowflake | The ID of the user to remove |
|
||||
|
||||
### Query parameters
|
||||
|
||||
| Field | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| location? | string | A value Fluxer accepts and ignores (max 100 characters) |
|
||||
|
||||
### Response
|
||||
|
||||
| Status | Body | Condition |
|
||||
|
||||
@@ -184,7 +184,6 @@ Starts a public thread from a message in a guild text channel, or an announcemen
|
||||
| name | string | The name of the thread (1-100 characters) |
|
||||
| auto_archive_duration? | integer | The [auto archive duration](#auto-archive-durations) in minutes (default 4320) |
|
||||
| rate_limit_per_user? | integer | The slowmode interval in seconds (0-21,600) |
|
||||
| location? | string | A value Fluxer accepts and ignores (max 100 characters) |
|
||||
|
||||
`rate_limit_per_user` defaults to the `default_thread_rate_limit_per_user` of the parent, or `0` when the parent has none.
|
||||
|
||||
@@ -252,7 +251,6 @@ The parent type selects the body. Either body can be sent as multipart form data
|
||||
| auto_archive_duration? | integer | The [auto archive duration](#auto-archive-durations) in minutes (default 4320) |
|
||||
| rate_limit_per_user? | integer | The slowmode interval in seconds (0-21,600) |
|
||||
| invitable?<sup>1</sup> | boolean | Whether a member who is not a thread moderator can add members who are not thread moderators (default true) |
|
||||
| location? | string | A value Fluxer accepts and ignores (max 100 characters) |
|
||||
|
||||
<sup>1</sup> Applies only to a private thread
|
||||
|
||||
@@ -266,7 +264,6 @@ The parent type selects the body. Either body can be sent as multipart form data
|
||||
| auto_archive_duration? | integer | The [auto archive duration](#auto-archive-durations) in minutes (default 4320) |
|
||||
| rate_limit_per_user? | integer | The slowmode interval in seconds (0-21,600) |
|
||||
| type?<sup>2</sup> | integer | The thread type (`11` only) |
|
||||
| location? | string | A value Fluxer accepts and ignores (max 100 characters) |
|
||||
|
||||
<sup>1</sup> Required when the channel has `REQUIRE_TAG`. A tag marked `moderated` needs a thread moderator
|
||||
|
||||
|
||||
@@ -293,12 +293,16 @@ after_store_event(channel_delete, Data, Tab, State) ->
|
||||
end,
|
||||
State;
|
||||
after_store_event(guild_member_remove, Data, Tab, State) ->
|
||||
_ =
|
||||
case guild_state_member:extract_user_id(Data) of
|
||||
UserId when is_integer(UserId) -> guild_thread_store:remove_user(Tab, UserId);
|
||||
_ -> []
|
||||
end,
|
||||
State;
|
||||
case guild_state_member:extract_user_id(Data) of
|
||||
UserId when is_integer(UserId) ->
|
||||
lists:foldl(
|
||||
fun guild_thread_subscriptions:member_lists_changed/2,
|
||||
State,
|
||||
guild_thread_store:remove_user(Tab, UserId)
|
||||
);
|
||||
_ ->
|
||||
State
|
||||
end;
|
||||
after_store_event(guild_member_update, Data, _Tab, State) ->
|
||||
case guild_state_member:extract_user_id(Data) of
|
||||
UserId when is_integer(UserId) ->
|
||||
|
||||
@@ -75,7 +75,6 @@ apply_threads_flag(_Other, Session) ->
|
||||
|
||||
-spec apply_member_lists(term(), map(), guild_state()) -> {map(), [integer()]}.
|
||||
apply_member_lists(Ids, Session, State) when is_list(Ids) ->
|
||||
Previous = maps:get(thread_member_lists, Session, []),
|
||||
Viewable = lists:sublist(
|
||||
[Id || Id <- lists:usort(Ids), viewable_thread(Session, Id, State)], ?MAX_MEMBER_LISTS
|
||||
),
|
||||
@@ -84,7 +83,7 @@ apply_member_lists(Ids, Session, State) when is_list(Ids) ->
|
||||
[] -> maps:remove(thread_member_lists, Session);
|
||||
_ -> Session#{thread_member_lists => Viewable}
|
||||
end,
|
||||
{Updated, Viewable -- Previous};
|
||||
{Updated, Viewable};
|
||||
apply_member_lists(_Other, Session, _State) ->
|
||||
{Session, []}.
|
||||
|
||||
|
||||
@@ -1515,6 +1515,45 @@ thread_member_list_follows_member_updates_test() ->
|
||||
?assertNot(maps:is_key(thread_list_dirty, Unlisted))
|
||||
end).
|
||||
|
||||
thread_member_list_resubscribe_resends_snapshot_test() ->
|
||||
with_guild(fun(State) ->
|
||||
Subscribed = guild_thread_subscriptions:update(
|
||||
<<"a">>, #{member_lists => [?T1]}, State
|
||||
),
|
||||
[_] = received(a, thread_member_list_update, drain()),
|
||||
Again = guild_thread_subscriptions:update(
|
||||
<<"a">>, #{member_lists => [?T1]}, Subscribed
|
||||
),
|
||||
[_] = received(a, thread_member_list_update, drain()),
|
||||
_ = guild_thread_subscriptions:update(<<"a">>, #{threads => true}, Again),
|
||||
?assertEqual([], received(a, thread_member_list_update, drain()))
|
||||
end).
|
||||
|
||||
thread_member_list_drops_removed_guild_members_test() ->
|
||||
with_guild(fun(State0) ->
|
||||
Added = #{
|
||||
<<"id">> => integer_to_binary(?T1),
|
||||
<<"member_count">> => 2,
|
||||
<<"added_members">> => [thread_member(?T1, ?V)]
|
||||
},
|
||||
State1 = dispatch(thread_members_update, Added, State0),
|
||||
Subscribed = guild_thread_subscriptions:update(
|
||||
<<"a">>, #{member_lists => [?T1]}, State1
|
||||
),
|
||||
_ = drain(),
|
||||
Removed = dispatch(
|
||||
guild_member_remove,
|
||||
#{<<"user">> => #{<<"id">> => integer_to_binary(?V)}},
|
||||
Subscribed
|
||||
),
|
||||
?assertEqual(#{?T1 => true}, maps:get(thread_list_dirty, Removed)),
|
||||
_ = guild_thread_subscriptions:handle_list_flush(Removed),
|
||||
[#{<<"members">> := Members}] = received(a, thread_member_list_update, drain()),
|
||||
?assertEqual(
|
||||
[integer_to_binary(?A)], [maps:get(<<"user_id">>, M) || M <- Members]
|
||||
)
|
||||
end).
|
||||
|
||||
handoff_through_an_old_node_round_trips_test() ->
|
||||
with_guild(fun(State) ->
|
||||
Exported = guild_handoff:export_handoff_state(State),
|
||||
|
||||
@@ -38,7 +38,6 @@ import {z} from 'zod';
|
||||
|
||||
const EXPERIMENT = {experiment: 'channel_threads'} as const;
|
||||
const EMOJI_NAME_MAX_LENGTH = 64;
|
||||
const LOCATION_MAX_LENGTH = 100;
|
||||
|
||||
export const ForumTagRequest = withSchemaMetadata(
|
||||
z.object({
|
||||
@@ -141,7 +140,6 @@ export const StartForumThreadRequest = withSchemaMetadata(
|
||||
.describe('Seconds a user has to wait before sending another message (0-21600)'),
|
||||
applied_tags: AppliedTagsType.optional(),
|
||||
message: ForumThreadMessageRequest.describe('The first message of the post'),
|
||||
location: z.string().max(LOCATION_MAX_LENGTH).optional().describe('Accepted and ignored'),
|
||||
}),
|
||||
EXPERIMENT,
|
||||
);
|
||||
|
||||
@@ -22,7 +22,6 @@ import {
|
||||
import {z} from 'zod';
|
||||
|
||||
const THREAD_MEMBERS_LIST_MAX_LIMIT = 100;
|
||||
const LOCATION_MAX_LENGTH = 100;
|
||||
|
||||
export const ThreadAutoArchiveDurationSchema = createInt32EnumType(
|
||||
[
|
||||
@@ -43,13 +42,10 @@ const ThreadRateLimitPerUserType = Int32Type.max(THREAD_RATE_LIMIT_PER_USER_MAX)
|
||||
'Seconds a user has to wait before sending another message (0-21600)',
|
||||
);
|
||||
|
||||
const LocationType = z.string().max(LOCATION_MAX_LENGTH).optional().describe('Accepted and ignored');
|
||||
|
||||
export const StartThreadFromMessageRequest = z.object({
|
||||
name: ThreadNameType,
|
||||
auto_archive_duration: ThreadAutoArchiveDurationSchema.optional(),
|
||||
rate_limit_per_user: ThreadRateLimitPerUserType.optional(),
|
||||
location: LocationType,
|
||||
});
|
||||
|
||||
export type StartThreadFromMessageRequest = z.infer<typeof StartThreadFromMessageRequest>;
|
||||
@@ -68,15 +64,10 @@ export const StartThreadRequest = z.object({
|
||||
auto_archive_duration: ThreadAutoArchiveDurationSchema.optional(),
|
||||
rate_limit_per_user: ThreadRateLimitPerUserType.optional(),
|
||||
invitable: z.boolean().optional().describe('Whether non-moderators can add other non-moderators (private threads)'),
|
||||
location: LocationType,
|
||||
});
|
||||
|
||||
export type StartThreadRequest = z.infer<typeof StartThreadRequest>;
|
||||
|
||||
export const ThreadLocationQuery = z.object({
|
||||
location: LocationType,
|
||||
});
|
||||
|
||||
export const ThreadMembersListQuery = z.object({
|
||||
with_member: QueryBooleanType.describe('Whether to include a guild member object for each thread member'),
|
||||
after: SnowflakeType.optional().describe('Get thread members after this user ID'),
|
||||
|
||||
Reference in new issue
Block a user