Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Apr 25, 2025. It is now read-only.
/chat_servicePublic archive

Commit290ca2d

Browse files
committed
__ADD__ some validation
1 parentf77f8fd commit290ca2d

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

‎lib/controllers/room_controller.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,16 @@ exports.createRoom = async (io, socket, data, callback) => {
200200
};
201201

202202

203-
exports.isNew=async(io,socket,data,callback)=>{
203+
exports.notNew=async(io,socket,data,callback)=>{
204204

205205
const{
206206
room_id
207207
}=data;
208208
try{
209209
log({
210-
'isNew':data
210+
'notNew':data
211211
});
212-
constvalid=validator.joi.validate(data,validator.isNew);
212+
constvalid=validator.joi.validate(data,validator.notNew);
213213
if(valid.error){
214214
elog({
215215
'isNew validation error':valid.error
@@ -366,10 +366,10 @@ exports.choosePsychologist = async (io, socket, data, callback) => {
366366

367367
exports.expireTransaction=async(io,socket,data,callback)=>{
368368
const{
369-
room_id,
370-
user_id
369+
room_id
371370
}=data;
372371
try{
372+
constuser_id=socket.handshake.query.user_id;
373373
log({
374374
'expireTransaction data':data
375375
});

‎lib/handlers/socket_handler.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ module.exports = io => {
126126
});
127127

128128

129-
socket.on('is_new',(data,callback)=>{
129+
socket.on('not_new',(data,callback)=>{
130130

131131
log('is_new triggered');
132-
room_controller.isNew(io,socket,data,callback);
132+
room_controller.notNew(io,socket,data,callback);
133133

134134
});
135135

‎lib/utils/validator.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,12 @@ exports.choosePsychologist = joi.object().keys({
5959
access_token:joi.optional()
6060
});
6161

62+
exports.notNew=joi.object().keys({
63+
room_id:joi.string().required().regex(/^[a-f\d]{24}$/i)
64+
});
65+
66+
exports.expireTransaction=joi.object().keys({
67+
room_id:joi.string().required().regex(/^[a-f\d]{24}$/i)
68+
})
6269

6370
exports.joi=joi;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp