Skip to content
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

Added features to filter chats, edit messages, add users to group chat, share images as messages, and create dedicated group chats for events #2360

Open
wants to merge 72 commits into
base: develop-postgres
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
1ca936b
Initial commit
disha1202 Jun 8, 2024
c42da5e
Updated the UI of chat screen
disha1202 Jun 27, 2024
3742346
feat: added support to create group chat
disha1202 Jun 30, 2024
06f4af4
implemented group chats
disha1202 Jul 2, 2024
c18b97b
Implemented logic to send messages in group chat
disha1202 Jul 7, 2024
cbde8f7
refactor chat functionality
disha1202 Jul 12, 2024
9950269
fix format
disha1202 Jul 12, 2024
77a392c
refactor code
disha1202 Jul 13, 2024
eb54545
fix failing tests
disha1202 Jul 15, 2024
09427e6
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
disha1202 Jul 15, 2024
6fbaaa2
removed unwanted code
disha1202 Jul 15, 2024
8fffdc5
fix: formatting issues and reverted unwanted changes
disha1202 Jul 15, 2024
f76dc3e
removed unwanted code
disha1202 Jul 15, 2024
d4864a8
implemented reply functionality for direct chat
disha1202 Jul 20, 2024
75fa6c3
implemented reply functionality
disha1202 Jul 27, 2024
58086e2
Updated chat schema
disha1202 Jul 28, 2024
4d6f9a6
fix: contact card ui
disha1202 Jul 31, 2024
a68dcb4
removed unwanted code
disha1202 Jul 31, 2024
3df2541
feat: implemented unseen message functionality
disha1202 Aug 15, 2024
15385ae
fix: create group chat functionality
disha1202 Aug 18, 2024
65fb52d
added filters
disha1202 Aug 25, 2024
6eff29e
feat: add member to group chat
disha1202 Sep 1, 2024
e355314
feat: implemented logic to update group image and name
disha1202 Sep 8, 2024
e125d96
feat: moved chat to organization & added functionality to share media…
disha1202 Sep 9, 2024
1ee07f3
Merge branch 'develop' into schema-update
disha1202 Sep 21, 2024
4525924
fix: formatting issues
disha1202 Sep 21, 2024
f4b6fd0
fix: formatting issue
disha1202 Sep 21, 2024
74899fd
fix: formatting issue
disha1202 Sep 21, 2024
450b587
fix: type errors
disha1202 Sep 21, 2024
b1790e2
fix: tsdoc error
disha1202 Sep 21, 2024
fe66f0a
fix: formatting errors
disha1202 Sep 21, 2024
352b6b5
improve code coverage
disha1202 Sep 21, 2024
9a661e5
improved code coverage
disha1202 Sep 22, 2024
580260a
Merge branch 'develop' of https://github.com/disha1202/talawa-admin i…
disha1202 Sep 22, 2024
a1ea33b
feat: implemented edit message functionality
disha1202 Oct 13, 2024
182eded
Merge branch 'develop' into schema-update
disha1202 Oct 17, 2024
e6e5c24
Update Chat.tsx
disha1202 Oct 17, 2024
789aa19
feat: added option for creating a dedicated group chat for an event
disha1202 Oct 19, 2024
426f34c
Merge branch 'schema-update' of https://github.com/disha1202/talawa-a…
disha1202 Oct 19, 2024
11265e0
fix: failing test cases
disha1202 Oct 20, 2024
bb9ddc8
feat: implemented notifications
disha1202 Oct 20, 2024
85f698c
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
disha1202 Oct 20, 2024
d541812
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
disha1202 Oct 23, 2024
635a115
fix: failing tests
disha1202 Oct 25, 2024
9d581e8
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
disha1202 Oct 25, 2024
4b3850a
reverted unwanted changes
disha1202 Oct 25, 2024
da51531
revert unwanted changes
disha1202 Oct 25, 2024
5f463b0
Merge branch 'develop' of https://github.com/disha1202/talawa-admin i…
disha1202 Oct 26, 2024
a06cfc0
Merge branch 'unseen-msgs' of https://github.com/disha1202/talawa-adm…
disha1202 Oct 26, 2024
2abde8c
feat: added missing queries
disha1202 Oct 26, 2024
972ce3e
fix: formatting issues
disha1202 Oct 27, 2024
a552e05
fix: formatting issues
disha1202 Oct 27, 2024
a0afd7c
fix: failing test cases
disha1202 Oct 27, 2024
14a127a
removed unwanted changes
disha1202 Oct 27, 2024
622e2b6
fix: failing test cases
disha1202 Oct 27, 2024
ad599a9
Merge branch 'develop' into group-chat-features
disha1202 Oct 28, 2024
431e77a
updated translation files
disha1202 Oct 29, 2024
e520ed8
Merge branch 'group-chat-features' of https://github.com/disha1202/ta…
disha1202 Oct 29, 2024
6539100
Merge branch 'develop' of https://github.com/PalisadoesFoundation/tal…
disha1202 Oct 29, 2024
1597197
improved: code coverage
disha1202 Oct 30, 2024
38426f0
Merge branch 'develop' into group-chat-features
disha1202 Oct 30, 2024
566e8c2
Update public/locales/hi/translation.json
disha1202 Oct 30, 2024
38df508
improve code coverage
disha1202 Oct 31, 2024
a184b40
Merge branch 'develop-postgres' of https://github.com/PalisadoesFound…
disha1202 Dec 23, 2024
8a6c1d0
Merge branch 'group-chat-features' of https://github.com/disha1202/ta…
disha1202 Dec 23, 2024
6f3d603
fix: add svg
disha1202 Dec 23, 2024
590d48c
removed unused svg file
disha1202 Dec 23, 2024
44942ab
updated schema.graphql
disha1202 Dec 23, 2024
3b3f412
updated schema.graphql
disha1202 Dec 23, 2024
3260022
updated schema.graphql
disha1202 Dec 23, 2024
cf4d2de
fix: test cases
disha1202 Dec 26, 2024
33b5f24
Merge branch 'develop-postgres' of https://github.com/PalisadoesFound…
disha1202 Dec 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@
"recurringEvent": "Recurring Event",
"isPublic": "Is Public",
"isRegistrable": "Is Registrable",
"createChat": "Create Chat",
"createEvent": "Create Event",
"enterFilter": "Enter Filter",
"enterTitle": "Enter Title",
Expand Down Expand Up @@ -553,6 +554,7 @@
"recurringEvent": "Recurring Event",
"isPublic": "Is Public",
"isRegistrable": "Is Registrable",
"createChat": "Create Chat",
"updatePost": "Update Post",
"eventDetails": "Event Details",
"eventDeleted": "Event deleted successfully.",
Expand Down Expand Up @@ -1193,6 +1195,7 @@
"enterDescription": "Enter Description",
"publicEvent": "Is Public",
"registerable": "Is Registerable",
"createChat": "Create Chat",
"monthlyCalendarView": "Monthly Calendar",
"yearlyCalendarView": "Yearly Calender",
"startTime": "startTime",
Expand Down Expand Up @@ -1248,14 +1251,22 @@
"endOfResults": "endOfResults"
},
"userChat": {
"add": "Add",
"chat": "Chat",
"search": "Search",
"messages": "Messages",
"contacts": "Contacts"
"contacts": "Contacts",
"create": "Create",
"newChat": "New Chat",
"newGroupChat": "New Group Chat",
"groupInfo": "Group Info",
"members": "Members",
"addMembers": "Add Members"
Comment on lines +1265 to +1275
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Missing translations for chat filtering and image sharing.

While the translations cover basic chat and group management features, they're missing keys for:

  1. Chat filtering functionality
  2. Image sharing in messages

These features were mentioned in the PR objectives but lack corresponding UI strings.

Add the following translation keys:

  "userChat": {
    "add": "Add",
    "chat": "Chat",
    "search": "Search",
    "messages": "Messages",
    "contacts": "Contacts",
    "create": "Create",
    "newChat": "New Chat",
    "newGroupChat": "New Group Chat",
    "groupInfo": "Group Info",
    "members": "Members",
    "addMembers": "Add Members",
+   "filterChats": "Filter Chats",
+   "filterByName": "Filter by name",
+   "filterByDate": "Filter by date",
+   "attachImage": "Attach image",
+   "imagePreview": "Image preview"
  }

Committable suggestion was skipped due to low confidence.

},
"userChatRoom": {
"selectContact": "Select a contact to start conversation",
"sendMessage": "Send Message"
"sendMessage": "Send Message",
"reply": "Reply"
Comment on lines +1279 to +1280
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Missing translations for message editing.

While "reply" functionality is supported, the translations don't include strings for editing messages, which was mentioned in the PR objectives.

Add the following translation keys:

  "userChatRoom": {
    "selectContact": "Select a contact to start conversation",
    "sendMessage": "Send Message",
    "reply": "Reply",
+   "editMessage": "Edit message",
+   "saveEdit": "Save changes",
+   "cancelEdit": "Cancel edit"
  }

Committable suggestion was skipped due to low confidence.

},
"orgProfileField": {
"loading": "Loading...",
Expand Down
21 changes: 16 additions & 5 deletions public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@
"startDate": "Date de début",
"endDate": "Date de fin",
"talawaApiUnavailable": "API Talawa indisponible",
"done": "Fait"
"done": "Fait",
"createChat": "Créer une discussion"
Comment on lines +442 to +443
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Fix inconsistent translation for "done".

The key "done" is translated differently across sections:

  • "Fait" in organizationEvents
  • "Terminé" in eventListCard

This inconsistency should be resolved by using the same translation throughout.

Apply this diff to use consistent translation:

  "organizationEvents": {
-   "done": "Fait",
+   "done": "Terminé",
    "createChat": "Créer une discussion"
  },
  "eventListCard": {
    "done": "Terminé",
    "createChat": "Créer une discussion"
  }

Also applies to: 583-584

},
"organizationActionItems": {
"actionItemCategory": "Catégorie de l'Action",
Expand Down Expand Up @@ -579,7 +580,8 @@
"registerEvent": "Inscrire à l'événement",
"close": "Fermer",
"talawaApiUnavailable": "API Talawa non disponible",
"done": "Terminé"
"done": "Terminé",
"createChat": "Créer une discussion"
Comment on lines +583 to +584
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix inconsistent translation for "done".

The key "done" is translated differently across sections:

  • "Fait" in organizationEvents
  • "Terminé" in eventListCard

This inconsistency should be resolved by using the same translation throughout.

},
"funds": {
"title": "Fonds",
Expand Down Expand Up @@ -1204,7 +1206,8 @@
"eventDescription": "Description de l'événement",
"eventLocation": "Lieu de l'événement",
"startDate": "Date de début",
"endDate": "Date de fin"
"endDate": "Date de fin",
"createChat": "Créer une discussion"
},
"userEventCard": {
"starts": "Départs",
Expand Down Expand Up @@ -1248,14 +1251,22 @@
"endOfResults": "Fin des résultats"
},
"userChat": {
"add": "Ajouter",
"chat": "Chat",
"contacts": "Contacts",
"search": "rechercher",
"messages": "messages"
"messages": "messages",
"create": "créer",
"newChat": "nouvelle discussion",
"newGroupChat": "Nouvelle discussion de groupe",
"groupInfo": "Informations sur le groupe",
"members": "Membres",
"addMembers": "Add Members"
Comment on lines +1265 to +1275
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix inconsistent capitalization in chat-related translations.

Some translations start with lowercase letters while most translations in the file start with uppercase. This should be consistent throughout the file.

-    "chat": "Chat",
-    "search": "rechercher",
-    "messages": "messages",
-    "create": "créer",
-    "newChat": "nouvelle discussion",
+    "chat": "Chat",
+    "search": "Rechercher",
+    "messages": "Messages",
+    "create": "Créer",
+    "newChat": "Nouvelle discussion",

-    "reply": "répondre"
+    "reply": "Répondre"

Also applies to: 1206-1207

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Translate the English text to French.

The string "Add Members" should be translated to French to maintain consistency.

-    "addMembers": "Add Members"
+    "addMembers": "Ajouter des membres"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"addMembers": "Add Members"
"addMembers": "Ajouter des membres"

},
"userChatRoom": {
"selectContact": "Sélectionnez un contact pour démarrer la conversation",
"sendMessage": "Envoyer le message"
"sendMessage": "Envoyer le message",
"reply": "répondre"
},
"orgProfileField": {
"loading": "Chargement...",
Expand Down
21 changes: 16 additions & 5 deletions public/locales/hi/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@
"startDate": "प्रारंभ तिथि",
"endDate": "समाप्ति तिथि",
"talawaApiUnavailable": "Talawa API अनुपलब्ध",
"done": "पूर्ण"
"done": "पूर्ण",
"createChat": "चैट बनाएं"
Comment on lines +442 to +443
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Move chat-related translations to the appropriate section.

The translations for "done" and "createChat" appear to be misplaced in the "organizationEvents" section. These strings are related to chat functionality and should be moved to the "userChat" or "userChatRoom" sections for better organization and maintainability.

Apply this diff to move the translations to the appropriate section:

  "organizationEvents": {
-   "done": "पूर्ण",
-   "createChat": "चैट बनाएं"
  },
  "userChat": {
+   "done": "पूर्ण",
+   "createChat": "चैट बनाएं"
  }

Committable suggestion was skipped due to low confidence.

},
"organizationActionItems": {
"actionItemCategory": "क्रिया वस्तु श्रेणी",
Expand Down Expand Up @@ -579,7 +580,8 @@
"registerEvent": "कार्यक्रम के लिए पंजीकरण करें",
"close": "बंद करें",
"talawaApiUnavailable": "Talawa API अनुपलब्ध",
"done": "समाप्त"
"done": "समाप्त",
"createChat": "चैट बनाएं"
Comment on lines +583 to +584
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Move chat-related translations to the appropriate section.

Similarly, the translations for "done" and "createChat" in the "eventListCard" section should be moved to the "userChat" section to maintain consistency and avoid duplication.

Apply this diff to consolidate chat-related translations:

  "eventListCard": {
-   "done": "समाप्त",
-   "createChat": "चैट बनाएं"
  },
  "userChat": {
+   "done": "समाप्त",
+   "createChat": "चैट बनाएं"
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"done": "समाप्त",
"createChat": "चैट बनाएं"
"done": "समाप्त",
"createChat": "चैट बनाएं"

},
"funds": {
"title": "फंड",
Expand Down Expand Up @@ -1204,7 +1206,8 @@
"eventDescription": "कार्यक्रम विवरण",
"eventLocation": "कार्यक्रम स्थान",
"startDate": "प्रारंभ तिथि",
"endDate": "समाप्ति तिथि"
"endDate": "समाप्ति तिथि",
"createChat": "चैट बनाएं"
},
"userEventCard": {
"starts": "प्रारंभ होगा",
Expand Down Expand Up @@ -1248,14 +1251,22 @@
"endOfResults": "परिणाम समाप्त"
},
"userChat": {
"add": "जोड़ें",
"chat": "बात करना",
"contacts": "संपर्क",
"search": "खोज",
"messages": "संदेश"
"messages": "संदेश",
"create": "बनाएं",
"newChat": "नई चैट",
"newGroupChat": "नया समूह चैट",
"groupInfo": "समूह जानकारी",
"members": "सदस्यों",
"addMembers": "सदस्य जोड़ें"
},
"userChatRoom": {
"selectContact": "बातचीत शुरू करने के लिए एक संपर्क चुनें",
"sendMessage": "मेसेज भेजें"
"sendMessage": "मेसेज भेजें",
"reply": "जवाब"
},
"orgProfileField": {
"loading": "लोड हो रहा है...",
Expand Down
21 changes: 16 additions & 5 deletions public/locales/sp/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@
"on": "En",
"after": "Después de",
"occurences": "ocurrencias",
"done": "Hecho"
"done": "Hecho",
"createChat": "Crear chat"
},
"organizationActionItems": {
"actionItemCategory": "Categoría de Acción",
Expand Down Expand Up @@ -579,7 +580,8 @@
"on": "En",
"after": "Después de",
"occurences": "ocurrencias",
"done": "Hecho"
"done": "Hecho",
"createChat": "Crear chat"
},
"funds": {
"title": "Fondos",
Expand Down Expand Up @@ -1206,7 +1208,8 @@
"publicEvent": "Es público",
"registerable": "Es registrable",
"monthlyCalendarView": "Calendario mensual",
"yearlyCalendarView": "Calendario anual"
"yearlyCalendarView": "Calendario anual",
"createChat": "Crear chat"
},
"userEventCard": {
"location": "Ubicación",
Expand Down Expand Up @@ -1250,14 +1253,22 @@
"createAdvertisement": "Crear publicidad"
},
"userChat": {
"add": "Agregar",
"chat": "Charlar",
"search": "Buscar",
"contacts": "Contactos",
"messages": "Mensajes"
"messages": "Mensajes",
"create": "crear",
"newChat": "nueva charla",
"newGroupChat": "Nuevo chat grupal",
"groupInfo": "Información del grupo",
"members": "Miembros",
"addMembers": "Add Members"
},
"userChatRoom": {
"selectContact": "Seleccione un contacto para iniciar una conversación",
"sendMessage": "Enviar mensaje"
"sendMessage": "Enviar mensaje",
"reply": "responder"
},
"orgProfileField": {
"loading": "Cargando..",
Expand Down
21 changes: 16 additions & 5 deletions public/locales/zh/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@
"startDate": "开始日期",
"endDate": "结束日期",
"talawaApiUnavailable": "塔拉瓦 API 不可用",
"done": "完成"
"done": "完成",
"createChat": "创建聊天"
Comment on lines +442 to +443
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Consolidate redundant "createChat" translations.

The translation key "createChat" with value "创建聊天" is duplicated across multiple sections. Consider consolidating it into a single location under the "userChat" section.

Apply this diff:

  "organizationEvents": {
    "done": "完成",
-   "createChat": "创建聊天"
  },
  "eventListCard": {
    "done": "完成",
-   "createChat": "创建聊天"
  },
  "userEvents": {
    "endDate": "结束日期",
-   "createChat": "创建聊天"
  },
  "userChat": {
    "add": "添加",
    "chat": "聊天",
    ...
+   "createChat": "创建聊天"
  }

Also applies to: 562-563, 1147-1148

},
"organizationActionItems": {
"actionItemCategory": "行动项类别",
Expand Down Expand Up @@ -579,7 +580,8 @@
"registerEvent": "注册活动",
"close": "关闭",
"talawaApiUnavailable": "塔拉瓦 API 不可用",
"done": "完成"
"done": "完成",
"createChat": "创建聊天"
},
"funds": {
"title": "基金",
Expand Down Expand Up @@ -1204,7 +1206,8 @@
"eventDescription": "活动描述",
"eventLocation": "活动位置",
"startDate": "开始日期",
"endDate": "结束日期"
"endDate": "结束日期",
"createChat": "创建聊天"
},
"userEventCard": {
"starts": "开始",
Expand Down Expand Up @@ -1248,14 +1251,22 @@
"endOfResults": "结果结束"
},
"userChat": {
"add": "添加",
"chat": "聊天",
"contacts": "联系方式",
"search": "搜索",
"messages": "消息"
"messages": "消息",
"create": "创造",
"newChat": "新聊天",
"newGroupChat": "新群聊",
"groupInfo": "集团信息",
"members": "会员",
"addMembers": "Add Members"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Translate the "Add Members" text to Chinese.

The text "Add Members" is in English while this file contains Chinese translations.

Apply this diff to fix the translation:

-    "addMembers": "Add Members"
+    "addMembers": "添加成员"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"addMembers": "Add Members"
"addMembers": "添加成员"

Comment on lines +1265 to +1275
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add missing translations for new chat features.

Several key chat features mentioned in the PR objectives are missing translations:

Add the following translations to the userChat section:

  "userChat": {
    "add": "添加",
    "chat": "聊天",
    "contacts": "联系方式",
    "search": "搜索",
    "messages": "消息",
    "create": "创造",
    "newChat": "新聊天",
    "newGroupChat": "新群聊",
    "groupInfo": "集团信息",
    "members": "会员",
    "addMembers": "Add Members",
+   "filterChats": "筛选聊天",
+   "editMessage": "编辑消息",
+   "shareImage": "分享图片",
+   "eventChat": "活动聊天"
  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"add": "添加",
"chat": "聊天",
"contacts": "联系方式",
"search": "搜索",
"messages": "消息"
"messages": "消息",
"create": "创造",
"newChat": "新聊天",
"newGroupChat": "新群聊",
"groupInfo": "集团信息",
"members": "会员",
"addMembers": "Add Members"
"add": "添加",
"chat": "聊天",
"contacts": "联系方式",
"search": "搜索",
"messages": "消息",
"create": "创造",
"newChat": "新聊天",
"newGroupChat": "新群聊",
"groupInfo": "集团信息",
"members": "会员",
"addMembers": "Add Members",
"filterChats": "筛选聊天",
"editMessage": "编辑消息",
"shareImage": "分享图片",
"eventChat": "活动聊天"

},
"userChatRoom": {
"selectContact": "选择联系人开始对话",
"sendMessage": "发信息"
"sendMessage": "发信息",
"reply": "回复"
},
"orgProfileField": {
"loading": "加载中...",
Expand Down
5 changes: 3 additions & 2 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ type Chat {
updatedAt: DateTime!
users: [User!]!
admins: [User]
unseenMessagesByUsers: JSON
lastMessageId: String
}

Expand All @@ -516,7 +517,6 @@ type ChatMessage {
createdAt: DateTime!
chatMessageBelongsTo: Chat!
messageContent: String!
type: String!
replyTo: ChatMessage
sender: User!
deletedBy: [User]
Expand Down Expand Up @@ -694,7 +694,8 @@ type Mutation {
revokeRefreshTokenForUser: Boolean!
saveFcmToken(token: String): Boolean!
sendMembershipRequest(organizationId: ID!): MembershipRequest!
sendMessageToChat(chatId: ID!, messageContent: String!, type: String!, replyTo: ID): ChatMessage!
sendMessageToChat(chatId: ID!, messageContent: String!, replyTo: ID): ChatMessage!
markChatMessagesAsRead(chatId: ID!, userId: ID!): Chat
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider enhancing markChatMessagesAsRead mutation.

The mutation could be improved by:

  1. Returning the number of messages marked as read
  2. Supporting batch operations for multiple chats

Consider this alternative design:

type MarkChatMessagesAsReadPayload {
  chat: Chat!
  markedMessagesCount: Int!
}

extend type Mutation {
  markChatMessagesAsRead(input: MarkChatMessagesAsReadInput!): MarkChatMessagesAsReadPayload!
}

input MarkChatMessagesAsReadInput {
  chatId: ID!
  userId: ID!
  """
  Optional: Mark messages as read up to this message ID
  If not provided, marks all messages as read
  """
  upToMessageId: ID
}

signUp(data: UserInput!, file: String): AuthData!
togglePostPin(id: ID!, title: String): Post!
unassignUserTag(input: ToggleUserTagAssignInput!): User
Expand Down
3 changes: 2 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,14 @@ function app(): JSX.Element {
<Route element={<SecuredRouteForUser />}>
<Route path="/user/organizations" element={<Organizations />} />
<Route path="/user/settings" element={<Settings />} />
<Route path="/user/chat" element={<Chat />} />
{/* <Route path="/user/chat" element={<Chat />} /> */}
<Route element={<UserScreen />}>
<Route path="/user/organizations" element={<Organizations />} />
<Route path="/user/organization/:orgId" element={<Posts />} />
<Route path="/user/people/:orgId" element={<People />} />
<Route path="/user/donate/:orgId" element={<Donate />} />
<Route path="/user/events/:orgId" element={<Events />} />
<Route path="/user/chat/:orgId" element={<Chat />} />
<Route path="/user/campaigns/:orgId" element={<Campaigns />} />
<Route path="/user/pledges/:orgId" element={<Pledges />} />
<Route
Expand Down
51 changes: 50 additions & 1 deletion src/GraphQl/Mutations/OrganizationMutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,34 +63,83 @@ export const CREATE_CHAT = gql`
$organizationId: ID
$isGroup: Boolean!
$name: String
$image: String
) {
createChat(
data: {
userIds: $userIds
organizationId: $organizationId
isGroup: $isGroup
name: $name
image: $image
}
) {
_id
}
}
`;

export const ADD_USER_TO_GROUP_CHAT = gql`
mutation addUserToGroupChat($userId: ID!, $chatId: ID!) {
addUserToGroupChat(userId: $userId, chatId: $chatId) {
_id
}
}
`;
Comment on lines +82 to +88
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider enhancing error handling in ADD_USER_TO_GROUP_CHAT mutation

While the mutation is well-structured, consider adding:

  1. Error handling for when the user is already in the group
  2. Validation to ensure the chat exists and is a group chat
  3. Permission checks to verify if the requester has rights to add users


export const MARK_CHAT_MESSAGES_AS_READ = gql`
mutation markChatMessagesAsRead($chatId: ID!, $userId: ID!) {
markChatMessagesAsRead(chatId: $chatId, userId: $userId) {
_id
}
}
`;
Comment on lines +90 to +96
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

Consider retrieving userId server-side in MARK_CHAT_MESSAGES_AS_READ

Passing userId as a parameter can pose security risks if a user manipulates it maliciously. It's recommended to retrieve the userId from the authenticated session on the server side to ensure users can only mark their own messages as read.


export const UPDATE_CHAT = gql`
mutation updateChat($input: UpdateChatInput!) {
updateChat(input: $input) {
_id
}
}
`;

export const EDIT_CHAT_MESSAGE = gql`
mutation updateChatMessage(
$messageId: ID!
$messageContent: String!
$chatId: ID!
) {
updateChatMessage(
input: {
messageId: $messageId
messageContent: $messageContent
chatId: $chatId
}
) {
_id
messageContent
updatedAt
}
}
`;

export const SEND_MESSAGE_TO_CHAT = gql`
mutation sendMessageToChat(
$chatId: ID!
$replyTo: ID
$messageContent: String!
$media: String
$messageContent: String
Comment on lines +130 to +131
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add input validation to SEND_MESSAGE_TO_CHAT mutation

The mutation allows both messageContent and media to be optional. Consider adding validation to ensure at least one is provided to prevent empty messages.

Also applies to: 137-137

) {
sendMessageToChat(
chatId: $chatId
replyTo: $replyTo
messageContent: $messageContent
media: $media
Comment on lines +130 to +137
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

Validate input to prevent empty messages in SEND_MESSAGE_TO_CHAT

Both media and messageContent are optional parameters. Consider adding validation to ensure that at least one of them is provided when sending a message. This will prevent the creation of empty messages and enhance user experience.

) {
_id
createdAt
messageContent
media
replyTo {
_id
createdAt
Expand Down
Loading
Loading