|
|
@ -243,6 +243,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
async getPendingFriendRequests(direction) {
|
|
|
|
|
|
|
|
// Theoretically all ouur messages could be friend requests, thus we have to unfortunately go through each one :(
|
|
|
|
|
|
|
|
// We are most likely to find the friend request in the more recent conversations first
|
|
|
|
|
|
|
|
const messages = await window.Signal.Data.getMessagesByConversation(this.id, {
|
|
|
|
|
|
|
|
MessageCollection: Whisper.MessageCollection,
|
|
|
|
|
|
|
|
limit: Number.MAX_VALUE,
|
|
|
|
|
|
|
|
}).reverse();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Get the messages that are matching the direction and the friendStatus
|
|
|
|
|
|
|
|
return messages.filter(m => (m.direction === direction && m.friendStatus === 'pending'));
|
|
|
|
|
|
|
|
},
|
|
|
|
getPropsForListItem() {
|
|
|
|
getPropsForListItem() {
|
|
|
|
const result = {
|
|
|
|
const result = {
|
|
|
|
...this.format(),
|
|
|
|
...this.format(),
|
|
|
@ -420,6 +431,10 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.set({ keyExchangeCompleted: completed });
|
|
|
|
this.set({ keyExchangeCompleted: completed });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await window.Signal.Data.updateConversation(this.id, this.attributes, {
|
|
|
|
|
|
|
|
Conversation: Whisper.Conversation,
|
|
|
|
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
getFriendRequestStatus() {
|
|
|
|
getFriendRequestStatus() {
|
|
|
|
return this.get('friendRequestStatus');
|
|
|
|
return this.get('friendRequestStatus');
|
|
|
@ -667,7 +682,7 @@
|
|
|
|
async addFriendRequest(body, options = {}) {
|
|
|
|
async addFriendRequest(body, options = {}) {
|
|
|
|
const mergedOptions = {
|
|
|
|
const mergedOptions = {
|
|
|
|
status: 'pending',
|
|
|
|
status: 'pending',
|
|
|
|
type: 'incoming',
|
|
|
|
direction: 'incoming',
|
|
|
|
preKeyBundle: null,
|
|
|
|
preKeyBundle: null,
|
|
|
|
...options,
|
|
|
|
...options,
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -708,8 +723,8 @@
|
|
|
|
unread: 1,
|
|
|
|
unread: 1,
|
|
|
|
from: this.id,
|
|
|
|
from: this.id,
|
|
|
|
to: this.ourNumber,
|
|
|
|
to: this.ourNumber,
|
|
|
|
status: mergedOptions.status,
|
|
|
|
friendStatus: mergedOptions.status,
|
|
|
|
requestType: mergedOptions.type,
|
|
|
|
direction: mergedOptions.direction,
|
|
|
|
body,
|
|
|
|
body,
|
|
|
|
preKeyBundle: mergedOptions.preKeyBundle,
|
|
|
|
preKeyBundle: mergedOptions.preKeyBundle,
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -936,6 +951,8 @@
|
|
|
|
now
|
|
|
|
now
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Maybe create the friend request here?
|
|
|
|
|
|
|
|
// TODO: Make sure we're not adding duplicate messages if keys haven't been exchanged
|
|
|
|
const messageWithSchema = await upgradeMessageSchema({
|
|
|
|
const messageWithSchema = await upgradeMessageSchema({
|
|
|
|
type: 'outgoing',
|
|
|
|
type: 'outgoing',
|
|
|
|
body,
|
|
|
|
body,
|
|
|
|