Uniformize once and for all the conversation types

no more 'direct'. those are private convos
pull/1576/head
Audric Ackermann 4 years ago
parent 3ec6c6523c
commit a26c5da6cb
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -7,7 +7,7 @@ import { DefaultTheme } from 'styled-components';
import { ConversationController } from '../../session/conversations'; import { ConversationController } from '../../session/conversations';
import { ToastUtils, UserUtils } from '../../session/utils'; import { ToastUtils, UserUtils } from '../../session/utils';
import { initiateGroupUpdate } from '../../session/group'; import { initiateGroupUpdate } from '../../session/group';
import { ConversationModel, ConversationType } from '../../models/conversation'; import { ConversationModel, ConversationTypeEnum } from '../../models/conversation';
import { getCompleteUrlForV2ConvoId } from '../../interactions/conversation'; import { getCompleteUrlForV2ConvoId } from '../../interactions/conversation';
import _ from 'lodash'; import _ from 'lodash';
interface Props { interface Props {
@ -108,7 +108,7 @@ class InviteContactsDialogInner extends React.Component<Props, State> {
pubkeys.forEach(async pubkeyStr => { pubkeys.forEach(async pubkeyStr => {
const privateConvo = await ConversationController.getInstance().getOrCreateAndWait( const privateConvo = await ConversationController.getInstance().getOrCreateAndWait(
pubkeyStr, pubkeyStr,
ConversationType.PRIVATE ConversationTypeEnum.PRIVATE
); );
if (privateConvo) { if (privateConvo) {
@ -125,7 +125,7 @@ class InviteContactsDialogInner extends React.Component<Props, State> {
pubkeys.forEach(async pubkeyStr => { pubkeys.forEach(async pubkeyStr => {
const privateConvo = await ConversationController.getInstance().getOrCreateAndWait( const privateConvo = await ConversationController.getInstance().getOrCreateAndWait(
pubkeyStr, pubkeyStr,
ConversationType.PRIVATE ConversationTypeEnum.PRIVATE
); );
if (privateConvo) { if (privateConvo) {

@ -10,6 +10,7 @@ import { MessageBody } from './MessageBody';
import { ColorType, LocalizerType } from '../../types/Util'; import { ColorType, LocalizerType } from '../../types/Util';
import { ContactName } from './ContactName'; import { ContactName } from './ContactName';
import { PubKey } from '../../session/types'; import { PubKey } from '../../session/types';
import { ConversationTypeEnum } from '../../models/conversation';
interface Props { interface Props {
attachment?: QuotedAttachmentType; attachment?: QuotedAttachmentType;
@ -19,7 +20,7 @@ interface Props {
i18n: LocalizerType; i18n: LocalizerType;
isFromMe: boolean; isFromMe: boolean;
isIncoming: boolean; isIncoming: boolean;
conversationType: 'group' | 'direct'; conversationType: ConversationTypeEnum;
convoId: string; convoId: string;
isPublic?: boolean; isPublic?: boolean;
withContentAbove: boolean; withContentAbove: boolean;

@ -2,12 +2,13 @@ import React from 'react';
import { TypingAnimation } from './TypingAnimation'; import { TypingAnimation } from './TypingAnimation';
import styled from 'styled-components'; import styled from 'styled-components';
import { ConversationTypeEnum } from '../../models/conversation';
interface TypingBubbleProps { interface TypingBubbleProps {
avatarPath?: string; avatarPath?: string;
phoneNumber: string; phoneNumber: string;
displayedName: string | null; displayedName: string | null;
conversationType: string; conversationType: ConversationTypeEnum;
isTyping: boolean; isTyping: boolean;
} }
@ -24,7 +25,7 @@ const TypingBubbleContainer = styled.div<TypingBubbleProps>`
`; `;
export const TypingBubble = (props: TypingBubbleProps) => { export const TypingBubble = (props: TypingBubbleProps) => {
if (props.conversationType === 'group') { if (props.conversationType === ConversationTypeEnum.GROUP) {
return <></>; return <></>;
} }

@ -2,16 +2,10 @@ import React from 'react';
import { ConversationListItemWithDetails } from '../ConversationListItem'; import { ConversationListItemWithDetails } from '../ConversationListItem';
import { RowRendererParamsType } from '../LeftPane'; import { RowRendererParamsType } from '../LeftPane';
import { SessionButton, SessionButtonColor, SessionButtonType } from './SessionButton';
import { AutoSizer, List } from 'react-virtualized'; import { AutoSizer, List } from 'react-virtualized';
import { ConversationType as ReduxConversationType } from '../../state/ducks/conversations'; import { ConversationType as ReduxConversationType } from '../../state/ducks/conversations';
import { SessionClosableOverlay, SessionClosableOverlayType } from './SessionClosableOverlay';
import { ToastUtils } from '../../session/utils';
import { DefaultTheme } from 'styled-components'; import { DefaultTheme } from 'styled-components';
import { LeftPaneSectionHeader } from './LeftPaneSectionHeader'; import { LeftPaneSectionHeader } from './LeftPaneSectionHeader';
import { ConversationController } from '../../session/conversations';
import { PubKey } from '../../session/types';
import { ConversationType } from '../../models/conversation';
import autoBind from 'auto-bind'; import autoBind from 'auto-bind';
export interface Props { export interface Props {

@ -24,11 +24,8 @@ import { DefaultTheme } from 'styled-components';
import { LeftPaneSectionHeader } from './LeftPaneSectionHeader'; import { LeftPaneSectionHeader } from './LeftPaneSectionHeader';
import { ConversationController } from '../../session/conversations'; import { ConversationController } from '../../session/conversations';
import { OpenGroup } from '../../opengroup/opengroupV1/OpenGroup'; import { OpenGroup } from '../../opengroup/opengroupV1/OpenGroup';
import { ConversationType } from '../../models/conversation'; import { ConversationTypeEnum } from '../../models/conversation';
import { import { openGroupV2CompleteURLRegex } from '../../opengroup/utils/OpenGroupUtils';
getOpenGroupV2ConversationId,
openGroupV2CompleteURLRegex,
} from '../../opengroup/utils/OpenGroupUtils';
import { joinOpenGroupV2WithUIEvents } from '../../opengroup/opengroupV2/JoinOpenGroupV2'; import { joinOpenGroupV2WithUIEvents } from '../../opengroup/opengroupV2/JoinOpenGroupV2';
export interface Props { export interface Props {
@ -374,7 +371,7 @@ export class LeftPaneMessageSection extends React.Component<Props, State> {
if (!error) { if (!error) {
await ConversationController.getInstance().getOrCreateAndWait( await ConversationController.getInstance().getOrCreateAndWait(
pubkey, pubkey,
ConversationType.PRIVATE ConversationTypeEnum.PRIVATE
); );
openConversationExternal(pubkey); openConversationExternal(pubkey);
} else { } else {

@ -11,6 +11,7 @@ import { SessionSpinner } from './SessionSpinner';
import { PillDivider } from './PillDivider'; import { PillDivider } from './PillDivider';
import { DefaultTheme } from 'styled-components'; import { DefaultTheme } from 'styled-components';
import { UserUtils } from '../../session/utils'; import { UserUtils } from '../../session/utils';
import { ConversationTypeEnum } from '../../models/conversation';
export enum SessionClosableOverlayType { export enum SessionClosableOverlayType {
Message = 'message', Message = 'message',
@ -67,7 +68,9 @@ export class SessionClosableOverlay extends React.Component<Props, State> {
let filteredContactsList = contactsList; let filteredContactsList = contactsList;
const isClosedGroupView = overlayMode === SessionClosableOverlayType.ClosedGroup; const isClosedGroupView = overlayMode === SessionClosableOverlayType.ClosedGroup;
if (isClosedGroupView) { if (isClosedGroupView) {
filteredContactsList = filteredContactsList.filter(c => c.type === 'direct' && !c.isMe); filteredContactsList = filteredContactsList.filter(
c => c.type === ConversationTypeEnum.PRIVATE && !c.isMe
);
} }
return filteredContactsList.map((d: any) => { return filteredContactsList.map((d: any) => {
@ -108,6 +111,8 @@ export class SessionClosableOverlay extends React.Component<Props, State> {
onButtonClick, onButtonClick,
} = this.props; } = this.props;
const { groupName, selectedMembers } = this.state;
const isMessageView = overlayMode === SessionClosableOverlayType.Message; const isMessageView = overlayMode === SessionClosableOverlayType.Message;
const isOpenGroupView = overlayMode === SessionClosableOverlayType.OpenGroup; const isOpenGroupView = overlayMode === SessionClosableOverlayType.OpenGroup;
const isClosedGroupView = overlayMode === SessionClosableOverlayType.ClosedGroup; const isClosedGroupView = overlayMode === SessionClosableOverlayType.ClosedGroup;
@ -141,9 +146,6 @@ export class SessionClosableOverlay extends React.Component<Props, State> {
default: default:
} }
const { groupName, selectedMembers } = this.state;
const ourSessionID = UserUtils.getOurPubKeyStrFromCache();
const contacts = this.getContacts(); const contacts = this.getContacts();
const noContactsForClosedGroup = const noContactsForClosedGroup =

@ -30,6 +30,7 @@ import { getMessageById, getPubkeysInPublicConversation } from '../../../data/da
import autoBind from 'auto-bind'; import autoBind from 'auto-bind';
import { getDecryptedMediaUrl } from '../../../session/crypto/DecryptedAttachmentsManager'; import { getDecryptedMediaUrl } from '../../../session/crypto/DecryptedAttachmentsManager';
import { deleteOpenGroupMessages } from '../../../interactions/conversation'; import { deleteOpenGroupMessages } from '../../../interactions/conversation';
import { ConversationTypeEnum } from '../../../models/conversation';
interface State { interface State {
// Message sending progress // Message sending progress
@ -223,7 +224,7 @@ export class SessionConversation extends React.Component<Props, State> {
const isPublic = selectedConversation.isPublic || false; const isPublic = selectedConversation.isPublic || false;
const isPrivate = selectedConversation.type === 'direct'; const isPrivate = selectedConversation.type === ConversationTypeEnum.PRIVATE;
return ( return (
<SessionTheme theme={this.props.theme}> <SessionTheme theme={this.props.theme}>
<div className="conversation-header">{this.renderHeader()}</div> <div className="conversation-header">{this.renderHeader()}</div>

@ -19,6 +19,7 @@ import { MessageModel } from '../../../models/message';
import { MessageRegularProps } from '../../../models/messageType'; import { MessageRegularProps } from '../../../models/messageType';
import { getMessagesBySentAt } from '../../../data/data'; import { getMessagesBySentAt } from '../../../data/data';
import autoBind from 'auto-bind'; import autoBind from 'auto-bind';
import { ConversationTypeEnum } from '../../../models/conversation';
interface State { interface State {
showScrollButton: boolean; showScrollButton: boolean;
@ -122,7 +123,7 @@ export class SessionMessagesList extends React.Component<Props, State> {
const { showScrollButton } = this.state; const { showScrollButton } = this.state;
let displayedName = null; let displayedName = null;
if (conversation.type === 'direct') { if (conversation.type === ConversationTypeEnum.PRIVATE) {
displayedName = ConversationController.getInstance().getContactProfileNameOrShortenedPubKey( displayedName = ConversationController.getInstance().getContactProfileNameOrShortenedPubKey(
conversationKey conversationKey
); );
@ -247,7 +248,7 @@ export class SessionMessagesList extends React.Component<Props, State> {
return; return;
} }
if (messageProps.conversationType === 'group') { if (messageProps.conversationType === ConversationTypeEnum.GROUP) {
messageProps.weAreAdmin = conversation.groupAdmins?.includes(ourPrimary); messageProps.weAreAdmin = conversation.groupAdmins?.includes(ourPrimary);
} }
// a message is deletable if // a message is deletable if

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { animation, Menu } from 'react-contexify'; import { animation, Menu } from 'react-contexify';
import { ConversationTypeEnum } from '../../../models/conversation';
import { import {
getBlockMenuItem, getBlockMenuItem,
@ -14,7 +15,7 @@ import {
export type PropsContextConversationItem = { export type PropsContextConversationItem = {
triggerId: string; triggerId: string;
type: 'group' | 'direct'; type: ConversationTypeEnum;
isMe: boolean; isMe: boolean;
isPublic?: boolean; isPublic?: boolean;
isBlocked?: boolean; isBlocked?: boolean;
@ -58,7 +59,7 @@ export const ConversationListItemContextMenu = (props: PropsContextConversationI
<Menu id={triggerId} animation={animation.fade}> <Menu id={triggerId} animation={animation.fade}>
{getBlockMenuItem( {getBlockMenuItem(
isMe, isMe,
type === 'direct', type === ConversationTypeEnum.PRIVATE,
isBlocked, isBlocked,
onBlockContact, onBlockContact,
onUnblockContact, onUnblockContact,

@ -3,7 +3,7 @@ import { PubKey } from '../../session/types';
import React from 'react'; import React from 'react';
import * as _ from 'lodash'; import * as _ from 'lodash';
import { ConversationController } from '../../session/conversations'; import { ConversationController } from '../../session/conversations';
import { ConversationType } from '../../models/conversation'; import { ConversationTypeEnum } from '../../models/conversation';
export type ConversationAvatar = { export type ConversationAvatar = {
avatarPath?: string; avatarPath?: string;
@ -55,7 +55,10 @@ export function usingClosedConversationDetails(WrappedComponent: any) {
members = members.slice(0, 2); members = members.slice(0, 2);
const memberConvos = await Promise.all( const memberConvos = await Promise.all(
members.map(async m => members.map(async m =>
ConversationController.getInstance().getOrCreateAndWait(m.key, ConversationType.PRIVATE) ConversationController.getInstance().getOrCreateAndWait(
m.key,
ConversationTypeEnum.PRIVATE
)
) )
); );
const memberAvatars = memberConvos.map(m => { const memberAvatars = memberConvos.map(m => {

@ -1,12 +1,9 @@
import _ from 'lodash'; import _ from 'lodash';
import { getV2OpenGroupRoom } from '../data/opengroups'; import { getV2OpenGroupRoom } from '../data/opengroups';
import { ConversationModel, ConversationType } from '../models/conversation'; import { ConversationModel, ConversationTypeEnum } from '../models/conversation';
import { OpenGroup } from '../opengroup/opengroupV1/OpenGroup'; import { OpenGroup } from '../opengroup/opengroupV1/OpenGroup';
import { ApiV2 } from '../opengroup/opengroupV2'; import { ApiV2 } from '../opengroup/opengroupV2';
import { import { joinOpenGroupV2WithUIEvents } from '../opengroup/opengroupV2/JoinOpenGroupV2';
joinOpenGroupV2WithUIEvents,
parseOpenGroupV2,
} from '../opengroup/opengroupV2/JoinOpenGroupV2';
import { isOpenGroupV2, openGroupV2CompleteURLRegex } from '../opengroup/utils/OpenGroupUtils'; import { isOpenGroupV2, openGroupV2CompleteURLRegex } from '../opengroup/utils/OpenGroupUtils';
import { ConversationController } from '../session/conversations'; import { ConversationController } from '../session/conversations';
import { PubKey } from '../session/types'; import { PubKey } from '../session/types';
@ -224,7 +221,7 @@ async function acceptOpenGroupInvitationV1(serverAddress: string) {
const conversation = await ConversationController.getInstance().getOrCreateAndWait( const conversation = await ConversationController.getInstance().getOrCreateAndWait(
conversationId, conversationId,
ConversationType.GROUP ConversationTypeEnum.GROUP
); );
await conversation.setPublicSource(sslServerUrl, 1); await conversation.setPublicSource(sslServerUrl, 1);

@ -4,7 +4,7 @@ import { getMessageQueue } from '../session';
import { ConversationController } from '../session/conversations'; import { ConversationController } from '../session/conversations';
import { ClosedGroupVisibleMessage } from '../session/messages/outgoing/visibleMessage/ClosedGroupVisibleMessage'; import { ClosedGroupVisibleMessage } from '../session/messages/outgoing/visibleMessage/ClosedGroupVisibleMessage';
import { PubKey } from '../session/types'; import { PubKey } from '../session/types';
import { ToastUtils, UserUtils } from '../session/utils'; import { UserUtils } from '../session/utils';
import { BlockedNumberController } from '../util'; import { BlockedNumberController } from '../util';
import { MessageController } from '../session/messages'; import { MessageController } from '../session/messages';
import { leaveClosedGroup } from '../session/group'; import { leaveClosedGroup } from '../session/group';
@ -39,13 +39,11 @@ import { ReadReceiptMessage } from '../session/messages/outgoing/controlMessage/
import { OpenGroup } from '../opengroup/opengroupV1/OpenGroup'; import { OpenGroup } from '../opengroup/opengroupV1/OpenGroup';
import { OpenGroupUtils } from '../opengroup/utils'; import { OpenGroupUtils } from '../opengroup/utils';
import { ConversationInteraction } from '../interactions'; import { ConversationInteraction } from '../interactions';
import { getV2OpenGroupRoom } from '../data/opengroups';
import { OpenGroupVisibleMessage } from '../session/messages/outgoing/visibleMessage/OpenGroupVisibleMessage'; import { OpenGroupVisibleMessage } from '../session/messages/outgoing/visibleMessage/OpenGroupVisibleMessage';
import { OpenGroupRequestCommonType } from '../opengroup/opengroupV2/ApiUtil'; import { OpenGroupRequestCommonType } from '../opengroup/opengroupV2/ApiUtil';
import { getOpenGroupV2FromConversationId } from '../opengroup/utils/OpenGroupUtils'; import { getOpenGroupV2FromConversationId } from '../opengroup/utils/OpenGroupUtils';
import { ApiV2 } from '../opengroup/opengroupV2';
export enum ConversationType { export enum ConversationTypeEnum {
GROUP = 'group', GROUP = 'group',
PRIVATE = 'private', PRIVATE = 'private',
} }
@ -203,7 +201,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
return OpenGroupUtils.isOpenGroupV1(this.id); return OpenGroupUtils.isOpenGroupV1(this.id);
} }
public isClosedGroup() { public isClosedGroup() {
return this.get('type') === ConversationType.GROUP && !this.isPublic(); return this.get('type') === ConversationTypeEnum.GROUP && !this.isPublic();
} }
public isBlocked() { public isBlocked() {
@ -392,7 +390,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
id: this.id as string, id: this.id as string,
activeAt: this.get('active_at'), activeAt: this.get('active_at'),
avatarPath: this.getAvatarPath() || undefined, avatarPath: this.getAvatarPath() || undefined,
type: this.isPrivate() ? 'direct' : 'group', type: this.isPrivate() ? ConversationTypeEnum.PRIVATE : ConversationTypeEnum.GROUP,
isMe: this.isMe(), isMe: this.isMe(),
isPublic: this.isPublic(), isPublic: this.isPublic(),
isTyping: !!this.typingTimer, isTyping: !!this.typingTimer,
@ -1190,7 +1188,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
public async getProfile(id: string) { public async getProfile(id: string) {
const c = await ConversationController.getInstance().getOrCreateAndWait( const c = await ConversationController.getInstance().getOrCreateAndWait(
id, id,
ConversationType.PRIVATE ConversationTypeEnum.PRIVATE
); );
// We only need to update the profile as they are all stored inside the conversation // We only need to update the profile as they are all stored inside the conversation
@ -1445,7 +1443,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
} }
public isPrivate() { public isPrivate() {
return this.get('type') === ConversationType.PRIVATE; return this.get('type') === ConversationTypeEnum.PRIVATE;
} }
public getAvatarPath() { public getAvatarPath() {
@ -1487,7 +1485,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
const convo = await ConversationController.getInstance().getOrCreateAndWait( const convo = await ConversationController.getInstance().getOrCreateAndWait(
message.get('source'), message.get('source'),
ConversationType.PRIVATE ConversationTypeEnum.PRIVATE
); );
const iconUrl = await convo.getNotificationIcon(); const iconUrl = await convo.getNotificationIcon();

@ -18,7 +18,7 @@ import {
import autoBind from 'auto-bind'; import autoBind from 'auto-bind';
import { saveMessage } from '../../ts/data/data'; import { saveMessage } from '../../ts/data/data';
import { ConversationModel, ConversationType } from './conversation'; import { ConversationModel, ConversationTypeEnum } from './conversation';
import { getSuggestedFilenameSending } from '../types/Attachment'; import { getSuggestedFilenameSending } from '../types/Attachment';
import { actions as conversationActions } from '../state/ducks/conversations'; import { actions as conversationActions } from '../state/ducks/conversations';
import { VisibleMessage } from '../session/messages/outgoing/visibleMessage/VisibleMessage'; import { VisibleMessage } from '../session/messages/outgoing/visibleMessage/VisibleMessage';
@ -480,7 +480,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
authorName: contact.name, authorName: contact.name,
authorProfileName: contact.profileName, authorProfileName: contact.profileName,
authorPhoneNumber: contact.phoneNumber, authorPhoneNumber: contact.phoneNumber,
conversationType: isGroup ? 'group' : 'direct', conversationType: isGroup ? ConversationTypeEnum.GROUP : ConversationTypeEnum.PRIVATE,
convoId, convoId,
attachments: attachments attachments: attachments
.filter((attachment: any) => !attachment.error) .filter((attachment: any) => !attachment.error)
@ -695,7 +695,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
...this.propsForMessage, ...this.propsForMessage,
disableMenu: true, disableMenu: true,
// To ensure that group avatar doesn't show up // To ensure that group avatar doesn't show up
conversationType: 'direct', conversationType: ConversationTypeEnum.PRIVATE,
}, },
errors, errors,
contacts: sortedContacts, contacts: sortedContacts,
@ -911,7 +911,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
return null; return null;
} }
return ConversationController.getInstance().getOrCreate(source, ConversationType.PRIVATE); return ConversationController.getInstance().getOrCreate(source, ConversationTypeEnum.PRIVATE);
} }
public isOutgoing() { public isOutgoing() {

@ -4,6 +4,7 @@ import { v4 as uuidv4 } from 'uuid';
import { QuotedAttachmentType } from '../components/conversation/Quote'; import { QuotedAttachmentType } from '../components/conversation/Quote';
import { AttachmentType } from '../types/Attachment'; import { AttachmentType } from '../types/Attachment';
import { Contact } from '../types/Contact'; import { Contact } from '../types/Contact';
import { ConversationTypeEnum } from './conversation';
export type MessageModelType = 'incoming' | 'outgoing'; export type MessageModelType = 'incoming' | 'outgoing';
export type MessageDeliveryStatus = 'sending' | 'sent' | 'delivered' | 'read' | 'error'; export type MessageDeliveryStatus = 'sending' | 'sent' | 'delivered' | 'read' | 'error';
@ -187,7 +188,7 @@ export interface MessageRegularProps {
authorProfileName?: string; authorProfileName?: string;
/** Note: this should be formatted for display */ /** Note: this should be formatted for display */
authorPhoneNumber: string; authorPhoneNumber: string;
conversationType: 'group' | 'direct'; conversationType: ConversationTypeEnum;
attachments?: Array<AttachmentType>; attachments?: Array<AttachmentType>;
quote?: { quote?: {
text: string; text: string;

@ -1,4 +1,4 @@
import { ConversationModel, ConversationType } from '../../models/conversation'; import { ConversationModel, ConversationTypeEnum } from '../../models/conversation';
import { ConversationController } from '../../session/conversations'; import { ConversationController } from '../../session/conversations';
import { PromiseUtils } from '../../session/utils'; import { PromiseUtils } from '../../session/utils';
import { allowOnlyOneAtATime } from '../../session/utils/Promise'; import { allowOnlyOneAtATime } from '../../session/utils/Promise';
@ -332,7 +332,7 @@ export class OpenGroup {
// Create conversation // Create conversation
const conversation = await ConversationController.getInstance().getOrCreateAndWait( const conversation = await ConversationController.getInstance().getOrCreateAndWait(
conversationId, conversationId,
ConversationType.GROUP // keep a group for this one as this is an old open group ConversationTypeEnum.GROUP // keep a group for this one as this is an old open group
); );
// Convert conversation to a public one // Convert conversation to a public one

@ -5,7 +5,7 @@ import {
removeV2OpenGroupRoom, removeV2OpenGroupRoom,
saveV2OpenGroupRoom, saveV2OpenGroupRoom,
} from '../../data/opengroups'; } from '../../data/opengroups';
import { ConversationModel, ConversationType } from '../../models/conversation'; import { ConversationModel, ConversationTypeEnum } from '../../models/conversation';
import { ConversationController } from '../../session/conversations'; import { ConversationController } from '../../session/conversations';
import { allowOnlyOneAtATime } from '../../session/utils/Promise'; import { allowOnlyOneAtATime } from '../../session/utils/Promise';
import { getOpenGroupV2ConversationId } from '../utils/OpenGroupUtils'; import { getOpenGroupV2ConversationId } from '../utils/OpenGroupUtils';
@ -178,7 +178,7 @@ export class OpenGroupManagerV2 {
} }
const conversation = await ConversationController.getInstance().getOrCreateAndWait( const conversation = await ConversationController.getInstance().getOrCreateAndWait(
conversationId, conversationId,
ConversationType.GROUP ConversationTypeEnum.GROUP
); );
room.imageID = roomInfos.imageId || undefined; room.imageID = roomInfos.imageId || undefined;
room.roomName = roomInfos.name || undefined; room.roomName = roomInfos.name || undefined;

@ -26,7 +26,7 @@ import {
import { ECKeyPair, HexKeyPair } from './keypairs'; import { ECKeyPair, HexKeyPair } from './keypairs';
import { UserUtils } from '../session/utils'; import { UserUtils } from '../session/utils';
import { ConversationModel, ConversationType } from '../models/conversation'; import { ConversationModel, ConversationTypeEnum } from '../models/conversation';
import _ from 'lodash'; import _ from 'lodash';
import { forceSyncConfigurationNowIfNeeded } from '../session/utils/syncUtils'; import { forceSyncConfigurationNowIfNeeded } from '../session/utils/syncUtils';
import { MessageController } from '../session/messages'; import { MessageController } from '../session/messages';
@ -196,7 +196,7 @@ export async function handleNewClosedGroup(
maybeConvo || maybeConvo ||
(await ConversationController.getInstance().getOrCreateAndWait( (await ConversationController.getInstance().getOrCreateAndWait(
groupId, groupId,
ConversationType.GROUP ConversationTypeEnum.GROUP
)); ));
// ***** Creating a new group ***** // ***** Creating a new group *****
log.info('Received a new ClosedGroup of id:', groupId); log.info('Received a new ClosedGroup of id:', groupId);
@ -744,7 +744,7 @@ async function sendLatestKeyPairToUsers(
window.log.info(`Sending latest closed group encryption key pair to: ${member}`); window.log.info(`Sending latest closed group encryption key pair to: ${member}`);
await ConversationController.getInstance().getOrCreateAndWait( await ConversationController.getInstance().getOrCreateAndWait(
member, member,
ConversationType.PRIVATE ConversationTypeEnum.PRIVATE
); );
const wrappers = await ClosedGroup.buildEncryptionKeyPairWrappers([member], keyPairToUse); const wrappers = await ClosedGroup.buildEncryptionKeyPairWrappers([member], keyPairToUse);
@ -801,7 +801,7 @@ export async function createClosedGroup(groupName: string, members: Array<string
// Create the group // Create the group
const convo = await ConversationController.getInstance().getOrCreateAndWait( const convo = await ConversationController.getInstance().getOrCreateAndWait(
groupPublicKey, groupPublicKey,
ConversationType.GROUP ConversationTypeEnum.GROUP
); );
const admins = [ourNumber.key]; const admins = [ourNumber.key];

@ -1,6 +1,6 @@
import _ from 'lodash'; import _ from 'lodash';
import { createOrUpdateItem, getItemById, hasSyncedInitialConfigurationItem } from '../data/data'; import { createOrUpdateItem, getItemById, hasSyncedInitialConfigurationItem } from '../data/data';
import { ConversationType } from '../models/conversation'; import { ConversationTypeEnum } from '../models/conversation';
import { OpenGroup } from '../opengroup/opengroupV1/OpenGroup'; import { OpenGroup } from '../opengroup/opengroupV1/OpenGroup';
import { SignalService } from '../protobuf'; import { SignalService } from '../protobuf';
import { ConversationController } from '../session/conversations'; import { ConversationController } from '../session/conversations';
@ -112,7 +112,7 @@ async function handleGroupsAndContactsFromConfigMessage(
} }
const contactConvo = await ConversationController.getInstance().getOrCreateAndWait( const contactConvo = await ConversationController.getInstance().getOrCreateAndWait(
toHex(c.publicKey), toHex(c.publicKey),
ConversationType.PRIVATE ConversationTypeEnum.PRIVATE
); );
const profile = { const profile = {
displayName: c.name, displayName: c.name,

@ -16,7 +16,7 @@ import { ECKeyPair } from './keypairs';
import { KeyPairRequestManager } from './keyPairRequestManager'; import { KeyPairRequestManager } from './keyPairRequestManager';
import { requestEncryptionKeyPair } from '../session/group'; import { requestEncryptionKeyPair } from '../session/group';
import { handleConfigurationMessage } from './configMessage'; import { handleConfigurationMessage } from './configMessage';
import { ConversationType } from '../models/conversation'; import { ConversationTypeEnum } from '../models/conversation';
export async function handleContentMessage(envelope: EnvelopePlus) { export async function handleContentMessage(envelope: EnvelopePlus) {
try { try {
@ -341,7 +341,7 @@ export async function innerHandleContentMessage(
await ConversationController.getInstance().getOrCreateAndWait( await ConversationController.getInstance().getOrCreateAndWait(
envelope.source, envelope.source,
ConversationType.PRIVATE ConversationTypeEnum.PRIVATE
); );
if (content.dataMessage) { if (content.dataMessage) {

@ -14,7 +14,7 @@ import { handleClosedGroupControlMessage } from './closedGroups';
import { MessageModel } from '../models/message'; import { MessageModel } from '../models/message';
import { MessageModelType } from '../models/messageType'; import { MessageModelType } from '../models/messageType';
import { getMessageBySender } from '../../ts/data/data'; import { getMessageBySender } from '../../ts/data/data';
import { ConversationModel, ConversationType } from '../models/conversation'; import { ConversationModel, ConversationTypeEnum } from '../models/conversation';
import { DeliveryReceiptMessage } from '../session/messages/outgoing/controlMessage/receipt/DeliveryReceiptMessage'; import { DeliveryReceiptMessage } from '../session/messages/outgoing/controlMessage/receipt/DeliveryReceiptMessage';
export async function updateProfile( export async function updateProfile(
@ -73,7 +73,7 @@ export async function updateProfile(
const conv = await ConversationController.getInstance().getOrCreateAndWait( const conv = await ConversationController.getInstance().getOrCreateAndWait(
conversation.id, conversation.id,
ConversationType.PRIVATE ConversationTypeEnum.PRIVATE
); );
await conv.setLokiProfile(newProfile); await conv.setLokiProfile(newProfile);
} }
@ -280,7 +280,7 @@ export async function handleDataMessage(
const senderConversation = await ConversationController.getInstance().getOrCreateAndWait( const senderConversation = await ConversationController.getInstance().getOrCreateAndWait(
senderPubKey, senderPubKey,
ConversationType.PRIVATE ConversationTypeEnum.PRIVATE
); );
// Check if we need to update any profile names // Check if we need to update any profile names
@ -409,7 +409,7 @@ export const isDuplicate = (
async function handleProfileUpdate( async function handleProfileUpdate(
profileKeyBuffer: Uint8Array, profileKeyBuffer: Uint8Array,
convoId: string, convoId: string,
convoType: ConversationType, convoType: ConversationTypeEnum,
isIncoming: boolean isIncoming: boolean
) { ) {
const profileKey = StringUtils.decode(profileKeyBuffer, 'base64'); const profileKey = StringUtils.decode(profileKeyBuffer, 'base64');
@ -419,7 +419,7 @@ async function handleProfileUpdate(
const ourNumber = UserUtils.getOurPubKeyStrFromCache(); const ourNumber = UserUtils.getOurPubKeyStrFromCache();
const me = ConversationController.getInstance().getOrCreate( const me = ConversationController.getInstance().getOrCreate(
ourNumber, ourNumber,
ConversationType.PRIVATE ConversationTypeEnum.PRIVATE
); );
// Will do the save for us if needed // Will do the save for us if needed
@ -427,7 +427,7 @@ async function handleProfileUpdate(
} else { } else {
const sender = await ConversationController.getInstance().getOrCreateAndWait( const sender = await ConversationController.getInstance().getOrCreateAndWait(
convoId, convoId,
ConversationType.PRIVATE ConversationTypeEnum.PRIVATE
); );
// Will do the save for us // Will do the save for us
@ -572,7 +572,7 @@ export async function handleMessageEvent(event: MessageEvent): Promise<void> {
const isGroupMessage = Boolean(message.group); const isGroupMessage = Boolean(message.group);
const type = isGroupMessage ? ConversationType.GROUP : ConversationType.PRIVATE; const type = isGroupMessage ? ConversationTypeEnum.GROUP : ConversationTypeEnum.PRIVATE;
let conversationId = isIncoming ? source : destination || source; // for synced message let conversationId = isIncoming ? source : destination || source; // for synced message
if (!conversationId) { if (!conversationId) {

@ -3,7 +3,7 @@ import { toNumber } from 'lodash';
import { ConversationController } from '../session/conversations'; import { ConversationController } from '../session/conversations';
import { MessageController } from '../session/messages'; import { MessageController } from '../session/messages';
import { actions as conversationActions } from '../state/ducks/conversations'; import { actions as conversationActions } from '../state/ducks/conversations';
import { ConversationType } from '../models/conversation'; import { ConversationTypeEnum } from '../models/conversation';
export async function onError(ev: any) { export async function onError(ev: any) {
const { error } = ev; const { error } = ev;
@ -18,7 +18,7 @@ export async function onError(ev: any) {
const id = message.get('conversationId'); const id = message.get('conversationId');
const conversation = await ConversationController.getInstance().getOrCreateAndWait( const conversation = await ConversationController.getInstance().getOrCreateAndWait(
id, id,
ConversationType.PRIVATE ConversationTypeEnum.PRIVATE
); );
// force conversation unread count to be > 0 so it is highlighted // force conversation unread count to be > 0 so it is highlighted
conversation.set({ conversation.set({

@ -2,12 +2,12 @@ import { queueAttachmentDownloads } from './attachments';
import { Quote } from './types'; import { Quote } from './types';
import { PubKey } from '../session/types'; import { PubKey } from '../session/types';
import _, { toNumber } from 'lodash'; import _ from 'lodash';
import { SignalService } from '../protobuf'; import { SignalService } from '../protobuf';
import { StringUtils, UserUtils } from '../session/utils'; import { StringUtils, UserUtils } from '../session/utils';
import { ConversationController } from '../session/conversations'; import { ConversationController } from '../session/conversations';
import { ConversationModel, ConversationType } from '../models/conversation'; import { ConversationModel, ConversationTypeEnum } from '../models/conversation';
import { MessageCollection, MessageModel } from '../models/message'; import { MessageModel } from '../models/message';
import { MessageController } from '../session/messages'; import { MessageController } from '../session/messages';
import { getMessageById, getMessagesBySentAt } from '../../ts/data/data'; import { getMessageById, getMessagesBySentAt } from '../../ts/data/data';
import { actions as conversationActions } from '../state/ducks/conversations'; import { actions as conversationActions } from '../state/ducks/conversations';
@ -369,7 +369,7 @@ async function handleRegularMessage(
const sendingDeviceConversation = await ConversationController.getInstance().getOrCreateAndWait( const sendingDeviceConversation = await ConversationController.getInstance().getOrCreateAndWait(
source, source,
ConversationType.PRIVATE ConversationTypeEnum.PRIVATE
); );
// Check if we need to update any profile names // Check if we need to update any profile names
// the only profile we don't update with what is coming here is ours, // the only profile we don't update with what is coming here is ours,

@ -27,7 +27,7 @@ import { StringUtils, UserUtils } from '../session/utils';
import { SignalService } from '../protobuf'; import { SignalService } from '../protobuf';
import { ConversationController } from '../session/conversations'; import { ConversationController } from '../session/conversations';
import { removeUnprocessed } from '../data/data'; import { removeUnprocessed } from '../data/data';
import { ConversationType } from '../models/conversation'; import { ConversationTypeEnum } from '../models/conversation';
import { import {
getOpenGroupV2ConversationId, getOpenGroupV2ConversationId,
openGroupPrefixRegex, openGroupPrefixRegex,
@ -281,7 +281,7 @@ export async function handlePublicMessage(messageData: any) {
if (!isMe && profile) { if (!isMe && profile) {
const conversation = await ConversationController.getInstance().getOrCreateAndWait( const conversation = await ConversationController.getInstance().getOrCreateAndWait(
source, source,
ConversationType.PRIVATE ConversationTypeEnum.PRIVATE
); );
await updateProfile(conversation, profile, profileKey); await updateProfile(conversation, profile, profileKey);
} }
@ -365,7 +365,7 @@ export async function handleOpenGroupV2Message(
const ourNumber = UserUtils.getOurPubKeyStrFromCache(); const ourNumber = UserUtils.getOurPubKeyStrFromCache();
const conversation = await ConversationController.getInstance().getOrCreateAndWait( const conversation = await ConversationController.getInstance().getOrCreateAndWait(
conversationId, conversationId,
ConversationType.GROUP ConversationTypeEnum.GROUP
); );
if (!conversation) { if (!conversation) {

@ -8,7 +8,7 @@ import {
ConversationAttributes, ConversationAttributes,
ConversationCollection, ConversationCollection,
ConversationModel, ConversationModel,
ConversationType, ConversationTypeEnum,
} from '../../models/conversation'; } from '../../models/conversation';
import { BlockedNumberController } from '../../util'; import { BlockedNumberController } from '../../util';
import { getSnodesFor } from '../snode_api/snodePool'; import { getSnodesFor } from '../snode_api/snodePool';
@ -67,12 +67,12 @@ export class ConversationController {
return this.conversations.add(attributes); return this.conversations.add(attributes);
} }
public getOrCreate(id: string, type: ConversationType) { public getOrCreate(id: string, type: ConversationTypeEnum) {
if (typeof id !== 'string') { if (typeof id !== 'string') {
throw new TypeError("'id' must be a string"); throw new TypeError("'id' must be a string");
} }
if (type !== ConversationType.PRIVATE && type !== ConversationType.GROUP) { if (type !== ConversationTypeEnum.PRIVATE && type !== ConversationTypeEnum.GROUP) {
throw new TypeError(`'type' must be 'private' or 'group' got: '${type}'`); throw new TypeError(`'type' must be 'private' or 'group' got: '${type}'`);
} }
@ -153,7 +153,7 @@ export class ConversationController {
public async getOrCreateAndWait( public async getOrCreateAndWait(
id: string | PubKey, id: string | PubKey,
type: ConversationType type: ConversationTypeEnum
): Promise<ConversationModel> { ): Promise<ConversationModel> {
const initialPromise = const initialPromise =
this._initialPromise !== undefined ? this._initialPromise : Promise.resolve(); this._initialPromise !== undefined ? this._initialPromise : Promise.resolve();

@ -18,7 +18,7 @@ import { encryptUsingSessionProtocol } from '../crypto/MessageEncrypter';
import { ECKeyPair } from '../../receiver/keypairs'; import { ECKeyPair } from '../../receiver/keypairs';
import { UserUtils } from '../utils'; import { UserUtils } from '../utils';
import { ClosedGroupMemberLeftMessage } from '../messages/outgoing/controlMessage/group/ClosedGroupMemberLeftMessage'; import { ClosedGroupMemberLeftMessage } from '../messages/outgoing/controlMessage/group/ClosedGroupMemberLeftMessage';
import { ConversationModel, ConversationType } from '../../models/conversation'; import { ConversationModel, ConversationTypeEnum } from '../../models/conversation';
import { MessageModel } from '../../models/message'; import { MessageModel } from '../../models/message';
import { MessageModelType } from '../../models/messageType'; import { MessageModelType } from '../../models/messageType';
import { MessageController } from '../messages'; import { MessageController } from '../messages';
@ -86,7 +86,7 @@ export async function initiateGroupUpdate(
) { ) {
const convo = await ConversationController.getInstance().getOrCreateAndWait( const convo = await ConversationController.getInstance().getOrCreateAndWait(
groupId, groupId,
ConversationType.GROUP ConversationTypeEnum.GROUP
); );
if (convo.isPublic()) { if (convo.isPublic()) {
@ -223,7 +223,7 @@ export async function updateOrCreateClosedGroup(details: GroupInfo) {
const conversation = await ConversationController.getInstance().getOrCreateAndWait( const conversation = await ConversationController.getInstance().getOrCreateAndWait(
id, id,
ConversationType.GROUP ConversationTypeEnum.GROUP
); );
const updates: any = { const updates: any = {
@ -409,7 +409,7 @@ async function sendAddedMembers(
}); });
const promises = addedMembers.map(async m => { const promises = addedMembers.map(async m => {
await ConversationController.getInstance().getOrCreateAndWait(m, ConversationType.PRIVATE); await ConversationController.getInstance().getOrCreateAndWait(m, ConversationTypeEnum.PRIVATE);
const memberPubKey = PubKey.cast(m); const memberPubKey = PubKey.cast(m);
await getMessageQueue().sendToPubKey(memberPubKey, newClosedGroupUpdate); await getMessageQueue().sendToPubKey(memberPubKey, newClosedGroupUpdate);
}); });

@ -3,8 +3,9 @@ import _, { omit } from 'lodash';
import { Constants } from '../../session'; import { Constants } from '../../session';
import { createAsyncThunk } from '@reduxjs/toolkit'; import { createAsyncThunk } from '@reduxjs/toolkit';
import { ConversationController } from '../../session/conversations'; import { ConversationController } from '../../session/conversations';
import { MessageCollection, MessageModel } from '../../models/message'; import { MessageModel } from '../../models/message';
import { getMessagesByConversation } from '../../data/data'; import { getMessagesByConversation } from '../../data/data';
import { ConversationTypeEnum } from '../../models/conversation';
// State // State
@ -66,7 +67,7 @@ export interface ConversationType {
activeAt?: number; activeAt?: number;
lastMessage?: LastMessageType; lastMessage?: LastMessageType;
phoneNumber: string; phoneNumber: string;
type: 'direct' | 'group'; type: ConversationTypeEnum;
isMe: boolean; isMe: boolean;
isPublic?: boolean; isPublic?: boolean;
unreadCount: number; unreadCount: number;

@ -15,6 +15,7 @@ import {
import { PubKey } from '../../session/types'; import { PubKey } from '../../session/types';
import { MessageModel } from '../../models/message'; import { MessageModel } from '../../models/message';
import { MessageModelType } from '../../models/messageType'; import { MessageModelType } from '../../models/messageType';
import { ConversationTypeEnum } from '../../models/conversation';
// State // State
@ -257,9 +258,9 @@ async function queryConversationsAndContacts(providedQuery: string, options: Sea
} else { } else {
conversations.push(primaryDevice); conversations.push(primaryDevice);
} }
} else if (conversation.type === 'direct') { } else if (conversation.type === ConversationTypeEnum.PRIVATE) {
contacts.push(conversation.id); contacts.push(conversation.id);
} else if (conversation.type !== 'group') { } else if (conversation.type !== ConversationTypeEnum.GROUP) {
contacts.push(conversation.id); contacts.push(conversation.id);
} else { } else {
conversations.push(conversation.id); conversations.push(conversation.id);

@ -11,6 +11,7 @@ import {
import { getIntl, getOurNumber } from './user'; import { getIntl, getOurNumber } from './user';
import { BlockedNumberController } from '../../util'; import { BlockedNumberController } from '../../util';
import { LocalizerType } from '../../types/Util'; import { LocalizerType } from '../../types/Util';
import { ConversationTypeEnum } from '../../models/conversation';
export const getConversations = (state: StateType): ConversationsStateType => state.conversations; export const getConversations = (state: StateType): ConversationsStateType => state.conversations;
@ -140,7 +141,7 @@ export const _getLeftPaneLists = (
continue; continue;
} }
if (conversation.activeAt !== undefined && conversation.type === 'direct') { if (conversation.activeAt !== undefined && conversation.type === ConversationTypeEnum.PRIVATE) {
directConversations.push(conversation); directConversations.push(conversation);
} }

@ -9,7 +9,7 @@ import { ClosedGroupVisibleMessage } from '../../../../session/messages/outgoing
import { MockConversation } from '../../../test-utils/utils'; import { MockConversation } from '../../../test-utils/utils';
import { ConfigurationMessage } from '../../../../session/messages/outgoing/controlMessage/ConfigurationMessage'; import { ConfigurationMessage } from '../../../../session/messages/outgoing/controlMessage/ConfigurationMessage';
import { ConversationModel, ConversationType } from '../../../../models/conversation'; import { ConversationModel, ConversationTypeEnum } from '../../../../models/conversation';
import chaiAsPromised from 'chai-as-promised'; import chaiAsPromised from 'chai-as-promised';
chai.use(chaiAsPromised as any); chai.use(chaiAsPromised as any);
@ -227,17 +227,17 @@ describe('Message Utils', () => {
let convos: Array<ConversationModel>; let convos: Array<ConversationModel>;
const mockValidOpenGroup = new MockConversation({ const mockValidOpenGroup = new MockConversation({
type: ConversationType.GROUP, type: ConversationTypeEnum.GROUP,
id: `${openGroupPrefix}1@chat-dev.lokinet.org`, id: `${openGroupPrefix}1@chat-dev.lokinet.org`,
}); });
const mockValidOpenGroup2 = new MockConversation({ const mockValidOpenGroup2 = new MockConversation({
type: ConversationType.GROUP, type: ConversationTypeEnum.GROUP,
id: `${openGroupPrefix}1@chat-dev2.lokinet.org`, id: `${openGroupPrefix}1@chat-dev2.lokinet.org`,
}); });
const mockValidClosedGroup = new MockConversation({ const mockValidClosedGroup = new MockConversation({
type: ConversationType.GROUP, type: ConversationTypeEnum.GROUP,
}); });
const mockValidPrivate = { const mockValidPrivate = {

@ -1,4 +1,5 @@
import { assert } from 'chai'; import { assert } from 'chai';
import { ConversationTypeEnum } from '../../../models/conversation';
import { ConversationLookupType } from '../../../state/ducks/conversations'; import { ConversationLookupType } from '../../../state/ducks/conversations';
import { import {
@ -17,7 +18,7 @@ describe('state/selectors/conversations', () => {
name: 'No timestamp', name: 'No timestamp',
phoneNumber: 'notused', phoneNumber: 'notused',
type: 'direct', type: ConversationTypeEnum.PRIVATE,
isMe: false, isMe: false,
unreadCount: 1, unreadCount: 1,
mentionedUs: false, mentionedUs: false,
@ -33,7 +34,7 @@ describe('state/selectors/conversations', () => {
name: 'B', name: 'B',
phoneNumber: 'notused', phoneNumber: 'notused',
type: 'direct', type: ConversationTypeEnum.PRIVATE,
isMe: false, isMe: false,
unreadCount: 1, unreadCount: 1,
mentionedUs: false, mentionedUs: false,
@ -49,7 +50,7 @@ describe('state/selectors/conversations', () => {
name: 'C', name: 'C',
phoneNumber: 'notused', phoneNumber: 'notused',
type: 'direct', type: ConversationTypeEnum.PRIVATE,
isMe: false, isMe: false,
unreadCount: 1, unreadCount: 1,
mentionedUs: false, mentionedUs: false,
@ -64,7 +65,7 @@ describe('state/selectors/conversations', () => {
activeAt: 20, activeAt: 20,
name: 'Á', name: 'Á',
phoneNumber: 'notused', phoneNumber: 'notused',
type: 'direct', type: ConversationTypeEnum.PRIVATE,
isMe: false, isMe: false,
unreadCount: 1, unreadCount: 1,
mentionedUs: false, mentionedUs: false,
@ -79,7 +80,7 @@ describe('state/selectors/conversations', () => {
activeAt: 30, activeAt: 30,
name: 'First!', name: 'First!',
phoneNumber: 'notused', phoneNumber: 'notused',
type: 'direct', type: ConversationTypeEnum.PRIVATE,
isMe: false, isMe: false,
unreadCount: 1, unreadCount: 1,
mentionedUs: false, mentionedUs: false,

@ -1,7 +1,7 @@
import { v4 as uuid } from 'uuid'; import { v4 as uuid } from 'uuid';
import { generateFakePubKey, generateFakePubKeys } from './pubkey'; import { generateFakePubKey, generateFakePubKeys } from './pubkey';
import { ClosedGroupVisibleMessage } from '../../../session/messages/outgoing/visibleMessage/ClosedGroupVisibleMessage'; import { ClosedGroupVisibleMessage } from '../../../session/messages/outgoing/visibleMessage/ClosedGroupVisibleMessage';
import { ConversationAttributes, ConversationType } from '../../../models/conversation'; import { ConversationAttributes, ConversationTypeEnum } from '../../../models/conversation';
import { OpenGroupMessage } from '../../../session/messages/outgoing'; import { OpenGroupMessage } from '../../../session/messages/outgoing';
import { VisibleMessage } from '../../../session/messages/outgoing/visibleMessage/VisibleMessage'; import { VisibleMessage } from '../../../session/messages/outgoing/visibleMessage/VisibleMessage';
import { OpenGroup } from '../../../opengroup/opengroupV1/OpenGroup'; import { OpenGroup } from '../../../opengroup/opengroupV1/OpenGroup';
@ -48,13 +48,13 @@ export function generateClosedGroupMessage(groupId?: string): ClosedGroupVisible
interface MockConversationParams { interface MockConversationParams {
id?: string; id?: string;
members?: Array<string>; members?: Array<string>;
type: ConversationType; type: ConversationTypeEnum;
isMediumGroup?: boolean; isMediumGroup?: boolean;
} }
export class MockConversation { export class MockConversation {
public id: string; public id: string;
public type: ConversationType; public type: ConversationTypeEnum;
public attributes: ConversationAttributes; public attributes: ConversationAttributes;
constructor(params: MockConversationParams) { constructor(params: MockConversationParams) {
@ -70,7 +70,7 @@ export class MockConversation {
id: this.id, id: this.id,
name: '', name: '',
profileName: undefined, profileName: undefined,
type: params.type === ConversationType.GROUP ? 'group' : params.type, type: params.type === ConversationTypeEnum.GROUP ? 'group' : params.type,
members, members,
left: false, left: false,
expireTimer: 0, expireTimer: 0,
@ -85,7 +85,7 @@ export class MockConversation {
} }
public isPrivate() { public isPrivate() {
return this.type === ConversationType.PRIVATE; return this.type === ConversationTypeEnum.PRIVATE;
} }
public isBlocked() { public isBlocked() {

@ -14,7 +14,7 @@ import {
import { forceSyncConfigurationNowIfNeeded } from '../session/utils/syncUtils'; import { forceSyncConfigurationNowIfNeeded } from '../session/utils/syncUtils';
import { actions as userActions } from '../state/ducks/user'; import { actions as userActions } from '../state/ducks/user';
import { mn_decode, mn_encode } from '../session/crypto/mnemonic'; import { mn_decode, mn_encode } from '../session/crypto/mnemonic';
import { ConversationType } from '../models/conversation'; import { ConversationTypeEnum } from '../models/conversation';
/** /**
* Might throw * Might throw
@ -216,7 +216,7 @@ async function registrationDone(ourPubkey: string, displayName: string) {
// Ensure that we always have a conversation for ourself // Ensure that we always have a conversation for ourself
const conversation = await ConversationController.getInstance().getOrCreateAndWait( const conversation = await ConversationController.getInstance().getOrCreateAndWait(
ourPubkey, ourPubkey,
ConversationType.PRIVATE ConversationTypeEnum.PRIVATE
); );
await conversation.setLokiProfile({ displayName }); await conversation.setLokiProfile({ displayName });
const user = { const user = {

Loading…
Cancel
Save