add logic and more test to saveMessage
This commit is contained in:
@@ -22,13 +22,6 @@ function createAddress(elt) {
|
||||
return `${elt.mailbox}@${elt.host}`;
|
||||
}
|
||||
|
||||
async function initiateRoom(envelope, ownerId, messageId, isSeen) {
|
||||
await createRoom(envelope.subject, ownerId, messageId).then(async (roomId) => {
|
||||
// todo register members
|
||||
await registerMessageInRoom(messageId, roomId, isSeen, envelope.date);
|
||||
});
|
||||
}
|
||||
|
||||
const roomType = {
|
||||
ROOM: 0,
|
||||
CHANNEL: 1,
|
||||
@@ -104,7 +97,6 @@ class registerMessageInApp {
|
||||
await registerMessageInRoom(this.messageId, roomId, this.isSeen, this.envelope.date);
|
||||
await this.registerMembers(roomId);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
async createOrRegisterOnMembers(roomId) {
|
||||
@@ -134,10 +126,10 @@ class registerMessageInApp {
|
||||
} else {
|
||||
// it is not a reply and not a dm
|
||||
// so it is a channel, which can be possibly a group
|
||||
initiateRoom(this.envelope, this.ownerId, this.messageId, this.isSeen);
|
||||
this.initiateRoom(this.ownerId, roomType.ROOM);
|
||||
}
|
||||
} else {
|
||||
await this.createOrRegisterOnExistence(this.ownerId, roomType.CHANNEL);
|
||||
await this.createOrRegisterOnExistence(this.ownerId, roomType.ROOM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user