diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-03-11 18:08:26 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-03-11 18:08:26 +0900 |
| commit | bd79352e8005bd8fe0ffa846e3318bc49b3fdd36 (patch) | |
| tree | 5a6a266ae92587c654d0089d493dc57a0ac3903e /src/api/endpoints/othello/match.ts | |
| parent | #1231 (diff) | |
| download | sharkey-bd79352e8005bd8fe0ffa846e3318bc49b3fdd36.tar.gz sharkey-bd79352e8005bd8fe0ffa846e3318bc49b3fdd36.tar.bz2 sharkey-bd79352e8005bd8fe0ffa846e3318bc49b3fdd36.zip | |
#1204
Diffstat (limited to 'src/api/endpoints/othello/match.ts')
| -rw-r--r-- | src/api/endpoints/othello/match.ts | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/api/endpoints/othello/match.ts b/src/api/endpoints/othello/match.ts index 640be9cb57..b73e105ef0 100644 --- a/src/api/endpoints/othello/match.ts +++ b/src/api/endpoints/othello/match.ts @@ -2,7 +2,7 @@ import $ from 'cafy'; import Matching, { pack as packMatching } from '../../models/othello-matching'; import Game, { pack as packGame } from '../../models/othello-game'; import User from '../../models/user'; -import { publishOthelloStream } from '../../event'; +import publishUserStream, { publishOthelloStream } from '../../event'; import { eighteight } from '../../../common/othello/maps'; module.exports = (params, user) => new Promise(async (res, rej) => { @@ -48,6 +48,14 @@ module.exports = (params, user) => new Promise(async (res, rej) => { res(await packGame(game, user)); publishOthelloStream(exist.parent_id, 'matched', await packGame(game, exist.parent_id)); + + const other = await Matching.count({ + child_id: user._id + }); + + if (other == 0) { + publishUserStream(user._id, 'othello_no_invites'); + } } else { // Fetch child const child = await User.findOne({ @@ -77,7 +85,11 @@ module.exports = (params, user) => new Promise(async (res, rej) => { // Reponse res(); + const packed = await packMatching(matching, child); + // 招待 - publishOthelloStream(child._id, 'invited', await packMatching(matching, child)); + publishOthelloStream(child._id, 'invited', packed); + + publishUserStream(child._id, 'othello_invited', packed); } }); |