remove 'recipients' message field and 'destination'

we do not need recipients as it makes no sense for us having medium
groups on the same pubkey

we do not need destination as it can always be guessed from the
direction and the type of conversation of that message
pull/2142/head
Audric Ackermann 3 years ago
parent 00d2bbc63d
commit 5e314e4dcc
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -1421,7 +1421,7 @@
cursor: pointer;
&:hover {
background-color: $color-gray-05;
background-color: var(--color-clickable-hovered);
}
}

@ -48,26 +48,6 @@
}
}
.recipients-input {
.recipients-container {
background-color: white;
border-bottom: 1px solid #f2f2f2;
}
.recipient {
background-color: $blue;
color: white;
&.error {
background-color: #f00;
}
}
.results {
box-shadow: 0px 0px 1px rgba(#aaa, 0.8);
}
}
.loading {
position: relative;
&::before {

@ -1,6 +1,7 @@
import { ipcRenderer } from 'electron';
// tslint:disable: no-require-imports no-var-requires one-variable-per-declaration no-void-expression
// tslint:disable: function-name
import _ from 'lodash';
import { MessageResultProps } from '../components/search/MessageSearchResults';

@ -514,13 +514,6 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
return current;
}
public getRecipients() {
if (this.isPrivate()) {
return [this.id];
}
const me = UserUtils.getOurPubKeyStrFromCache();
return _.without(this.get('members'), me);
}
public async getQuoteAttachment(attachments: any, preview: any) {
if (attachments && attachments.length) {
@ -710,12 +703,9 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
this.clearTypingTimers();
const destination = this.id;
const isPrivate = this.isPrivate();
const expireTimer = this.get('expireTimer');
const recipients = this.getRecipients();
const now = Date.now();
const networkTimestamp = now - getLatestTimestampOffset();
const networkTimestamp = getNowWithNetworkOffset();
window?.log?.info(
'Sending message to conversation',
@ -734,16 +724,13 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
preview,
attachments,
sent_at: networkTimestamp,
received_at: now,
received_at: networkTimestamp,
expireTimer,
recipients,
isDeleted: false,
source: UserUtils.getOurPubKeyStrFromCache(),
};
if (!this.isPublic()) {
messageObject.destination = destination;
} else {
if (this.isPublic()) {
// set the serverTimestamp only if this conversation is a public one.
messageObject.serverTimestamp = Date.now();
}
@ -752,7 +739,6 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
...messageObject,
groupInvitation,
conversationId: this.id,
destination: isPrivate ? destination : undefined,
};
const messageModel = await this.addSingleMessage(attributes);
@ -771,7 +757,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
this.set({
lastMessage: messageModel.getNotificationText(),
lastMessageStatus: 'sending',
active_at: now,
active_at: networkTimestamp,
});
await this.commit();
@ -806,7 +792,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
}
public async updateExpireTimer(
providedExpireTimer: any,
providedExpireTimer: number | null,
providedSource?: string,
receivedAt?: number, // is set if it comes from outside
options: {
@ -874,13 +860,9 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
const expireUpdate = {
identifier: message.id,
timestamp,
expireTimer,
expireTimer: expireTimer ? expireTimer : (null as number | null),
};
if (!expireUpdate.expireTimer) {
delete expireUpdate.expireTimer;
}
if (this.isMe()) {
const expirationTimerMessage = new ExpirationTimerUpdateMessage(expireUpdate);
return message.sendSyncMessageOnly(expirationTimerMessage);
@ -1519,7 +1501,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
const { expireTimer } = json;
return typeof expireTimer === 'number' && expireTimer > 0;
return isFinite(expireTimer) && expireTimer > 0;
}
private shouldDoTyping() {

@ -647,12 +647,9 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
// We include numbers we didn't successfully send to so we can display errors.
// Older messages don't have the recipients included on the message, so we fall
// back to the conversation's current recipients
const phoneNumbers = this.isIncoming()
const phoneNumbers: Array<string> = this.isIncoming()
? [this.get('source')]
: _.union(
this.get('sent_to') || [],
this.get('recipients') || this.getConversation()?.getRecipients() || []
);
: this.get('sent_to') || [];
// This will make the error message for outgoing key errors a bit nicer
const allErrors = (this.get('errors') || []).map((error: any) => {

@ -15,14 +15,12 @@ export interface MessageAttributes {
expireTimer: number;
received_at?: number;
sent_at?: number;
destination?: string;
preview?: any;
body?: string;
expirationStartTimestamp: number;
read_by: Array<string>;
decrypted_at: number;
expires_at?: number;
recipients: Array<string>;
type: MessageModelType;
group_update?: MessageGroupUpdate;
groupInvitation?: any;
@ -48,8 +46,7 @@ export interface MessageAttributes {
*/
timestamp?: number;
status?: MessageDeliveryStatus;
// dataMessage: any;
sent_to: any;
sent_to: Array<string>;
sent: boolean;
/**
@ -113,11 +110,6 @@ export interface DataExtractionNotificationMsg {
referencedAttachmentTimestamp: number; // the attachment timestamp he screenshot
}
export enum MessageDirection {
outgoing = 'outgoing',
incoming = 'incoming',
}
export type PropsForDataExtractionNotification = DataExtractionNotificationMsg & {
name: string;
messageId: string;
@ -139,14 +131,12 @@ export interface MessageAttributesOptionals {
expireTimer?: number;
received_at?: number;
sent_at?: number;
destination?: string;
preview?: any;
body?: string;
expirationStartTimestamp?: number;
read_by?: Array<string>;
decrypted_at?: number;
expires_at?: number;
recipients?: Array<string>;
type: MessageModelType;
group_update?: MessageGroupUpdate;
groupInvitation?: any;

@ -167,23 +167,8 @@ function updateReadStatus(message: MessageModel, conversation: ConversationModel
}
async function handleSyncedReceipts(message: MessageModel, conversation: ConversationModel) {
const readReceipts = window.Whisper.ReadReceipts.forMessage(conversation, message);
if (readReceipts.length) {
const readBy = readReceipts.map((receipt: any) => receipt.get('reader'));
message.set({
read_by: _.union(message.get('read_by'), readBy),
});
}
// A sync'd message to ourself is automatically considered read
const recipients = conversation.getRecipients();
if (conversation.isMe()) {
message.set({
read_by: recipients,
});
}
message.set({ recipients });
console.warn('handleSyncedReceipts', message);
debugger;
// If the newly received message is from us, we assume that we've seen the messages up until that point
const sentTimestamp = message.get('sent_at');

@ -39,6 +39,10 @@ function handleTimestampOffset(_request: string, snodeTimestamp: number) {
}
}
/**
* This function has no use to be called except during tests.
* @returns the current offset we have with the rest of the network.
*/
export function getLatestTimestampOffset() {
if (latestTimestampOffset === Number.MAX_SAFE_INTEGER) {
window.log.warn('latestTimestampOffset is not set yet');

@ -119,6 +119,7 @@ export async function send(
);
}
// tslint:disable-next-line: function-name
export async function TEST_sendMessageToSnode(
pubKey: string,
data: Uint8Array,

Loading…
Cancel
Save