Adding conditional to prevent adding multiple approval sync messages for the acceptor of the request.

This commit is contained in:
warrickct 2022-02-23 14:08:34 +11:00
parent 2b84a53959
commit ba30dc57c2

View file

@ -141,18 +141,20 @@ const handleContactReceived = async (
}
if (contactReceived.isApproved === true) {
// checking for existence of field on protobuf
await contactConvo.setIsApproved(Boolean(contactReceived.isApproved));
// TODO: add message search in convo for pre-existing msgRequestResponse msg only happens once per convo
await contactConvo.addSingleOutgoingMessage({
sent_at: _.toNumber(envelope.timestamp),
messageRequestResponse: {
isApproved: 1,
},
unread: 1, // 1 means unread
expireTimer: 0,
});
contactConvo.updateLastMessage();
if (!contactConvo.isApproved()) {
// checking for existence of field on protobuf
await contactConvo.setIsApproved(Boolean(contactReceived.isApproved));
// TODO: add message search in convo for pre-existing msgRequestResponse msg only happens once per convo
await contactConvo.addSingleOutgoingMessage({
sent_at: _.toNumber(envelope.timestamp),
messageRequestResponse: {
isApproved: 1,
},
unread: 1, // 1 means unread
expireTimer: 0,
});
contactConvo.updateLastMessage();
}
if (contactReceived.didApproveMe === true) {
// checking for existence of field on message