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

Commitf638cb5

Browse files
committed
__ADD__ notify message and automated message
1 parentf507263 commitf638cb5

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

‎lib/controllers/room_controller.js‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ exports.createRoom = async (io, socket, data, callback) => {
110110
type,
111111
state,
112112
unreadMessages,
113-
lastMessage,
113+
automatedMessage,
114+
notifyMessage,
114115
owner_id,
115116
is_new,
116117
}=data;
@@ -132,9 +133,10 @@ exports.createRoom = async (io, socket, data, callback) => {
132133
constsockets=[];
133134

134135
constsaved=awaitroom_dao.joinSocket(_id,socket.id,creator_id);
135-
constsaveIncrementalId=awaitchat_dao.incrementId(_id);
136-
lastMessage.incremental_id=saveIncrementalId;
137-
136+
constnotifyIncrId=awaitchat_dao.incrementId(_id);
137+
constautoIncrId=awaitchat_dao.incrementId(_id);
138+
notifyMessage.incremental_id=notifyIncrId;
139+
automatedMessage.incremental_id=autoIncrId;
138140
if(saved){
139141
for(constmemberofmembers){
140142
constmemberSockets=awaituser_dao.getUserSocketsById(member.user_id);
@@ -151,9 +153,10 @@ exports.createRoom = async (io, socket, data, callback) => {
151153
log({
152154
'createRoom sockets to be notified':sockets
153155
});
154-
constkeyedMessage=newkm('newMessage',JSON.stringify(lastMessage));
156+
constnotifyKeyedMessage=newkm('newMessage',JSON.stringify(notifyMessage));
157+
constautoKeyedMessage=newkm('newMessage',JSON.stringify(automatedMessage));
155158
producer.send([Object.assign({},config.PAYLOAD,{
156-
messages:[keyedMessage]
159+
messages:[notifyKeyedMessage,autoKeyedMessage]
157160
})],function(e,result){
158161
if(e){
159162
elog({
@@ -175,7 +178,7 @@ exports.createRoom = async (io, socket, data, callback) => {
175178
* created and is supposed to emit a "join_room" after reciving
176179
*/
177180
log({
178-
'createRoomlastMessage':lastMessage
181+
'createRoomproducer result':result
179182
});
180183
io.to(socket).emit('new_room',Object.assign({},config.RESPONSE,{
181184
message:'new_room',
@@ -188,7 +191,8 @@ exports.createRoom = async (io, socket, data, callback) => {
188191
type,
189192
state,
190193
unreadMessages,
191-
lastMessage,
194+
notifyMessage,
195+
automatedMessage,
192196
owner_id,
193197
is_new,
194198
}
@@ -197,7 +201,10 @@ exports.createRoom = async (io, socket, data, callback) => {
197201
socket.join(_id);
198202
callback(Object.assign({},config.RESPONSE,{
199203
message:'room_created',
200-
data:lastMessage
204+
data:{
205+
notifyMessage,
206+
automatedMessage
207+
}
201208
}));
202209

203210
}else

‎lib/utils/validator.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ exports.createRoom = joi.object().keys({
2121
type:joi.string().required(),
2222
state:joi.string().required(),
2323
unreadMessages:joi.number().required(),
24-
lastMessage:joi.object().required(),
24+
automatedMessage:joi.object().required(),
25+
notifyMessage:joi.object().required(),
2526
owner_id:joi.required(),
2627
is_new:joi.required(),
2728
access_token:joi.optional()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp