better error handling for vkontakte logint
fix event restore
This commit is contained in:
parent
e1ba4ea26b
commit
c078672684
|
@ -282,6 +282,7 @@ passport.use(new VkontakteStrategy({
|
|||
// 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.',
|
||||
});
|
||||
return;
|
||||
}
|
||||
const user = await oauthLogin(email, name);
|
||||
done(null, user);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* data saving for hourly events
|
||||
*
|
||||
*/
|
||||
import { commandOptions } from 'redis';
|
||||
|
||||
// its ok if its slow
|
||||
/* eslint-disable no-await-in-loop */
|
||||
|
@ -57,6 +58,7 @@ export async function getEventArea() {
|
|||
|
||||
/*
|
||||
* restore area effected by last event
|
||||
* TODO: notify RedisCanvas
|
||||
*/
|
||||
export async function clearOldEvent() {
|
||||
const pos = await getEventArea();
|
||||
|
@ -67,7 +69,10 @@ export async function clearOldEvent() {
|
|||
for (let jc = j - 1; jc <= j + 1; jc += 1) {
|
||||
for (let ic = i - 1; ic <= i + 1; ic += 1) {
|
||||
const chunkKey = `${EVENT_BACKUP_PREFIX}:${ic}:${jc}`;
|
||||
const chunk = await redis.get(chunkKey);
|
||||
const chunk = await redis.get(
|
||||
commandOptions({ returnBuffers: true }),
|
||||
chunkKey,
|
||||
);
|
||||
if (!chunk) {
|
||||
logger.warn(
|
||||
// eslint-disable-next-line max-len
|
||||
|
|
|
@ -59,7 +59,9 @@ class RedisCanvas {
|
|||
static async setChunk(i, j, chunk, canvasId) {
|
||||
if (chunk.length !== TILE_SIZE * TILE_SIZE) {
|
||||
// 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;
|
||||
}
|
||||
const key = `ch:${canvasId}:${i}:${j}`;
|
||||
|
|
|
@ -226,7 +226,9 @@ class SocketServer {
|
|||
let client = it.next();
|
||||
while (!client.done) {
|
||||
const ws = client.value;
|
||||
if (ws.user.id === userId && ws.readyState === WebSocket.OPEN) {
|
||||
if (ws.readyState === WebSocket.OPEN
|
||||
&& ws.user.id === userId
|
||||
) {
|
||||
return ws;
|
||||
}
|
||||
client = it.next();
|
||||
|
@ -240,7 +242,9 @@ class SocketServer {
|
|||
let client = it.next();
|
||||
while (!client.done) {
|
||||
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);
|
||||
}
|
||||
client = it.next();
|
||||
|
|
Loading…
Reference in New Issue
Block a user