Use UUIDs in group database schema

This commit is contained in:
Fedor Indutny 2021-10-26 15:59:08 -07:00 committed by GitHub
parent 74fde10ff5
commit 63fcdbe787
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 4530 additions and 3664 deletions

View file

@ -19,7 +19,11 @@ import {
getSearchResults,
} from '../../../state/selectors/search';
import { makeLookup } from '../../../util/makeLookup';
import { getDefaultConversation } from '../../helpers/getDefaultConversation';
import { UUID } from '../../../types/UUID';
import {
getDefaultConversation,
getDefaultConversationWithUuid,
} from '../../helpers/getDefaultConversation';
import { ReadStatus } from '../../../messages/MessageReadStatus';
import type { StateType } from '../../../state/reducer';
@ -52,7 +56,7 @@ describe('both/state/selectors/search', () => {
received_at: NOW,
sent_at: NOW,
source: 'source',
sourceUuid: 'sourceUuid',
sourceUuid: UUID.generate().toString(),
timestamp: NOW,
type: 'incoming' as const,
readStatus: ReadStatus.Read,
@ -125,10 +129,9 @@ describe('both/state/selectors/search', () => {
it('returns incoming message', () => {
const searchId = 'search-id';
const fromId = 'from-id';
const toId = 'to-id';
const from = getDefaultConversation({ id: fromId });
const from = getDefaultConversationWithUuid();
const to = getDefaultConversation({ id: toId });
const state = {
@ -136,9 +139,12 @@ describe('both/state/selectors/search', () => {
conversations: {
...getEmptyConversationState(),
conversationLookup: {
[fromId]: from,
[from.id]: from,
[toId]: to,
},
conversationsByUuid: {
[from.uuid]: from,
},
},
search: {
...getEmptySearchState(),
@ -146,7 +152,7 @@ describe('both/state/selectors/search', () => {
[searchId]: {
...getDefaultMessage(searchId),
type: 'incoming' as const,
sourceUuid: fromId,
sourceUuid: from.uuid,
conversationId: toId,
snippet: 'snippet',
body: 'snippet',
@ -178,11 +184,10 @@ describe('both/state/selectors/search', () => {
it('returns the correct "from" and "to" when sent to me', () => {
const searchId = 'search-id';
const fromId = 'from-id';
const toId = fromId;
const myId = 'my-id';
const from = getDefaultConversation({ id: fromId });
const from = getDefaultConversationWithUuid();
const toId = from.uuid;
const meAsRecipient = getDefaultConversation({ id: myId });
const state = {
@ -190,9 +195,12 @@ describe('both/state/selectors/search', () => {
conversations: {
...getEmptyConversationState(),
conversationLookup: {
[fromId]: from,
[from.id]: from,
[myId]: meAsRecipient,
},
conversationsByUuid: {
[from.uuid]: from,
},
},
ourConversationId: myId,
search: {
@ -201,7 +209,7 @@ describe('both/state/selectors/search', () => {
[searchId]: {
...getDefaultMessage(searchId),
type: 'incoming' as const,
sourceUuid: fromId,
sourceUuid: from.uuid,
conversationId: toId,
snippet: 'snippet',
body: 'snippet',
@ -223,24 +231,26 @@ describe('both/state/selectors/search', () => {
it('returns outgoing message and caches appropriately', () => {
const searchId = 'search-id';
const fromId = 'from-id';
const toId = 'to-id';
const from = getDefaultConversation({ id: fromId });
const from = getDefaultConversationWithUuid();
const to = getDefaultConversation({ id: toId });
const state = {
...getEmptyRootState(),
user: {
...getEmptyUserState(),
ourConversationId: fromId,
ourConversationId: from.id,
},
conversations: {
...getEmptyConversationState(),
conversationLookup: {
[fromId]: from,
[from.id]: from,
[toId]: to,
},
conversationsByUuid: {
[from.uuid]: from,
},
},
search: {
...getEmptySearchState(),
@ -293,9 +303,9 @@ describe('both/state/selectors/search', () => {
...state,
conversations: {
...state.conversations,
conversationLookup: {
...state.conversations.conversationLookup,
[fromId]: {
conversationsByUuid: {
...state.conversations.conversationsByUuid,
[from.uuid]: {
...from,
name: 'new-name',
},