|
|
|
@ -14,7 +14,7 @@ import { MessageModel } from '../models/message';
|
|
|
|
|
import { ApiV2 } from '../opengroup/opengroupV2';
|
|
|
|
|
|
|
|
|
|
import _ from 'lodash';
|
|
|
|
|
import { ConversationController } from '../session/conversations';
|
|
|
|
|
import { getConversationController } from '../session/conversations';
|
|
|
|
|
import { BlockedNumberController } from '../util/blockedNumberController';
|
|
|
|
|
import {
|
|
|
|
|
adminLeaveClosedGroup,
|
|
|
|
@ -136,7 +136,7 @@ export async function deleteOpenGroupMessages(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function blockConvoById(conversationId: string) {
|
|
|
|
|
const conversation = ConversationController.getInstance().get(conversationId);
|
|
|
|
|
const conversation = getConversationController().get(conversationId);
|
|
|
|
|
|
|
|
|
|
if (!conversation.id || conversation.isPublic()) {
|
|
|
|
|
return;
|
|
|
|
@ -151,7 +151,7 @@ export async function blockConvoById(conversationId: string) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function unblockConvoById(conversationId: string) {
|
|
|
|
|
const conversation = ConversationController.getInstance().get(conversationId);
|
|
|
|
|
const conversation = getConversationController().get(conversationId);
|
|
|
|
|
|
|
|
|
|
if (!conversation) {
|
|
|
|
|
// we assume it's a block contact and not group.
|
|
|
|
@ -172,37 +172,33 @@ export async function unblockConvoById(conversationId: string) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function showUpdateGroupNameByConvoId(conversationId: string) {
|
|
|
|
|
const conversation = ConversationController.getInstance().get(conversationId);
|
|
|
|
|
const conversation = getConversationController().get(conversationId);
|
|
|
|
|
if (conversation.isMediumGroup()) {
|
|
|
|
|
// make sure all the members' convo exists so we can add or remove them
|
|
|
|
|
await Promise.all(
|
|
|
|
|
conversation
|
|
|
|
|
.get('members')
|
|
|
|
|
.map(m =>
|
|
|
|
|
ConversationController.getInstance().getOrCreateAndWait(m, ConversationTypeEnum.PRIVATE)
|
|
|
|
|
)
|
|
|
|
|
.map(m => getConversationController().getOrCreateAndWait(m, ConversationTypeEnum.PRIVATE))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
window.inboxStore?.dispatch(updateGroupNameModal({ conversationId }));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function showUpdateGroupMembersByConvoId(conversationId: string) {
|
|
|
|
|
const conversation = ConversationController.getInstance().get(conversationId);
|
|
|
|
|
const conversation = getConversationController().get(conversationId);
|
|
|
|
|
if (conversation.isMediumGroup()) {
|
|
|
|
|
// make sure all the members' convo exists so we can add or remove them
|
|
|
|
|
await Promise.all(
|
|
|
|
|
conversation
|
|
|
|
|
.get('members')
|
|
|
|
|
.map(m =>
|
|
|
|
|
ConversationController.getInstance().getOrCreateAndWait(m, ConversationTypeEnum.PRIVATE)
|
|
|
|
|
)
|
|
|
|
|
.map(m => getConversationController().getOrCreateAndWait(m, ConversationTypeEnum.PRIVATE))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
window.inboxStore?.dispatch(updateGroupMembersModal({ conversationId }));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function showLeaveGroupByConvoId(conversationId: string) {
|
|
|
|
|
const conversation = ConversationController.getInstance().get(conversationId);
|
|
|
|
|
const conversation = getConversationController().get(conversationId);
|
|
|
|
|
|
|
|
|
|
if (!conversation.isGroup()) {
|
|
|
|
|
throw new Error('showLeaveGroupDialog() called with a non group convo.');
|
|
|
|
@ -242,7 +238,7 @@ export function showInviteContactByConvoId(conversationId: string) {
|
|
|
|
|
window.inboxStore?.dispatch(updateInviteContactModal({ conversationId }));
|
|
|
|
|
}
|
|
|
|
|
export async function onMarkAllReadByConvoId(conversationId: string) {
|
|
|
|
|
const conversation = ConversationController.getInstance().get(conversationId);
|
|
|
|
|
const conversation = getConversationController().get(conversationId);
|
|
|
|
|
|
|
|
|
|
await conversation.markReadBouncy(Date.now());
|
|
|
|
|
}
|
|
|
|
@ -256,7 +252,7 @@ export function showRemoveModeratorsByConvoId(conversationId: string) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function markAllReadByConvoId(conversationId: string) {
|
|
|
|
|
const conversation = ConversationController.getInstance().get(conversationId);
|
|
|
|
|
const conversation = getConversationController().get(conversationId);
|
|
|
|
|
await conversation.markReadBouncy(Date.now());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -264,7 +260,7 @@ export async function setNotificationForConvoId(
|
|
|
|
|
conversationId: string,
|
|
|
|
|
selected: ConversationNotificationSettingType
|
|
|
|
|
) {
|
|
|
|
|
const conversation = ConversationController.getInstance().get(conversationId);
|
|
|
|
|
const conversation = getConversationController().get(conversationId);
|
|
|
|
|
|
|
|
|
|
const existingSettings = conversation.get('triggerNotificationsFor');
|
|
|
|
|
if (existingSettings !== selected) {
|
|
|
|
@ -273,7 +269,7 @@ export async function setNotificationForConvoId(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
export async function clearNickNameByConvoId(conversationId: string) {
|
|
|
|
|
const conversation = ConversationController.getInstance().get(conversationId);
|
|
|
|
|
const conversation = getConversationController().get(conversationId);
|
|
|
|
|
await conversation.setNickname('');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -282,7 +278,7 @@ export function showChangeNickNameByConvoId(conversationId: string) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function deleteMessagesByConvoIdNoConfirmation(conversationId: string) {
|
|
|
|
|
const conversation = ConversationController.getInstance().get(conversationId);
|
|
|
|
|
const conversation = getConversationController().get(conversationId);
|
|
|
|
|
await removeAllMessagesInConversation(conversationId);
|
|
|
|
|
window.inboxStore?.dispatch(
|
|
|
|
|
conversationReset({
|
|
|
|
@ -325,7 +321,7 @@ export async function setDisappearingMessagesByConvoId(
|
|
|
|
|
conversationId: string,
|
|
|
|
|
seconds: number | undefined
|
|
|
|
|
) {
|
|
|
|
|
const conversation = ConversationController.getInstance().get(conversationId);
|
|
|
|
|
const conversation = getConversationController().get(conversationId);
|
|
|
|
|
|
|
|
|
|
if (!seconds || seconds <= 0) {
|
|
|
|
|
await conversation.updateExpirationTimer(null);
|
|
|
|
@ -340,7 +336,7 @@ export async function setDisappearingMessagesByConvoId(
|
|
|
|
|
* If this is a reupload, the old profileKey is used, otherwise a new one is generated
|
|
|
|
|
*/
|
|
|
|
|
export async function uploadOurAvatar(newAvatarDecrypted?: ArrayBuffer) {
|
|
|
|
|
const ourConvo = ConversationController.getInstance().get(UserUtils.getOurPubKeyStrFromCache());
|
|
|
|
|
const ourConvo = getConversationController().get(UserUtils.getOurPubKeyStrFromCache());
|
|
|
|
|
if (!ourConvo) {
|
|
|
|
|
window.log.warn('ourConvo not found... This is not a valid case');
|
|
|
|
|
return;
|
|
|
|
|