-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mutations to mark chat messages as read, update message, update group chat info, add user to group chat, share images in chats, and create dedicated group chats for events #2625
Conversation
…into chat-feature
…o reply-functionality
Closing this as inactive. |
Reopening. GSoC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🧹 Outside diff range and nitpick comments (2)
src/resolvers/Mutation/sendMessageToChat.ts (1)
90-93
: Consider atomic update for unseenMessagesByUsersThe current implementation might lead to race conditions when multiple users send messages simultaneously.
Consider using MongoDB's atomic operators:
- $set: { - unseenMessagesByUsers: JSON.stringify(unseenMessagesByUsers), - updatedAt: now, - }, + $set: { updatedAt: now }, + $inc: { + 'unseenMessagesByUsers': { + [context.userId]: 0, + ...Object.fromEntries( + Object.keys(unseenMessagesByUsers) + .filter(id => id !== context.userId) + .map(id => [`${id}`, 1]) + ) + } + }src/typeDefs/inputs.ts (1)
33-36
: Enhance chat search capabilitiesThe ChatWhereInput could be expanded to include more useful search criteria.
Consider adding more search fields:
input ChatWhereInput { user: UserWhereInput name_contains: String + isGroup: Boolean + createdAt_gte: DateTime + createdAt_lte: DateTime + hasUnreadMessages: Boolean }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (16)
schema.graphql
(10 hunks)src/models/Chat.ts
(3 hunks)src/models/ChatMessage.ts
(2 hunks)src/models/Event.ts
(3 hunks)src/resolvers/Mutation/index.ts
(3 hunks)src/resolvers/Mutation/sendMessageToChat.ts
(3 hunks)src/resolvers/Query/chatsByUserId.ts
(2 hunks)src/resolvers/Query/helperFunctions/getWhere.ts
(3 hunks)src/resolvers/Query/index.ts
(2 hunks)src/typeDefs/inputs.ts
(2 hunks)src/typeDefs/mutations.ts
(2 hunks)src/typeDefs/queries.ts
(1 hunks)src/typeDefs/types.ts
(2 hunks)src/types/generatedGraphQLTypes.ts
(24 hunks)tests/resolvers/Mutation/sendMessageToChat.spec.ts
(1 hunks)tests/resolvers/Query/eventsByOrganizationConnection.spec.ts
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (10)
- src/resolvers/Query/index.ts
- src/models/Event.ts
- src/resolvers/Mutation/index.ts
- tests/resolvers/Mutation/sendMessageToChat.spec.ts
- tests/resolvers/Query/eventsByOrganizationConnection.spec.ts
- src/typeDefs/queries.ts
- src/models/ChatMessage.ts
- src/resolvers/Query/chatsByUserId.ts
- src/models/Chat.ts
- src/typeDefs/mutations.ts
👮 Files not reviewed due to content moderation or server errors (3)
- src/resolvers/Query/helperFunctions/getWhere.ts
- schema.graphql
- src/types/generatedGraphQLTypes.ts
🔇 Additional comments (2)
src/typeDefs/inputs.ts (1)
157-157
: LGTM: Event chat creation flag added
The createChat boolean field is a good addition to control chat creation for events.
src/typeDefs/types.ts (1)
828-828
: LGTM: Media field added to ChatMessage
The media field addition aligns well with the new file upload functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (5)
src/resolvers/Mutation/markChatMessagesAsRead.ts (2)
10-19
: Update JSDoc remarks to include all validation checks.The remarks section is missing the user authorization check that verifies if the user is a member of the chat.
* @remarks The following checks are done: * 1. If the direct chat exists. * 2. If the user exists + * 3. If the user is a member of the chat
83-89
: Remove redundant chat existence check.The chat existence is already verified at the beginning of the function, making this check redundant.
- if (!updatedChat) { - throw new errors.NotFoundError( - requestContext.translate(CHAT_NOT_FOUND_ERROR.MESSAGE), - CHAT_NOT_FOUND_ERROR.CODE, - CHAT_NOT_FOUND_ERROR.PARAM, - ); - }schema.graphql (3)
213-214
: Consider using a structured type instead of JSON for unseenMessagesByUsers.Using JSON type for unseenMessagesByUsers reduces type safety and makes validation harder. Consider creating a dedicated type.
type UnseenMessages { userId: ID! count: Int! } type Chat { # ...other fields unseenMessagesByUsers: [UnseenMessages!] }
223-223
: Use URL scalar type for media field and add documentation.The media field would benefit from using the URL scalar type and having documentation about supported media types/sizes.
- media: String + """ + URL to the media attachment. Supported types: image/*, video/* + Max size: 10MB + """ + media: URL
2228-2232
: Add documentation and validation directives to createGroupChatInput.The input type would benefit from documentation and validation directives.
+""" +Input for creating a new group chat. +""" input createGroupChatInput { + "ID of the organization this chat belongs to" organizationId: ID! + "Title of the group chat (3-50 characters)" - title: String! + title: String! @constraint(minLength: 3, maxLength: 50) + "List of user IDs to add to the chat (minimum 2 users)" - userIds: [ID!]! + userIds: [ID!]! @constraint(minItems: 2) }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
schema.graphql
(11 hunks)src/resolvers/Mutation/markChatMessagesAsRead.ts
(1 hunks)src/resolvers/Query/chatsByUserId.ts
(2 hunks)src/typeDefs/mutations.ts
(2 hunks)src/types/generatedGraphQLTypes.ts
(27 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- src/resolvers/Query/chatsByUserId.ts
- src/typeDefs/mutations.ts
🔇 Additional comments (3)
src/resolvers/Mutation/markChatMessagesAsRead.ts (2)
1-4
: LGTM! Imports are well structured.
22-32
: LGTM! Proper error handling with performance optimization.
src/types/generatedGraphQLTypes.ts (1)
Line range hint 1-5089
: LGTM! Auto-generated types file.
This file is automatically generated from the GraphQL schema, no manual review needed.
|
Hi @palisadoes |
@disha1202 The PR was merged and the failed tests persist |
@disha1202 Can we merge this now? Can you make changes so that coderabbit.ai approves? |
Please fix the conflicting files |
The merge-base changed after approval.
3a5276a
into
PalisadoesFoundation:develop
What kind of change does this PR introduce?
Feature
Issue Number:
Fixes #2624
Did you add tests for your changes?
Yes
Snapshots/Videos:
If relevant, did you update the documentation?
Summary
Does this PR introduce a breaking change?
Other information
Have you read the contributing guide?
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Documentation
Tests