From 643a3eee8554410a908414a76d92f8f20b9181a5 Mon Sep 17 00:00:00 2001 From: John Brunton Date: Sat, 24 Aug 2024 15:05:33 +0100 Subject: [PATCH] feat: invite users (#145) --- client/src/data/messages.ts | 1 + .../src/features/room/organisms/ChatBox.tsx | 6 +- services/api/.eslintrc.js | 2 +- services/api/package-lock.json | 283 ++++++++++-------- services/api/package.json | 6 +- .../src/app/auth/permissions/roles.spec.ts | 55 +++- .../api/src/app/auth/permissions/roles.ts | 29 +- .../api/src/app/messages/command.service.ts | 51 ++-- .../api/src/app/messages/messages.module.ts | 4 + services/api/src/app/users/users.service.ts | 17 +- services/api/src/data/adapters/schema.ts | 2 + .../dynamodb.users.repository.e2e-spec.ts | 39 +-- .../repositories/dynamodb.users.repository.ts | 16 +- .../src/domain/entities/membership.entity.ts | 34 +++ .../domain/entities/memberships.repository.ts | 1 + .../api/src/domain/entities/users/system.ts | 4 +- .../src/domain/entities/users/user.entity.ts | 1 + .../domain/entities/users/users.repository.ts | 19 +- .../src/domain/usecases/commands/help.spec.ts | 2 + .../usecases/commands/parse/command.parser.ts | 2 + .../usecases/commands/parse/parse.spec.ts | 71 +++++ .../usecases/commands/parse/parsers/index.ts | 4 + .../commands/parse/parsers/invite-parser.ts | 16 + .../commands/parse/parsers/leave.parser.ts | 14 + .../src/domain/usecases/rooms/invite.spec.ts | 148 +++++++++ .../api/src/domain/usecases/rooms/invite.ts | 95 ++++++ .../src/domain/usecases/rooms/leave.spec.ts | 59 ++++ .../api/src/domain/usecases/rooms/leave.ts | 43 +++ services/api/src/fixtures/auth/FakeAuth.ts | 1 + .../src/fixtures/auth/auth-info.factory.ts | 1 + .../fixtures/data/test.users.repository.ts | 8 + .../api/src/fixtures/messages/user.factory.ts | 1 + 32 files changed, 837 insertions(+), 198 deletions(-) create mode 100644 services/api/src/domain/usecases/commands/parse/parsers/invite-parser.ts create mode 100644 services/api/src/domain/usecases/commands/parse/parsers/leave.parser.ts create mode 100644 services/api/src/domain/usecases/rooms/invite.spec.ts create mode 100644 services/api/src/domain/usecases/rooms/invite.ts create mode 100644 services/api/src/domain/usecases/rooms/leave.spec.ts create mode 100644 services/api/src/domain/usecases/rooms/leave.ts diff --git a/client/src/data/messages.ts b/client/src/data/messages.ts index 586cd8d1..cb83dd49 100644 --- a/client/src/data/messages.ts +++ b/client/src/data/messages.ts @@ -55,6 +55,7 @@ export const useMessagesSubscription = (roomId?: string, opts: QueryOptions = De } if (message.updatedEntities?.includes('users')) { queryClient.invalidateQueries({ queryKey: ['users'] }) + queryClient.invalidateQueries({ queryKey: ['me'] }) } queryClient.setQueryData(['messages', message.roomId], (messages: Message[] | undefined) => { if (!messages) return diff --git a/client/src/features/room/organisms/ChatBox.tsx b/client/src/features/room/organisms/ChatBox.tsx index 2c398024..7dfbab64 100644 --- a/client/src/features/room/organisms/ChatBox.tsx +++ b/client/src/features/room/organisms/ChatBox.tsx @@ -1,5 +1,5 @@ import { Button, Icon, Textarea, Spinner, VStack, Alert, AlertIcon, Spacer } from '@chakra-ui/react' -import React, { useState, KeyboardEventHandler, useRef, useEffect } from 'react' +import React, { useState, KeyboardEventHandler, useRef, useEffect, ReactElement } from 'react' import { AiOutlineArrowRight } from 'react-icons/ai' import { usePostMessage } from '../../../data/messages' import { useJoinRoom } from '../../../data/rooms' @@ -23,7 +23,7 @@ const JoinAlert = ({ roomId, canJoin }: ChatBoxProps) => { return ( - You need to join this room to chat. + Join this room to chat.