add logic and more test to saveMessage

This commit is contained in:
grimhilt
2023-04-01 15:07:49 +02:00
parent 7f28823758
commit 1d761fa6df
2 changed files with 71 additions and 30 deletions

View File

@@ -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);
}
}
}