I assume these are fixes and potentially debugging changes
This commit is contained in:
parent
79d9d246f5
commit
3aa0866aa3
3
makefile
3
makefile
@ -43,6 +43,9 @@ reset-server:
|
||||
create-invite:
|
||||
node ./dist/server/scripts/create-cordis-file.js
|
||||
|
||||
create-invite-heaven:
|
||||
node ./dist/server/scripts/create-cordis-file.js 'Literally Heaven' '7 days' './invites/literally-heaven.cordis'
|
||||
|
||||
create-example-roles:
|
||||
node ./dist/server/scripts/example-roles.js
|
||||
|
||||
|
4484
package-lock.json
generated
4484
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -19,7 +19,7 @@
|
||||
"react-contenteditable": "^3.3.6",
|
||||
"recoil": "^0.5.2",
|
||||
"sass": "^1.43.4",
|
||||
"sharp": "^0.29.2",
|
||||
"sharp": "^0.30.4",
|
||||
"socket.io": "^4.3.1",
|
||||
"socket.io-client": "^4.3.2",
|
||||
"source-map": "^0.7.3",
|
||||
|
@ -161,7 +161,7 @@ export class AutoVerifier<T> {
|
||||
|
||||
// you CAN safely call this while another fetch is going on! How convenient
|
||||
unverify(): void {
|
||||
LOG.debug(`v#${this.verifierId}: unverifying`);
|
||||
// lOG.debug(`v#${this.verifierId}: unverifying`);
|
||||
if (this.primaryPromise) {
|
||||
this.primaryPromise.catch(e => {
|
||||
console.warn('caught unverified primary promise', e);
|
||||
|
@ -1,3 +1,8 @@
|
||||
import * as electronRemote from '@electron/remote';
|
||||
const electronConsole = electronRemote.getGlobal('console') as Console;
|
||||
import Logger from '../../../../logger/logger';
|
||||
const LOG = Logger.create(__filename, electronConsole);
|
||||
|
||||
import moment from 'moment';
|
||||
import React, { FC } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
@ -18,15 +23,25 @@ export interface TokenRowProps {
|
||||
}
|
||||
|
||||
const TokenRow: FC<TokenRowProps> = (props: TokenRowProps) => {
|
||||
LOG.debug('rendering TokenRow');
|
||||
const { token, guild } = props;
|
||||
|
||||
const guildMeta = useRecoilValue(guildMetaState(guild.id));
|
||||
|
||||
const [guildSocketConfigs] = useOneTimeAsyncAction(async () => await guild.fetchSocketConfigs(), null, [guild]);
|
||||
const iconSrc = useRecoilValueSoftImgSrc(guildResourceSoftImgSrcState({ guildId: guild.id, resourceId: isLoaded(guildMeta) ? guildMeta.value.iconResourceId : null }));
|
||||
const iconSrc = useRecoilValueSoftImgSrc(
|
||||
guildResourceSoftImgSrcState({
|
||||
guildId: guild.id,
|
||||
resourceId: isLoaded(guildMeta) ? guildMeta.value.iconResourceId : null,
|
||||
}),
|
||||
);
|
||||
|
||||
const [revoke] = useAsyncVoidCallback(async () => {
|
||||
await guild.requestDoRevokeToken(token.token);
|
||||
try {
|
||||
await guild.requestDoRevokeToken(token.token);
|
||||
} catch (e: unknown) {
|
||||
LOG.warn('Unable to revoke token: ' + (e as Error).message);
|
||||
}
|
||||
}, [guild, token]);
|
||||
|
||||
const [downloadFunc, downloadText, downloadShaking] = useDownloadButton(
|
||||
@ -49,7 +64,8 @@ const TokenRow: FC<TokenRowProps> = (props: TokenRowProps) => {
|
||||
[guildSocketConfigs, guildMeta, token, iconSrc],
|
||||
);
|
||||
|
||||
const userText = (token.member instanceof Member ? 'Used by ' + token.member.displayName : token.member?.id) ?? 'Unused Token';
|
||||
const userText =
|
||||
(token.member instanceof Member ? 'Used by ' + token.member.displayName : token.member?.id) ?? 'Unused Token';
|
||||
return (
|
||||
<div key={guild.id + token.token} className="token-row">
|
||||
<div className="user-token">
|
||||
@ -58,10 +74,17 @@ const TokenRow: FC<TokenRowProps> = (props: TokenRowProps) => {
|
||||
</div>
|
||||
<div className="created-expires">
|
||||
<div className="created">{'Created ' + moment(token.created).fromNow()}</div>
|
||||
<div className="expires">{token.expires ? 'Expires ' + moment(token.expires).fromNow() : 'Never expires'}</div>
|
||||
<div className="expires">
|
||||
{token.expires ? 'Expires ' + moment(token.expires).fromNow() : 'Never expires'}
|
||||
</div>
|
||||
</div>
|
||||
<div className="actions">
|
||||
<Button colorType={ButtonColorType.BRAND} onClick={downloadFunc} hoverText={downloadText} shaking={downloadShaking}>
|
||||
<Button
|
||||
colorType={ButtonColorType.BRAND}
|
||||
onClick={downloadFunc}
|
||||
hoverText={downloadText}
|
||||
shaking={downloadShaking}
|
||||
>
|
||||
{BaseElements.DOWNLOAD}
|
||||
</Button>
|
||||
<Button colorType={ButtonColorType.NEGATIVE} onClick={revoke} hoverText="Revoke">
|
||||
|
@ -27,6 +27,7 @@ export interface GuildInvitesDisplayProps {
|
||||
guild: CombinedGuild;
|
||||
}
|
||||
const GuildInvitesDisplay: FC<GuildInvitesDisplayProps> = (props: GuildInvitesDisplayProps) => {
|
||||
LOG.debug('rendering GuildInvitesDisplay');
|
||||
const { guild } = props;
|
||||
|
||||
const guildMeta = useRecoilValue(guildMetaState(guild.id));
|
||||
|
@ -8,7 +8,7 @@ import { Message } from '../../data-types';
|
||||
import MessageElement from './components/message-element';
|
||||
import { currGuildActiveChannelMessagesState, currGuildSelfMemberState, currGuildState } from '../require/atoms';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { isFailed, isLoaded, isPended, isUnload } from '../require/loadables';
|
||||
import { isLoaded } from '../require/loadables';
|
||||
import InfiniteScrollRecoil from '../components/infinite-scroll';
|
||||
|
||||
const MessageList: FC = () => {
|
||||
@ -22,17 +22,17 @@ const MessageList: FC = () => {
|
||||
// TODO: Show nicer retry buttons (and test the retry buttons)
|
||||
|
||||
// leaving this in for debugging purposes
|
||||
useEffect(() => {
|
||||
if (isUnload(messages)) {
|
||||
LOG.debug('recoilMessages unloaded');
|
||||
} else if (isPended(messages)) {
|
||||
LOG.debug('recoilMessages pended');
|
||||
} else if (isLoaded(messages)) {
|
||||
LOG.debug('recoilMessages loaded. length: ' + messages.value.length);
|
||||
} else if (isFailed(messages)) {
|
||||
LOG.debug('recoilMessages failed');
|
||||
}
|
||||
}, [messages]);
|
||||
// useEffect(() => {
|
||||
// if (isUnload(messages)) {
|
||||
// lOG.debug('recoilMessages unloaded');
|
||||
// } else if (isPended(messages)) {
|
||||
// lOG.debug('recoilMessages pended');
|
||||
// } else if (isLoaded(messages)) {
|
||||
// lOG.debug('recoilMessages loaded. length: ' + messages.value.length);
|
||||
// } else if (isFailed(messages)) {
|
||||
// lOG.debug('recoilMessages failed');
|
||||
// }
|
||||
// }, [messages]);
|
||||
|
||||
useEffect(() => {
|
||||
if (guild === null) return;
|
||||
|
@ -47,7 +47,7 @@ const ChannelOverlay: FC<ChannelOverlayProps> = (props: ChannelOverlayProps) =>
|
||||
if (channel) {
|
||||
setEdited(name !== channel.name || (flavorText === '' ? null : flavorText) !== channel.flavorText);
|
||||
} else {
|
||||
setEdited(name.length > 0 && flavorText.length > 0);
|
||||
setEdited(name.length > 0);
|
||||
}
|
||||
}, [name, flavorText, channel]);
|
||||
|
||||
|
@ -247,7 +247,7 @@ export default class PairVerifierFetchable extends EventEmitter<Conflictable> im
|
||||
}
|
||||
|
||||
unverify() {
|
||||
LOG.debug('unverifying all');
|
||||
// lOG.debug('unverifying all');
|
||||
this.fetchMetadataVerifier.unverify();
|
||||
this.fetchMembersVerifier.unverify();
|
||||
this.fetchChannelsVerifier.unverify();
|
||||
|
@ -106,9 +106,11 @@ async function getStaticSourceMaps(): Promise<Map<string, SourceMapConsumer>> {
|
||||
)
|
||||
continue; // make sure .map file exists
|
||||
const fileBuff = await fs.readFile(file + '.map');
|
||||
if (typeof window !== 'undefined' && URL && URL.createObjectURL) {
|
||||
if (URL && URL.createObjectURL) {
|
||||
// only run this stuff if we are running in a browser window
|
||||
const mappingsWasmBuffer = await fs.readFile(path.join(__dirname, '../../node_modules/source-map/lib/mappings.wasm'));
|
||||
const mappingsWasmBuffer = await fs.readFile(
|
||||
path.join(__dirname, '../../node_modules/source-map/lib/mappings.wasm'),
|
||||
);
|
||||
const mappingsWasmBlob = new Blob([mappingsWasmBuffer], { type: 'application/wasm' });
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
//@ts-ignore Typescript is missing this function... Probably because it is static
|
||||
@ -192,7 +194,10 @@ export default class Logger {
|
||||
}
|
||||
const longestFileName = Array.from(this.sourceMaps.keys())
|
||||
.map(filePath => path.basename(filePath))
|
||||
.reduce((longestFileName, fileName) => (fileName.length > longestFileName.length ? fileName : longestFileName), '');
|
||||
.reduce(
|
||||
(longestFileName, fileName) => (fileName.length > longestFileName.length ? fileName : longestFileName),
|
||||
'',
|
||||
);
|
||||
this.longestFileNameLength = longestFileName.length;
|
||||
}
|
||||
|
||||
@ -249,7 +254,9 @@ export default class Logger {
|
||||
if (data instanceof Error) {
|
||||
if (data.stack) {
|
||||
const errorFrames = this.getTSStackFrames(data);
|
||||
const tsStackLines = errorFrames.map((frame: StackTrace.Frame) => StackTrace.getFrameLine(frame));
|
||||
const tsStackLines = errorFrames.map((frame: StackTrace.Frame) =>
|
||||
StackTrace.getFrameLine(frame),
|
||||
);
|
||||
out += `${prefix}# ${data.name}: ${data.message}`;
|
||||
out += `\n${prefix}# ${tsStackLines.join(`\n${prefix}# `)}`;
|
||||
//out += `${prefix}# ${data.stack.split('\n').join(`\n${prefix}# `)}`;
|
||||
|
@ -245,7 +245,7 @@ function bindChallengeVerificationEvents(io: socketio.Server, client: socketio.S
|
||||
throw new EventError('unauthorized public key', e as Error);
|
||||
}
|
||||
|
||||
LOG.debug(`c#${client.id}: challenging for u#${identity.memberId}`);
|
||||
LOG.debug(`c#${client.id}: challenging for u#${identity.memberId?.slice(0, 4)}`);
|
||||
|
||||
if (connected.find(i => i.memberId === identity.memberId && i.verified)) {
|
||||
throw new EventError('member already connected');
|
||||
@ -318,7 +318,7 @@ function bindChallengeVerificationEvents(io: socketio.Server, client: socketio.S
|
||||
LOG.debug(`c#${client.id} joining ${rooms.join(', ')}`);
|
||||
client.join(rooms);
|
||||
|
||||
LOG.info(`c#${client.id}: verified as g#${identity.guildId} u#${identity.memberId}`);
|
||||
LOG.info(`c#${client.id}: verified as g#${identity.guildId} u#${identity.memberId?.slice(0, 4)}`);
|
||||
respond(null, identity.memberId);
|
||||
});
|
||||
}
|
||||
@ -341,7 +341,7 @@ function bindAdminEvents(io: socketio.Server, client: socketio.Socket, identity:
|
||||
if (name.length === 0 || name.length > MAX_GUILD_NAME_LENGTH) throw new EventError('invalid guild name');
|
||||
if (!identity.guildId) throw new EventError('identity no guildId');
|
||||
|
||||
LOG.debug(`g#${identity.guildId} u#${identity.memberId} set-name to ${name}`);
|
||||
LOG.debug(`g#${identity.guildId} u#${identity.memberId?.slice(0, 4)} set-name to ${name}`);
|
||||
|
||||
const newMeta = await DB.setName(identity.guildId, name);
|
||||
|
||||
@ -368,7 +368,7 @@ function bindAdminEvents(io: socketio.Server, client: socketio.Socket, identity:
|
||||
if (iconBuff.length === 0 || iconBuff.length > MAX_ICON_SIZE) throw new EventError('invalid guild icon');
|
||||
if (!identity.guildId) throw new EventError('identity no guildId');
|
||||
|
||||
LOG.debug(`g#${identity.guildId} u#${identity.memberId} set-icon`);
|
||||
LOG.debug(`g#${identity.guildId} u#${identity.memberId?.slice(0, 4)} set-icon`);
|
||||
|
||||
const typeResult = await FileType.fromBuffer(iconBuff);
|
||||
if (!typeResult || !['image/png', 'image/jpeg', 'image/jpg'].includes(typeResult.mime)) {
|
||||
@ -473,7 +473,7 @@ function bindAdminEvents(io: socketio.Server, client: socketio.Socket, identity:
|
||||
['function'],
|
||||
async respond => {
|
||||
if (!identity.guildId) throw new EventError('identity no guildId');
|
||||
LOG.debug(`u#${identity.memberId}: fetching tokens`);
|
||||
LOG.debug(`u#${identity.memberId?.slice(0, 4)}: fetching tokens`);
|
||||
const tokens = await DB.getTokens(identity.guildId);
|
||||
respond(null, tokens);
|
||||
},
|
||||
@ -494,7 +494,7 @@ function bindAdminEvents(io: socketio.Server, client: socketio.Socket, identity:
|
||||
async (expiresAfter, respond) => {
|
||||
if (!identity.guildId) throw new EventError('identity no guildId');
|
||||
|
||||
LOG.debug(`u#${identity.memberId}: creating token with expiresAfter=${expiresAfter}`);
|
||||
LOG.debug(`u#${identity.memberId?.slice(0, 4)}: creating token with expiresAfter=${expiresAfter}`);
|
||||
const token = await DB.createToken(identity.guildId, expiresAfter);
|
||||
respond(null, token);
|
||||
|
||||
@ -526,7 +526,7 @@ function bindAdminEvents(io: socketio.Server, client: socketio.Socket, identity:
|
||||
if (await DB.isTokenTaken(token)) {
|
||||
throw new EventError('token already taken');
|
||||
}
|
||||
LOG.debug(`u#${identity.memberId}: revoking t#${token}`);
|
||||
LOG.debug(`u#${identity.memberId?.slice(0, 4)}: revoking t#${token}`);
|
||||
const revokedToken = await DB.revokeToken(identity.guildId, token);
|
||||
respond(null);
|
||||
|
||||
@ -596,7 +596,9 @@ function bindActionEvents(io: socketio.Server, client: socketio.Socket, identity
|
||||
resourceName = resourceName.trim();
|
||||
resourceName = resourceName.replace(/[^A-Za-z0-9 .]/g, '_'); // only alphanumerics for file names
|
||||
|
||||
LOG.info(`u#${identity.memberId}: resource message with resource of size: ${resource.length} bytes`);
|
||||
LOG.info(
|
||||
`u#${identity.memberId?.slice(0, 4)}: resource message with resource of size: ${resource.length} bytes`,
|
||||
);
|
||||
|
||||
// try to get the dimensions of the resource if it is an image so that we can scale it down for the preview
|
||||
const fileType = (await FileType.fromBuffer(resource)) ?? { mime: null, ext: null };
|
||||
@ -689,7 +691,7 @@ function bindActionEvents(io: socketio.Server, client: socketio.Socket, identity
|
||||
if (!identity.guildId) throw new EventError('identity no guildId');
|
||||
if (!identity.memberId) throw new EventError('identity no memberId');
|
||||
|
||||
LOG.info(`u#${identity.memberId}: setting status to ${status}`);
|
||||
LOG.info(`u#${identity.memberId?.slice(0, 4)}: setting status to ${status}`);
|
||||
|
||||
const before = await DB.getMember(identity.guildId, identity.memberId);
|
||||
await DB.setMemberStatus(identity.guildId, identity.memberId, status);
|
||||
@ -722,7 +724,7 @@ function bindActionEvents(io: socketio.Server, client: socketio.Socket, identity
|
||||
if (!identity.guildId) throw new EventError('identity no guildId');
|
||||
if (!identity.memberId) throw new EventError('identity no memberId');
|
||||
|
||||
LOG.info(`u#${identity.memberId}: setting display name to ${displayName}`);
|
||||
LOG.info(`u#${identity.memberId?.slice(0, 4)}: setting display name to ${displayName}`);
|
||||
|
||||
await DB.setMemberDisplayName(identity.guildId, identity.memberId, displayName);
|
||||
const updated = await DB.getMember(identity.guildId, identity.memberId);
|
||||
@ -761,7 +763,7 @@ function bindActionEvents(io: socketio.Server, client: socketio.Socket, identity
|
||||
throw new EventError('invalid avatar buffer');
|
||||
}
|
||||
|
||||
LOG.info(`u#${identity.memberId}: uploaded new avatar`);
|
||||
LOG.info(`u#${identity.memberId?.slice(0, 4)}: uploaded new avatar`);
|
||||
|
||||
const resourceId = await DB.insertResource(identity.guildId, avatarBuff);
|
||||
await DB.setMemberAvatarResourceId(identity.guildId, identity.memberId, resourceId);
|
||||
@ -786,7 +788,7 @@ function bindFetchEvents(client: socketio.Socket, identity: IIdentity): void {
|
||||
// TODO: Make sure this corresponds with the client
|
||||
if (!identity.guildId) throw new EventError('identity no guildId');
|
||||
if (!identity.memberId) throw new EventError('identity no memberId');
|
||||
LOG.info(`u#${identity.memberId}: fetching guild`);
|
||||
LOG.info(`u#${identity.memberId?.slice(0, 4)}: fetching guild`);
|
||||
const guild = await DB.getGuild(identity.guildId);
|
||||
respond(null, guild);
|
||||
});
|
||||
@ -800,7 +802,7 @@ function bindFetchEvents(client: socketio.Socket, identity: IIdentity): void {
|
||||
bindEvent(client, identity, { verified: true }, 'fetch-channels', ['function'], async respond => {
|
||||
if (!identity.guildId) throw new EventError('identity no guildId');
|
||||
if (!identity.memberId) throw new EventError('identity no memberId');
|
||||
LOG.info(`u#${identity.memberId}: fetching channels`);
|
||||
LOG.info(`u#${identity.memberId?.slice(0, 4)}: fetching channels`);
|
||||
const channels = await DB.getChannels(identity.guildId);
|
||||
respond(null, channels);
|
||||
});
|
||||
@ -822,7 +824,9 @@ function bindFetchEvents(client: socketio.Socket, identity: IIdentity): void {
|
||||
async (channelId, number, respond) => {
|
||||
if (!identity.guildId) throw new EventError('identity no guildId');
|
||||
if (!identity.memberId) throw new EventError('identity no memberId');
|
||||
LOG.info(`u#${identity.memberId}: fetching recent messages for ch#${channelId} number: ${number}`);
|
||||
LOG.info(
|
||||
`u#${identity.memberId?.slice(0, 4)}: fetching recent messages for ch#${channelId} number: ${number}`,
|
||||
);
|
||||
const messages = await DB.getMessagesRecent(identity.guildId, channelId, number);
|
||||
respond(null, messages);
|
||||
},
|
||||
@ -848,7 +852,10 @@ function bindFetchEvents(client: socketio.Socket, identity: IIdentity): void {
|
||||
if (!identity.guildId) throw new EventError('identity no guildId');
|
||||
if (!identity.memberId) throw new EventError('identity no memberId');
|
||||
LOG.info(
|
||||
`u#${identity.memberId}: fetching messages before ch#${channelId} mo#${messageOrderId} number: ${number}`,
|
||||
`u#${identity.memberId?.slice(
|
||||
0,
|
||||
4,
|
||||
)}: fetching messages before ch#${channelId} mo#${messageOrderId} number: ${number}`,
|
||||
);
|
||||
const messages = await DB.getMessagesBefore(identity.guildId, channelId, messageOrderId, number);
|
||||
respond(null, messages);
|
||||
@ -874,7 +881,10 @@ function bindFetchEvents(client: socketio.Socket, identity: IIdentity): void {
|
||||
if (!identity.guildId) throw new EventError('identity no guildId');
|
||||
if (!identity.memberId) throw new EventError('identity no memberId');
|
||||
LOG.info(
|
||||
`u#${identity.memberId}: fetching messages after ch#${channelId} mo#${messageOrderId} number: ${number}`,
|
||||
`u#${identity.memberId?.slice(
|
||||
0,
|
||||
4,
|
||||
)}: fetching messages after ch#${channelId} mo#${messageOrderId} number: ${number}`,
|
||||
);
|
||||
const messages = await DB.getMessagesAfter(identity.guildId, channelId, messageOrderId, number);
|
||||
respond(null, messages);
|
||||
@ -896,7 +906,7 @@ function bindFetchEvents(client: socketio.Socket, identity: IIdentity): void {
|
||||
async (resourceId, respond) => {
|
||||
if (!identity.guildId) throw new EventError('identity no guildId');
|
||||
if (!identity.memberId) throw new EventError('identity no memberId');
|
||||
LOG.info(`u#${identity.memberId}: fetching r#${resourceId}`);
|
||||
LOG.info(`u#${identity.memberId?.slice(0, 4)}: fetching r#${resourceId}`);
|
||||
const resource = await DB.getResource(identity.guildId, resourceId);
|
||||
respond(null, resource);
|
||||
},
|
||||
@ -911,7 +921,7 @@ function bindFetchEvents(client: socketio.Socket, identity: IIdentity): void {
|
||||
bindEvent(client, identity, { verified: true }, 'fetch-members', ['function'], async respond => {
|
||||
if (!identity.guildId) throw new EventError('identity no guildId');
|
||||
if (!identity.memberId) throw new EventError('identity no memberId');
|
||||
LOG.info(`u#${identity.memberId}: fetching members`);
|
||||
LOG.info(`u#${identity.memberId?.slice(0, 4)}: fetching members`);
|
||||
const members = await DB.getMembers(identity.guildId);
|
||||
respond(null, members);
|
||||
});
|
||||
@ -943,7 +953,7 @@ export function bindSocketEvents(io: socketio.Server): void {
|
||||
1,
|
||||
);
|
||||
if (identity.verified) {
|
||||
LOG.info(`c#${client.id}: disconnected (was u#${identity.memberId})`);
|
||||
LOG.info(`c#${client.id}: disconnected (was u#${identity.memberId?.slice(0, 4)})`);
|
||||
(async () => {
|
||||
if (!identity.guildId || !identity.memberId) return;
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user