diff --git a/services/gunDB/contact-api/events.js b/services/gunDB/contact-api/events.js index 0513e195..c50ad89d 100644 --- a/services/gunDB/contact-api/events.js +++ b/services/gunDB/contact-api/events.js @@ -586,7 +586,8 @@ const onChats = (cb, gun, user, SEA) => { recipientAvatar: '', recipientDisplayName: Utils.defaultName(recipientPK), recipientPublicKey: recipientPK, - didDisconnect + didDisconnect, + id: recipientPK + incomingID } } @@ -625,7 +626,8 @@ const onChats = (cb, gun, user, SEA) => { recipientAvatar: '', recipientDisplayName: Utils.defaultName(recipientPK), recipientPublicKey: recipientPK, - didDisconnect + didDisconnect, + id: recipientPK + incomingFeedID } } diff --git a/services/gunDB/contact-api/schema.js b/services/gunDB/contact-api/schema.js index fceb2d11..e7dc0b5b 100644 --- a/services/gunDB/contact-api/schema.js +++ b/services/gunDB/contact-api/schema.js @@ -65,6 +65,8 @@ exports.isChatMessage = item => { * outgoing/incoming feed paradigm. It combines both the outgoing and incoming * messages into one data structure plus metada about the chat. * @typedef {object} Chat + * @prop {string} id Chats now have IDs because of disconnect. + * RecipientPublicKey will no longer be unique. * @prop {string|null} recipientAvatar Base64 encoded image. * @prop {string} recipientPublicKey A way to uniquely identify each chat. * @prop {ChatMessage[]} messages Sorted from most recent to least recent. @@ -107,6 +109,10 @@ exports.isChat = item => { return false } + if (typeof obj.id !== 'string') { + return false + } + return obj.messages.every(msg => exports.isChatMessage(msg)) }