Adds message forwarding
This commit is contained in:
parent
cd489a35fd
commit
d203f125c6
42 changed files with 1638 additions and 139 deletions
|
@ -1397,6 +1397,9 @@ export class ConversationModel extends window.Backbone.Model<
|
|||
sortedGroupMembers,
|
||||
timestamp,
|
||||
title: this.getTitle()!,
|
||||
searchableTitle: this.isMe()
|
||||
? window.i18n('noteToSelf')
|
||||
: this.getTitle(),
|
||||
type: (this.isPrivate() ? 'direct' : 'group') as ConversationTypeType,
|
||||
unreadCount: this.get('unreadCount')! || 0,
|
||||
};
|
||||
|
@ -2235,7 +2238,7 @@ export class ConversationModel extends window.Backbone.Model<
|
|||
});
|
||||
}
|
||||
|
||||
getUntrusted(): Backbone.Collection {
|
||||
getUntrusted(): Backbone.Collection<ConversationModel> {
|
||||
if (this.isPrivate()) {
|
||||
if (this.isUntrusted()) {
|
||||
return new window.Backbone.Collection([this]);
|
||||
|
@ -2243,16 +2246,14 @@ export class ConversationModel extends window.Backbone.Model<
|
|||
return new window.Backbone.Collection();
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const results = this.contactCollection!.map(contact => {
|
||||
if (contact.isMe()) {
|
||||
return [false, contact];
|
||||
}
|
||||
return [contact.isUntrusted(), contact];
|
||||
});
|
||||
|
||||
return new window.Backbone.Collection(
|
||||
results.filter(result => result[0]).map(result => result[1])
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
this.contactCollection!.filter(contact => {
|
||||
if (contact.isMe()) {
|
||||
return false;
|
||||
}
|
||||
return contact.isUntrusted();
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -3320,13 +3321,21 @@ export class ConversationModel extends window.Backbone.Model<
|
|||
quote: WhatIsThis,
|
||||
preview: WhatIsThis,
|
||||
sticker?: WhatIsThis,
|
||||
mentions?: BodyRangesType
|
||||
mentions?: BodyRangesType,
|
||||
{ dontClearDraft = false } = {}
|
||||
): void {
|
||||
this.clearTypingTimers();
|
||||
|
||||
const { clearUnreadMetrics } = window.reduxActions.conversations;
|
||||
clearUnreadMetrics(this.id);
|
||||
|
||||
const mandatoryProfileSharingEnabled = window.Signal.RemoteConfig.isEnabled(
|
||||
'desktop.mandatoryProfileSharing'
|
||||
);
|
||||
if (mandatoryProfileSharingEnabled && !this.get('profileSharing')) {
|
||||
this.set({ profileSharing: true });
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const destination = this.getSendTarget()!;
|
||||
const expireTimer = this.get('expireTimer');
|
||||
|
@ -3382,15 +3391,22 @@ export class ConversationModel extends window.Backbone.Model<
|
|||
Message: window.Whisper.Message,
|
||||
});
|
||||
|
||||
const draftProperties = dontClearDraft
|
||||
? {}
|
||||
: {
|
||||
draft: null,
|
||||
draftTimestamp: null,
|
||||
lastMessage: model.getNotificationText(),
|
||||
lastMessageStatus: 'sending' as const,
|
||||
};
|
||||
|
||||
this.set({
|
||||
lastMessage: model.getNotificationText(),
|
||||
lastMessageStatus: 'sending',
|
||||
...draftProperties,
|
||||
active_at: now,
|
||||
timestamp: now,
|
||||
isArchived: false,
|
||||
draft: null,
|
||||
draftTimestamp: null,
|
||||
});
|
||||
|
||||
this.incrementSentMessageCount();
|
||||
window.Signal.Data.updateConversation(this.attributes);
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ import {
|
|||
import { PropsType as ProfileChangeNotificationPropsType } from '../components/conversation/ProfileChangeNotification';
|
||||
import { AttachmentType, isImage, isVideo } from '../types/Attachment';
|
||||
import { MIMEType } from '../types/MIME';
|
||||
import { LinkPreviewType } from '../types/message/LinkPreviews';
|
||||
|
||||
/* eslint-disable camelcase */
|
||||
/* eslint-disable more/no-then */
|
||||
|
@ -1139,7 +1140,7 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
};
|
||||
}
|
||||
|
||||
getPropsForPreview(): WhatIsThis {
|
||||
getPropsForPreview(): Array<LinkPreviewType> {
|
||||
const previews = this.get('preview') || [];
|
||||
|
||||
return previews.map(preview => ({
|
||||
|
@ -1592,6 +1593,17 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
|||
return { text: '' };
|
||||
}
|
||||
|
||||
getRawText(): string {
|
||||
const body = (this.get('body') || '').trim();
|
||||
|
||||
const bodyRanges = this.processBodyRanges();
|
||||
if (bodyRanges) {
|
||||
return getTextWithMentions(bodyRanges, body);
|
||||
}
|
||||
|
||||
return body;
|
||||
}
|
||||
|
||||
getNotificationText(): string {
|
||||
const { text, emoji } = this.getNotificationData();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue