Fix read receipts being considered as inferred request approvals. Fix preventing subsequent request messages from reactivating the request banner.
This commit is contained in:
parent
c5afcb72df
commit
1ca66e6bcf
|
@ -729,7 +729,6 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
|
|||
* Does this conversation contain the properties to be considered a message request
|
||||
*/
|
||||
public isRequest(): boolean {
|
||||
// return !this.isMe() && !this.isApproved() && this.isPrivate() && !this.isBlocked();
|
||||
return ConversationModel.hasValidRequestValues({
|
||||
isMe: this.isMe(),
|
||||
isApproved: this.isApproved(),
|
||||
|
@ -743,13 +742,6 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
|
|||
* @param timestamp for determining the order for this message to appear like a regular message
|
||||
*/
|
||||
public async addOutgoingApprovalMessage(timestamp: number) {
|
||||
const getStackTrace = function() {
|
||||
const obj = {} as any;
|
||||
Error.captureStackTrace(obj, getStackTrace);
|
||||
return obj.stack;
|
||||
};
|
||||
window?.log?.info(getStackTrace());
|
||||
alert(getStackTrace());
|
||||
await this.addSingleOutgoingMessage({
|
||||
sent_at: timestamp,
|
||||
messageRequestResponse: {
|
||||
|
@ -768,13 +760,6 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
|
|||
* @param source For determining the conversation name used in the message.
|
||||
*/
|
||||
public async addIncomingApprovalMessage(timestamp: number, source: string) {
|
||||
const getStackTrace = function() {
|
||||
const obj = {} as any;
|
||||
Error.captureStackTrace(obj, getStackTrace);
|
||||
return obj.stack;
|
||||
};
|
||||
// window?.log?.info(getStackTrace());
|
||||
alert(getStackTrace());
|
||||
await this.addSingleIncomingMessage({
|
||||
sent_at: timestamp, // TODO: maybe add timestamp to messageRequestResponse? confirm it doesn't exist first
|
||||
source,
|
||||
|
@ -1006,14 +991,6 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
|
|||
'conversationId' | 'source' | 'type' | 'direction' | 'received_at'
|
||||
>
|
||||
) {
|
||||
// for handling edge case for syncing/linking devices.
|
||||
// if convo has a message by us, we have replied - which is considered as approved
|
||||
// if (!this.isMe()) {
|
||||
// if (!this.isApproved() && this.isPrivate()) {
|
||||
// this.setIsApproved(true);
|
||||
// }
|
||||
// }
|
||||
|
||||
return this.addSingleMessage({
|
||||
...messageAttributes,
|
||||
conversationId: this.id,
|
||||
|
|
|
@ -19,7 +19,6 @@ import { getAllCachedECKeyPair } from './closedGroups';
|
|||
import { handleCallMessage } from './callMessage';
|
||||
import { SettingsKey } from '../data/settings-key';
|
||||
import { ConversationTypeEnum } from '../models/conversation';
|
||||
import { showMessageRequestBanner } from '../state/ducks/userConfig';
|
||||
|
||||
export async function handleSwarmContentMessage(envelope: EnvelopePlus, messageHash: string) {
|
||||
try {
|
||||
|
@ -372,40 +371,12 @@ export async function innerHandleSwarmContentMessage(
|
|||
);
|
||||
}
|
||||
|
||||
const convo = await getConversationController().getOrCreateAndWait(
|
||||
envelope.source,
|
||||
ConversationTypeEnum.PRIVATE
|
||||
);
|
||||
|
||||
if (
|
||||
convo.isPrivate() &&
|
||||
!convo.isApproved() &&
|
||||
window.inboxStore?.getState().userConfig.hideMessageRequests
|
||||
) {
|
||||
window.inboxStore?.dispatch(showMessageRequestBanner());
|
||||
}
|
||||
|
||||
// For edge case when messaging a client that's unable to explicitly send request approvals
|
||||
if (!convo.didApproveMe() && convo.isPrivate() && convo.isApproved()) {
|
||||
await convo.setDidApproveMe(true);
|
||||
// Conversation was not approved before so a sync is needed
|
||||
await convo.addSingleIncomingMessage({
|
||||
sent_at: _.toNumber(envelope.timestamp),
|
||||
source: envelope.source,
|
||||
messageRequestResponse: {
|
||||
isApproved: 1,
|
||||
},
|
||||
unread: 1, // 1 means unread
|
||||
expireTimer: 0,
|
||||
});
|
||||
convo.updateLastMessage();
|
||||
}
|
||||
|
||||
if (content.dataMessage) {
|
||||
if (content.dataMessage.profileKey && content.dataMessage.profileKey.length === 0) {
|
||||
content.dataMessage.profileKey = null;
|
||||
}
|
||||
perfStart(`handleSwarmDataMessage-${envelope.id}`);
|
||||
|
||||
await handleSwarmDataMessage(
|
||||
envelope,
|
||||
content.dataMessage as SignalService.DataMessage,
|
||||
|
|
|
@ -6,11 +6,13 @@ import _ from 'lodash';
|
|||
import { getConversationController } from '../session/conversations';
|
||||
import { ConversationModel, ConversationTypeEnum } from '../models/conversation';
|
||||
import { MessageModel } from '../models/message';
|
||||
import { getMessageById, getMessagesBySentAt } from '../../ts/data/data';
|
||||
import { getMessageById, getMessageCountByType, getMessagesBySentAt } from '../../ts/data/data';
|
||||
|
||||
import { updateProfileOneAtATime } from './dataMessage';
|
||||
import { SignalService } from '../protobuf';
|
||||
import { UserUtils } from '../session/utils';
|
||||
import { showMessageRequestBanner } from '../state/ducks/userConfig';
|
||||
import { MessageDirection } from '../models/messageType';
|
||||
|
||||
function contentTypeSupported(type: string): boolean {
|
||||
const Chrome = window.Signal.Util.GoogleChrome;
|
||||
|
@ -250,6 +252,29 @@ async function handleRegularMessage(
|
|||
updateReadStatus(message, conversation);
|
||||
if (conversation.isPrivate()) {
|
||||
await conversation.setDidApproveMe(true);
|
||||
|
||||
const incomingMessageCount = await getMessageCountByType(
|
||||
conversation.id,
|
||||
MessageDirection.incoming
|
||||
);
|
||||
const isFirstRequestMessage = incomingMessageCount < 2;
|
||||
if (
|
||||
conversation.isRequest() &&
|
||||
isFirstRequestMessage &&
|
||||
window.inboxStore?.getState().userConfig.hideMessageRequests
|
||||
) {
|
||||
window.inboxStore?.dispatch(showMessageRequestBanner());
|
||||
}
|
||||
|
||||
// For edge case when messaging a client that's unable to explicitly send request approvals
|
||||
if (!conversation.didApproveMe() && conversation.isPrivate() && conversation.isApproved()) {
|
||||
await conversation.setDidApproveMe(true);
|
||||
// Conversation was not approved before so a sync is needed
|
||||
await conversation.addIncomingApprovalMessage(
|
||||
_.toNumber(message.get('sent_at')) - 1,
|
||||
source
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue