Новая генерация message id, теперь он принимается от оппонента
This commit is contained in:
@@ -18,7 +18,6 @@ import { useWindowFocus } from '@/app/hooks/useWindowFocus';
|
||||
import { useDialogsCache } from './useDialogsCache';
|
||||
import { useConsoleLogger } from '@/app/hooks/useConsoleLogger';
|
||||
import { useViewPanelsState, ViewPanelsState } from '@/app/hooks/useViewPanelsState';
|
||||
import { generateRandomKeyFormSeed } from '@/app/utils/utils';
|
||||
import { MessageReply } from './useReplyMessages';
|
||||
import { useTransport } from '../TransportProvider/useTransport';
|
||||
import { useFileStorage } from '@/app/hooks/useFileStorage';
|
||||
@@ -385,7 +384,7 @@ export function DialogProvider(props: DialogProviderProps) {
|
||||
* чтобы сообщение записанное здесь в стек сообщений совпадало
|
||||
* с тем что записывается в БД в файле useDialogFiber.ts
|
||||
*/
|
||||
const messageId = generateRandomKeyFormSeed(16, fromPublicKey + toPublicKey + timestamp.toString());
|
||||
const messageId = packet.getMessageId();
|
||||
const chachaDecryptedKey = Buffer.from(
|
||||
await decrypt(chachaKey, privatePlain),
|
||||
"binary");
|
||||
@@ -450,7 +449,7 @@ export function DialogProvider(props: DialogProviderProps) {
|
||||
* чтобы сообщение записанное здесь в стек сообщений совпадало
|
||||
* с тем что записывается в БД в файле useDialogFiber.ts
|
||||
*/
|
||||
const messageId = generateRandomKeyFormSeed(16, fromPublicKey + toPublicKey + timestamp.toString());
|
||||
const messageId = packet.getMessageId();
|
||||
|
||||
const groupKey = await getGroupKey(toPublicKey);
|
||||
if(!groupKey){
|
||||
|
||||
@@ -317,7 +317,7 @@ export function useDialogFiber() {
|
||||
const content = packet.getContent();
|
||||
const chachaKey = packet.getChachaKey();
|
||||
const timestamp = packet.getTimestamp();
|
||||
const messageId = generateRandomKeyFormSeed(16, fromPublicKey + toPublicKey + timestamp.toString());
|
||||
const messageId = packet.getMessageId();
|
||||
if(hasGroup(toPublicKey)){
|
||||
/**
|
||||
* Если это групповое сообщение, то игнорируем его здесь
|
||||
|
||||
@@ -65,20 +65,6 @@ export function murmurHash3_32_gc(key: string, seed: number = 0): number {
|
||||
return h1 >>> 0;
|
||||
}
|
||||
|
||||
export function generateRandomKeyFormSeed(length: number, seed: string): string {
|
||||
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
let result = '';
|
||||
const charactersLength = characters.length;
|
||||
let seedHash = murmurHash3_32_gc(seed, 1028);
|
||||
let state = Math.abs(seedHash);
|
||||
for (let i = 0; i < length; i++) {
|
||||
state = (state * 1664525 + 1013904223) % 4294967296;
|
||||
const randomIndex = state % charactersLength;
|
||||
result += characters.charAt(randomIndex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function hashCode(input: string) {
|
||||
let hash = 0;
|
||||
for (let i = 0; i < input.length; i += 1) {
|
||||
|
||||
Reference in New Issue
Block a user