Skip to content

Commit

Permalink
feat: new user conversation endpoints
Browse files Browse the repository at this point in the history
- roles can now be created and assigned to participants.
- new query/subscription to view user conversation participants.
- adding and removing participants that do/don't exist won't error out the whole flow.
- ensured that you can only add users to a conversation if they are following you.
  • Loading branch information
Creaous committed Dec 15, 2024
1 parent bcd9d0a commit 942c553
Show file tree
Hide file tree
Showing 4 changed files with 453 additions and 90 deletions.
2 changes: 1 addition & 1 deletion src/drizzle/schema/user/Conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const userConversationRole = pgTable(
{
id: uuid('id').defaultRandom().notNull(),
name: citext('name').notNull(),
description: citext('description').notNull(),
description: citext('description'),
conversationId: uuid('conversation_id').notNull(),
default: boolean('default').notNull().default(false),
permissions: citext('permissions')
Expand Down
15 changes: 14 additions & 1 deletion src/helpers/user/Conversation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { db } from '../../drizzle/db';
import { throwError } from '../common';

const validPermissions = [
'ADD_PARTICIPANTS',
'REMOVE_PARTICIPANTS',
'SEND_MESSAGES',
'CREATE_ROLES'
];

const getConversation = async (id: string) => {
const conversation = await db.query.userConversation.findFirst({
where: (userConversation, { eq }) => eq(userConversation.id, id)
Expand Down Expand Up @@ -70,4 +77,10 @@ const checkPermissions = async (
}
};

export { checkPermissions, getConversation, getParticipant, getPermissions };
export {
checkPermissions,
getConversation,
getParticipant,
getPermissions,
validPermissions
};
Loading

0 comments on commit 942c553

Please sign in to comment.