flash
cf71bab92d
This has been in the works for over a month and might break things because it's a very radical change. If it causes you to be unable to join chat, report it on the forum or try joining using the legacy chat on https://sockchat.flashii.net.
55 lines
1.4 KiB
JavaScript
55 lines
1.4 KiB
JavaScript
#include sockchat/utils.js
|
|
|
|
const SockChatS2CAuthSuccess = (ctx, userId, userName, userColour, userPerms, chanName, maxLength) => {
|
|
ctx.userId = userId;
|
|
ctx.channelName = chanName;
|
|
|
|
const statusInfo = SockChatParseStatusInfo(userName);
|
|
|
|
const info = {
|
|
wasConnected: ctx.wasConnected,
|
|
session: { success: true },
|
|
ctx: {
|
|
maxMsgLength: parseInt(maxLength),
|
|
},
|
|
user: {
|
|
id: ctx.userId,
|
|
self: true,
|
|
name: statusInfo.name,
|
|
status: statusInfo.status,
|
|
colour: SockChatParseUserColour(userColour),
|
|
perms: SockChatParseUserPerms(userPerms),
|
|
},
|
|
channel: {
|
|
name: ctx.channelName,
|
|
},
|
|
};
|
|
|
|
ctx.wasConnected = true;
|
|
ctx.keepAlive.start();
|
|
|
|
ctx.dispatch('session:start', info);
|
|
ctx.authPromise?.resolve(info);
|
|
};
|
|
|
|
const SockChatS2CAuthFail = (ctx, reason, expiresTime) => {
|
|
ctx.wasKicked = true;
|
|
|
|
const info = {
|
|
session: {
|
|
success: false,
|
|
needsAuth: reason === 'authfail',
|
|
outOfConnections: reason === 'sockfail',
|
|
},
|
|
};
|
|
if(expiresTime !== undefined)
|
|
info.baka = {
|
|
type: 'join',
|
|
perma: expiresTime === '-1',
|
|
until: expiresTime === '-1' ? undefined : new Date(parseInt(expiresTime) * 1000),
|
|
};
|
|
|
|
ctx.dispatch('session:fail', info);
|
|
ctx.authPromise?.reject(info);
|
|
};
|