Ignore delivery receipts for outgoing reactions
This commit is contained in:
parent
c8099171e2
commit
e46b1f7958
8 changed files with 151 additions and 34 deletions
|
@ -7,7 +7,7 @@ import type {
|
|||
SenderKeyInfoType,
|
||||
} from '../model-types.d';
|
||||
import type { StoredJob } from '../jobs/types';
|
||||
import type { ReactionType } from '../types/Reactions';
|
||||
import type { ReactionType, ReactionReadStatus } from '../types/Reactions';
|
||||
import type { ConversationColorType, CustomColorType } from '../types/Colors';
|
||||
import type { StorageAccessType } from '../types/Storage.d';
|
||||
import type { AttachmentType } from '../types/Attachment';
|
||||
|
@ -586,7 +586,16 @@ export type DataInterface = {
|
|||
targetAuthorServiceId: ServiceIdString;
|
||||
targetTimestamp: number;
|
||||
}) => Promise<void>;
|
||||
addReaction: (reactionObj: ReactionType) => Promise<void>;
|
||||
getReactionByTimestamp: (
|
||||
fromId: string,
|
||||
timestamp: number
|
||||
) => Promise<ReactionType | undefined>;
|
||||
addReaction: (
|
||||
reactionObj: ReactionType,
|
||||
options: {
|
||||
readStatus: ReactionReadStatus;
|
||||
}
|
||||
) => Promise<void>;
|
||||
_getAllReactions: () => Promise<Array<ReactionType>>;
|
||||
_removeAllReactions: () => Promise<void>;
|
||||
getMessageBySender: (options: {
|
||||
|
|
|
@ -33,6 +33,7 @@ import * as Errors from '../types/errors';
|
|||
import { ReadStatus } from '../messages/MessageReadStatus';
|
||||
import type { GroupV2MemberType } from '../model-types.d';
|
||||
import type { ReactionType } from '../types/Reactions';
|
||||
import { ReactionReadStatus } from '../types/Reactions';
|
||||
import { STORAGE_UI_KEYS } from '../types/StorageUIKeys';
|
||||
import type { StoryDistributionIdString } from '../types/StoryDistributionId';
|
||||
import type { ServiceIdString, AciString } from '../types/ServiceId';
|
||||
|
@ -274,6 +275,7 @@ const dataInterface: ServerInterface = {
|
|||
getUnreadByConversationAndMarkRead,
|
||||
getUnreadReactionsAndMarkRead,
|
||||
markReactionAsRead,
|
||||
getReactionByTimestamp,
|
||||
addReaction,
|
||||
removeReactionFromConversation,
|
||||
_getAllReactions,
|
||||
|
@ -2537,15 +2539,32 @@ async function markReactionAsRead(
|
|||
})();
|
||||
}
|
||||
|
||||
async function addReaction({
|
||||
conversationId,
|
||||
emoji,
|
||||
fromId,
|
||||
messageId,
|
||||
messageReceivedAt,
|
||||
targetAuthorAci,
|
||||
targetTimestamp,
|
||||
}: ReactionType): Promise<void> {
|
||||
async function getReactionByTimestamp(
|
||||
fromId: string,
|
||||
timestamp: number
|
||||
): Promise<ReactionType | undefined> {
|
||||
const db = getReadonlyInstance();
|
||||
const [query, params] = sql`
|
||||
SELECT * FROM reactions
|
||||
WHERE fromId IS ${fromId} AND timestamp IS ${timestamp}
|
||||
`;
|
||||
|
||||
return db.prepare(query).get(params);
|
||||
}
|
||||
|
||||
async function addReaction(
|
||||
{
|
||||
conversationId,
|
||||
emoji,
|
||||
fromId,
|
||||
messageId,
|
||||
messageReceivedAt,
|
||||
targetAuthorAci,
|
||||
targetTimestamp,
|
||||
timestamp,
|
||||
}: ReactionType,
|
||||
{ readStatus }: { readStatus: ReactionReadStatus }
|
||||
): Promise<void> {
|
||||
const db = await getWritableInstance();
|
||||
await db
|
||||
.prepare(
|
||||
|
@ -2557,6 +2576,7 @@ async function addReaction({
|
|||
messageReceivedAt,
|
||||
targetAuthorAci,
|
||||
targetTimestamp,
|
||||
timestamp,
|
||||
unread
|
||||
) VALUES (
|
||||
$conversationId,
|
||||
|
@ -2566,6 +2586,7 @@ async function addReaction({
|
|||
$messageReceivedAt,
|
||||
$targetAuthorAci,
|
||||
$targetTimestamp,
|
||||
$timestamp,
|
||||
$unread
|
||||
);`
|
||||
)
|
||||
|
@ -2577,7 +2598,8 @@ async function addReaction({
|
|||
messageReceivedAt,
|
||||
targetAuthorAci,
|
||||
targetTimestamp,
|
||||
unread: 1,
|
||||
timestamp,
|
||||
unread: readStatus === ReactionReadStatus.Unread ? 1 : 0,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
32
ts/sql/migrations/980-reaction-timestamp.ts
Normal file
32
ts/sql/migrations/980-reaction-timestamp.ts
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { Database } from '@signalapp/better-sqlite3';
|
||||
|
||||
import type { LoggerType } from '../../types/Logging';
|
||||
|
||||
export const version = 980;
|
||||
|
||||
export function updateToSchemaVersion980(
|
||||
currentVersion: number,
|
||||
db: Database,
|
||||
logger: LoggerType
|
||||
): void {
|
||||
if (currentVersion >= 980) {
|
||||
return;
|
||||
}
|
||||
|
||||
db.transaction(() => {
|
||||
db.exec(`
|
||||
ALTER TABLE reactions ADD COLUMN timestamp NUMBER;
|
||||
|
||||
CREATE INDEX reactions_byTimestamp
|
||||
ON reactions
|
||||
(fromId, timestamp);
|
||||
`);
|
||||
})();
|
||||
|
||||
db.pragma('user_version = 980');
|
||||
|
||||
logger.info('updateToSchemaVersion980: success!');
|
||||
}
|
|
@ -72,10 +72,11 @@ import { updateToSchemaVersion930 } from './930-fts5-secure-delete';
|
|||
import { updateToSchemaVersion940 } from './940-fts5-revert';
|
||||
import { updateToSchemaVersion950 } from './950-fts5-secure-delete';
|
||||
import { updateToSchemaVersion960 } from './960-untag-pni';
|
||||
import { updateToSchemaVersion970 } from './970-fts5-optimize';
|
||||
import {
|
||||
version as MAX_VERSION,
|
||||
updateToSchemaVersion970,
|
||||
} from './970-fts5-optimize';
|
||||
updateToSchemaVersion980,
|
||||
} from './980-reaction-timestamp';
|
||||
|
||||
function updateToSchemaVersion1(
|
||||
currentVersion: number,
|
||||
|
@ -2015,6 +2016,7 @@ export const SCHEMA_VERSIONS = [
|
|||
updateToSchemaVersion950,
|
||||
updateToSchemaVersion960,
|
||||
updateToSchemaVersion970,
|
||||
updateToSchemaVersion980,
|
||||
];
|
||||
|
||||
export class DBVersionFromFutureError extends Error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue