better error handling for vkontakte logint

fix event restore
This commit is contained in:
HF 2022-04-07 14:14:13 +02:00
parent e1ba4ea26b
commit c078672684
4 changed files with 16 additions and 4 deletions

View File

@ -282,6 +282,7 @@ passport.use(new VkontakteStrategy({
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
message: 'Sorry, you can not use vk login with an account that does not have a verified email set.', message: 'Sorry, you can not use vk login with an account that does not have a verified email set.',
}); });
return;
} }
const user = await oauthLogin(email, name); const user = await oauthLogin(email, name);
done(null, user); done(null, user);

View File

@ -3,6 +3,7 @@
* data saving for hourly events * data saving for hourly events
* *
*/ */
import { commandOptions } from 'redis';
// its ok if its slow // its ok if its slow
/* eslint-disable no-await-in-loop */ /* eslint-disable no-await-in-loop */
@ -57,6 +58,7 @@ export async function getEventArea() {
/* /*
* restore area effected by last event * restore area effected by last event
* TODO: notify RedisCanvas
*/ */
export async function clearOldEvent() { export async function clearOldEvent() {
const pos = await getEventArea(); const pos = await getEventArea();
@ -67,7 +69,10 @@ export async function clearOldEvent() {
for (let jc = j - 1; jc <= j + 1; jc += 1) { for (let jc = j - 1; jc <= j + 1; jc += 1) {
for (let ic = i - 1; ic <= i + 1; ic += 1) { for (let ic = i - 1; ic <= i + 1; ic += 1) {
const chunkKey = `${EVENT_BACKUP_PREFIX}:${ic}:${jc}`; const chunkKey = `${EVENT_BACKUP_PREFIX}:${ic}:${jc}`;
const chunk = await redis.get(chunkKey); const chunk = await redis.get(
commandOptions({ returnBuffers: true }),
chunkKey,
);
if (!chunk) { if (!chunk) {
logger.warn( logger.warn(
// eslint-disable-next-line max-len // eslint-disable-next-line max-len

View File

@ -59,7 +59,9 @@ class RedisCanvas {
static async setChunk(i, j, chunk, canvasId) { static async setChunk(i, j, chunk, canvasId) {
if (chunk.length !== TILE_SIZE * TILE_SIZE) { if (chunk.length !== TILE_SIZE * TILE_SIZE) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error(`Tried to set chunk with invalid length ${chunk.length}!`); console.error(
new Error(`Tried to set chunk with invalid length ${chunk.length}!`),
);
return false; return false;
} }
const key = `ch:${canvasId}:${i}:${j}`; const key = `ch:${canvasId}:${i}:${j}`;

View File

@ -226,7 +226,9 @@ class SocketServer {
let client = it.next(); let client = it.next();
while (!client.done) { while (!client.done) {
const ws = client.value; const ws = client.value;
if (ws.user.id === userId && ws.readyState === WebSocket.OPEN) { if (ws.readyState === WebSocket.OPEN
&& ws.user.id === userId
) {
return ws; return ws;
} }
client = it.next(); client = it.next();
@ -240,7 +242,9 @@ class SocketServer {
let client = it.next(); let client = it.next();
while (!client.done) { while (!client.done) {
const ws = client.value; const ws = client.value;
if (ws.user.id === userId && ws.readyState === WebSocket.OPEN) { if (ws.readyState === WebSocket.OPEN
&& ws.user.id === userId
) {
clients.push(ws); clients.push(ws);
} }
client = it.next(); client = it.next();