This commit is contained in:
syuilo
2021-12-09 23:58:30 +09:00
parent 0abe2dfee0
commit c69b72e199
573 changed files with 3318 additions and 3318 deletions

View File

@@ -52,7 +52,7 @@ export default abstract class Channel {
this.connection.sendMessageToWs('channel', {
id: this.id,
type: type,
body: body
body: body,
});
}

View File

@@ -32,13 +32,13 @@ export default class extends Channel {
// リプライなら再pack
if (note.replyId != null) {
note.reply = await Notes.pack(note.replyId, this.user, {
detail: true
detail: true,
});
}
// Renoteなら再pack
if (note.renoteId != null) {
note.renote = await Notes.pack(note.renoteId, this.user, {
detail: true
detail: true,
});
}

View File

@@ -95,12 +95,12 @@ export default class extends Channel {
if (!['map', 'bw', 'isLlotheo', 'canPutEverywhere', 'loopedBoard'].includes(key)) return;
await ReversiGames.update(this.gameId!, {
[key]: value
[key]: value,
});
publishReversiGameStream(this.gameId!, 'updateSettings', {
key: key,
value: value
value: value,
});
}
@@ -115,16 +115,16 @@ export default class extends Channel {
if ((game.user1Id !== this.user.id) && (game.user2Id !== this.user.id)) return;
const set = game.user1Id === this.user.id ? {
form1: form
form1: form,
} : {
form2: form
form2: form,
};
await ReversiGames.update(this.gameId!, set);
publishReversiGameStream(this.gameId!, 'initForm', {
userId: this.user.id,
form
form,
});
}
@@ -147,9 +147,9 @@ export default class extends Channel {
item.value = value;
const set = game.user1Id === this.user.id ? {
form2: form
form2: form,
} : {
form1: form
form1: form,
};
await ReversiGames.update(this.gameId!, set);
@@ -157,7 +157,7 @@ export default class extends Channel {
publishReversiGameStream(this.gameId!, 'updateForm', {
userId: this.user.id,
id,
value
value,
});
}
@@ -168,7 +168,7 @@ export default class extends Channel {
message.id = Math.random();
publishReversiGameStream(this.gameId!, 'message', {
userId: this.user.id,
message
message,
});
}
@@ -185,23 +185,23 @@ export default class extends Channel {
if (game.user1Id === this.user.id) {
await ReversiGames.update(this.gameId!, {
user1Accepted: accept
user1Accepted: accept,
});
publishReversiGameStream(this.gameId!, 'changeAccepts', {
user1: accept,
user2: game.user2Accepted
user2: game.user2Accepted,
});
if (accept && game.user2Accepted) bothAccepted = true;
} else if (game.user2Id === this.user.id) {
await ReversiGames.update(this.gameId!, {
user2Accepted: accept
user2Accepted: accept,
});
publishReversiGameStream(this.gameId!, 'changeAccepts', {
user1: game.user1Accepted,
user2: accept
user2: accept,
});
if (accept && game.user1Accepted) bothAccepted = true;
@@ -235,14 +235,14 @@ export default class extends Channel {
startedAt: new Date(),
isStarted: true,
black: bw,
map: map
map: map,
});
//#region 盤面に最初から石がないなどして始まった瞬間に勝敗が決定する場合があるのでその処理
const o = new Reversi(map, {
isLlotheo: freshGame.isLlotheo,
canPutEverywhere: freshGame.canPutEverywhere,
loopedBoard: freshGame.loopedBoard
loopedBoard: freshGame.loopedBoard,
});
if (o.isEnded) {
@@ -257,12 +257,12 @@ export default class extends Channel {
await ReversiGames.update(this.gameId!, {
isEnded: true,
winnerId: winner
winnerId: winner,
});
publishReversiGameStream(this.gameId!, 'ended', {
winnerId: winner,
game: await ReversiGames.pack(this.gameId!, this.user)
game: await ReversiGames.pack(this.gameId!, this.user),
});
}
//#endregion
@@ -293,7 +293,7 @@ export default class extends Channel {
const o = new Reversi(game.map, {
isLlotheo: game.isLlotheo,
canPutEverywhere: game.canPutEverywhere,
loopedBoard: game.loopedBoard
loopedBoard: game.loopedBoard,
});
// 盤面の状態を再生
@@ -320,7 +320,7 @@ export default class extends Channel {
const log = {
at: new Date(),
color: myColor,
pos
pos,
};
const crc32 = CRC32.str(game.logs.map(x => x.pos.toString()).join('') + pos.toString()).toString();
@@ -331,17 +331,17 @@ export default class extends Channel {
crc32,
isEnded: o.isEnded,
winnerId: winner,
logs: game.logs
logs: game.logs,
});
publishReversiGameStream(this.gameId!, 'set', Object.assign(log, {
next: o.turn
next: o.turn,
}));
if (o.isEnded) {
publishReversiGameStream(this.gameId!, 'ended', {
winnerId: winner,
game: await ReversiGames.pack(this.gameId!, this.user)
game: await ReversiGames.pack(this.gameId!, this.user),
});
}
}

View File

@@ -23,7 +23,7 @@ export default class extends Channel {
if (body.id == null) return;
const matching = await ReversiMatchings.findOne({
parentId: this.user!.id,
childId: body.id
childId: body.id,
});
if (matching == null) return;
publishMainStream(matching.childId, 'reversiInvited', await ReversiMatchings.pack(matching, { id: matching.childId }));

View File

@@ -32,13 +32,13 @@ export default class extends Channel {
// リプライなら再pack
if (note.replyId != null) {
note.reply = await Notes.pack(note.replyId, this.user, {
detail: true
detail: true,
});
}
// Renoteなら再pack
if (note.renoteId != null) {
note.renote = await Notes.pack(note.renoteId, this.user, {
detail: true
detail: true,
});
}

View File

@@ -31,7 +31,7 @@ export default class extends Channel {
// Renoteなら再pack
if (note.renoteId != null) {
note.renote = await Notes.pack(note.renoteId, this.user, {
detail: true
detail: true,
});
}

View File

@@ -32,7 +32,7 @@ export default class extends Channel {
if (['followers', 'specified'].includes(note.visibility)) {
note = await Notes.pack(note.id, this.user!, {
detail: true
detail: true,
});
if (note.isHidden) {
@@ -42,13 +42,13 @@ export default class extends Channel {
// リプライなら再pack
if (note.replyId != null) {
note.reply = await Notes.pack(note.replyId, this.user!, {
detail: true
detail: true,
});
}
// Renoteなら再pack
if (note.renoteId != null) {
note.renote = await Notes.pack(note.renoteId, this.user!, {
detail: true
detail: true,
});
}
}

View File

@@ -37,7 +37,7 @@ export default class extends Channel {
if (['followers', 'specified'].includes(note.visibility)) {
note = await Notes.pack(note.id, this.user!, {
detail: true
detail: true,
});
if (note.isHidden) {
@@ -47,13 +47,13 @@ export default class extends Channel {
// リプライなら再pack
if (note.replyId != null) {
note.reply = await Notes.pack(note.replyId, this.user!, {
detail: true
detail: true,
});
}
// Renoteなら再pack
if (note.renoteId != null) {
note.renote = await Notes.pack(note.renoteId, this.user!, {
detail: true
detail: true,
});
}
}

View File

@@ -33,5 +33,5 @@ export default {
channel,
admin,
gamesReversi,
gamesReversiGame
gamesReversiGame,
};

View File

@@ -32,13 +32,13 @@ export default class extends Channel {
// リプライなら再pack
if (note.replyId != null) {
note.reply = await Notes.pack(note.replyId, this.user, {
detail: true
detail: true,
});
}
// Renoteなら再pack
if (note.renoteId != null) {
note.renote = await Notes.pack(note.renoteId, this.user, {
detail: true
detail: true,
});
}

View File

@@ -20,7 +20,7 @@ export default class extends Channel {
if (data.body.note && data.body.note.isHidden) {
const note = await Notes.pack(data.body.note.id, this.user, {
detail: true
detail: true,
});
this.connection.cacheNote(note);
data.body.note = note;
@@ -33,7 +33,7 @@ export default class extends Channel {
if (this.muting.has(data.body.userId)) return;
if (data.body.isHidden) {
const note = await Notes.pack(data.body.id, this.user, {
detail: true
detail: true,
});
this.connection.cacheNote(note);
data.body = note;

View File

@@ -28,7 +28,7 @@ export default class extends Channel {
if (this.groupId) {
const joining = await UserGroupJoinings.findOne({
userId: this.user!.id,
userGroupId: this.groupId
userGroupId: this.groupId,
});
if (joining == null) {

View File

@@ -28,7 +28,7 @@ export default class extends Channel {
});
ev.emit('requestQueueStatsLog', {
id: body.id,
length: body.length
length: body.length,
});
break;
}

View File

@@ -28,7 +28,7 @@ export default class extends Channel {
});
ev.emit('requestServerStatsLog', {
id: body.id,
length: body.length
length: body.length,
});
break;
}

View File

@@ -21,7 +21,7 @@ export default class extends Channel {
// Check existence and owner
const list = await UserLists.findOne({
id: this.listId,
userId: this.user!.id
userId: this.user!.id,
});
if (!list) return;
@@ -40,7 +40,7 @@ export default class extends Channel {
where: {
userListId: this.listId,
},
select: ['userId']
select: ['userId'],
});
this.listUsers = users.map(x => x.userId);
@@ -52,7 +52,7 @@ export default class extends Channel {
if (['followers', 'specified'].includes(note.visibility)) {
note = await Notes.pack(note.id, this.user, {
detail: true
detail: true,
});
if (note.isHidden) {
@@ -62,13 +62,13 @@ export default class extends Channel {
// リプライなら再pack
if (note.replyId != null) {
note.reply = await Notes.pack(note.replyId, this.user, {
detail: true
detail: true,
});
}
// Renoteなら再pack
if (note.renoteId != null) {
note.renote = await Notes.pack(note.renoteId, this.user, {
detail: true
detail: true,
});
}
}

View File

@@ -203,8 +203,8 @@ export default class Connection {
code: e.code,
id: e.id,
kind: e.kind,
...(e.info ? { info: e.info } : {})
}
...(e.info ? { info: e.info } : {}),
},
});
});
}
@@ -281,7 +281,7 @@ export default class Connection {
public sendMessageToWs(type: string, payload: any) {
this.wsConnection.send(JSON.stringify({
type: type,
body: payload
body: payload,
}));
}
@@ -305,7 +305,7 @@ export default class Connection {
if (pong) {
this.sendMessageToWs('connected', {
id: id
id: id,
});
}
}
@@ -358,9 +358,9 @@ export default class Connection {
private async updateFollowing() {
const followings = await Followings.find({
where: {
followerId: this.user!.id
followerId: this.user!.id,
},
select: ['followeeId']
select: ['followeeId'],
});
this.following = new Set<string>(followings.map(x => x.followeeId));
@@ -370,9 +370,9 @@ export default class Connection {
private async updateMuting() {
const mutings = await Mutings.find({
where: {
muterId: this.user!.id
muterId: this.user!.id,
},
select: ['muteeId']
select: ['muteeId'],
});
this.muting = new Set<string>(mutings.map(x => x.muteeId));
@@ -382,9 +382,9 @@ export default class Connection {
private async updateBlocking() { // ここでいうBlockingは被Blockingの意
const blockings = await Blockings.find({
where: {
blockeeId: this.user!.id
blockeeId: this.user!.id,
},
select: ['blockerId']
select: ['blockerId'],
});
this.blocking = new Set<string>(blockings.map(x => x.blockerId));
@@ -394,9 +394,9 @@ export default class Connection {
private async updateFollowingChannels() {
const followings = await ChannelFollowings.find({
where: {
followerId: this.user!.id
followerId: this.user!.id,
},
select: ['followeeId']
select: ['followeeId'],
});
this.followingChannels = new Set<string>(followings.map(x => x.followeeId));
@@ -405,7 +405,7 @@ export default class Connection {
@autobind
private async updateUserProfile() {
this.userProfile = await UserProfiles.findOne({
userId: this.user!.id
userId: this.user!.id,
});
}