Support for joining New Groups via invite links
This commit is contained in:
parent
c0510b08a5
commit
a48b3e381e
41 changed files with 2532 additions and 381 deletions
|
@ -2,6 +2,8 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { debounce, reduce, uniq, without } from 'lodash';
|
||||
import PQueue from 'p-queue';
|
||||
|
||||
import dataInterface from './sql/Client';
|
||||
import {
|
||||
ConversationModelCollectionType,
|
||||
|
@ -150,6 +152,11 @@ export class ConversationController {
|
|||
return this._conversations.add(attributes);
|
||||
}
|
||||
|
||||
dangerouslyRemoveById(id: string): void {
|
||||
this._conversations.remove(id);
|
||||
this._conversations.resetLookups();
|
||||
}
|
||||
|
||||
getOrCreate(
|
||||
identifier: string | null,
|
||||
type: ConversationAttributesTypeType,
|
||||
|
@ -283,6 +290,16 @@ export class ConversationController {
|
|||
return this.ensureContactIds({ e164, uuid, highTrust: true });
|
||||
}
|
||||
|
||||
getOurConversationIdOrThrow(): string {
|
||||
const conversationId = this.getOurConversationId();
|
||||
if (!conversationId) {
|
||||
throw new Error(
|
||||
'getOurConversationIdOrThrow: Failed to fetch ourConversationId'
|
||||
);
|
||||
}
|
||||
return conversationId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a UUID and/or an E164, resolves to a string representing the local
|
||||
* database id of the given contact. In high trust mode, it may create new contacts,
|
||||
|
@ -713,7 +730,30 @@ export class ConversationController {
|
|||
ConversationCollection: window.Whisper.ConversationCollection,
|
||||
});
|
||||
|
||||
this._conversations.add(collection.models);
|
||||
// Get rid of temporary conversations
|
||||
const temporaryConversations = collection.filter(conversation =>
|
||||
Boolean(conversation.get('isTemporary'))
|
||||
);
|
||||
|
||||
if (temporaryConversations.length) {
|
||||
window.log.warn(
|
||||
`ConversationController: Removing ${temporaryConversations.length} temporary conversations`
|
||||
);
|
||||
}
|
||||
const queue = new PQueue({ concurrency: 3, timeout: 1000 * 60 * 2 });
|
||||
queue.addAll(
|
||||
temporaryConversations.map(item => async () => {
|
||||
await removeConversation(item.id, {
|
||||
Conversation: window.Whisper.Conversation,
|
||||
});
|
||||
})
|
||||
);
|
||||
await queue.onIdle();
|
||||
|
||||
// Hydrate the final set of conversations
|
||||
this._conversations.add(
|
||||
collection.filter(conversation => !conversation.get('isTemporary'))
|
||||
);
|
||||
|
||||
this._initialFetchComplete = true;
|
||||
|
||||
|
@ -725,10 +765,6 @@ export class ConversationController {
|
|||
updateConversation(conversation.attributes);
|
||||
}
|
||||
|
||||
if (!conversation.get('lastMessage')) {
|
||||
await conversation.updateLastMessage();
|
||||
}
|
||||
|
||||
// In case a too-large draft was saved to the database
|
||||
const draft = conversation.get('draft');
|
||||
if (draft && draft.length > MAX_MESSAGE_BODY_LENGTH) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue