Skip to content

Commit 9b90178

Browse files
authored
Chat refactor (#11779)
* first part of chat refactor remove per user chat zsets & store all mids in chat:room:<roomId>:mids reverse uids in getUidsInRoom * feat: create room button public groups wip * feat: public rooms create chats:room zset chat room deletion * join socket.io room * get rid of some calls that load all users in room * dont load all users when loadRoom is called * mange room users infinitescroll dont load all members in api call * IS for user list ability to change groups field for public rooms update groups field if group is renamed * test: test fixes * wip * keep 150 messages * fix extra awaits fix dupe code in chat toggleReadState * unread state for public rooms * feat: faster push unread * test: spec * change base to harmony * test: lint fixes * fix language of chat with message * add 2 methods for perf messaging.getTeasers and getUsers(roomIds) instead of loading one by one * refactor: cleaner conditional * test fix upgrade script fix save timestamp of room creation in room object * set progress.total * don't check for guests/spiders * public room unread fix * add public unread counts * mark read on send * ignore instead of throwing * doggy.gif * fix: restore delete * prevent entering chat rooms with meta.enter * fix self message causing mark unread * ability to sort public rooms * dont init sortable on mobile * move chat-loaded class to core * test: fix spec * add missing keys * use ajaxify * refactor: store some refs * fix: when user is deleted remove from public rooms as well * feat: change how unread count is calculated * get rid of cleaned content get rid of mid * add help text * test: fix tests, add back mid to prevent breaking change * ability to search members of chat rooms * remove * derp * perf: switch with partial data fix tests * more fixes if user leaves a group leave public rooms is he is no longer part of any of the groups that have access fix the cache key used to get all public room ids dont allow joining chat socket.io room if user is no longer part of group * fix: lint * fix: js error when trying to delete room after switching * add isRoomPublic
1 parent edd8ca9 commit 9b90178

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1749
-567
lines changed

Gruntfile.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ module.exports = function (grunt) {
4949
if (!pluginList.includes('nodebb-plugin-composer-default')) {
5050
pluginList.push('nodebb-plugin-composer-default');
5151
}
52-
if (!pluginList.includes('nodebb-theme-persona')) {
53-
pluginList.push('nodebb-theme-persona');
52+
if (!pluginList.includes('nodebb-theme-harmony')) {
53+
pluginList.push('nodebb-theme-harmony');
5454
}
5555
}
5656

public/language/en-GB/error.json

+1
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@
230230
"not-in-room": "User not in room",
231231
"cant-kick-self": "You can't kick yourself from the group",
232232
"no-users-selected": "No user(s) selected",
233+
"no-groups-selected": "No group(s) selected",
233234
"invalid-home-page-route": "Invalid home page route",
234235

235236
"invalid-session": "Invalid Session",

public/language/en-GB/modules.json

+15-1
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,29 @@
2727
"chat.three_months": "3 Months",
2828
"chat.delete_message_confirm": "Are you sure you wish to delete this message?",
2929
"chat.retrieving-users": "Retrieving users...",
30+
"chat.view-users-list": "View users list",
31+
"chat.public-rooms": "Public Rooms (%1)",
32+
"chat.private-rooms": "Private Rooms (%1)",
33+
"chat.create-room": "Create Chat Room",
34+
"chat.private.option": "Private (Only visible to users added to room)",
35+
"chat.public.option": "Public (Visible to every user in selected groups)",
36+
"chat.public.groups-help": "To create a chat room that is visible to all users select registered-users from the group list.",
3037
"chat.manage-room": "Manage Chat Room",
38+
"chat.add-user": "Add User",
39+
"chat.select-groups": "Select Groups",
3140
"chat.add-user-help": "Search for users here. When selected, the user will be added to the chat. The new user will not be able to see chat messages written before they were added to the conversation. Only room owners (<i class=\"fa fa-star text-warning\"></i>) may remove users from chat rooms.",
3241
"chat.confirm-chat-with-dnd-user": "This user has set their status to DnD(Do not disturb). Do you still want to chat with them?",
42+
"chat.room-name-optional": "Room Name (Optional)",
3343
"chat.rename-room": "Rename Room",
3444
"chat.rename-placeholder": "Enter your room name here",
3545
"chat.rename-help": "The room name set here will be viewable by all participants in the room.",
36-
"chat.leave": "Leave Chat",
46+
"chat.leave": "Leave",
47+
"chat.leave-room": "Leave Room",
3748
"chat.leave-prompt": "Are you sure you wish to leave this chat?",
3849
"chat.leave-help": "Leaving this chat will remove you from future correspondence in this chat. If you are re-added in the future, you will not see any chat history from prior to your re-joining.",
50+
"chat.delete": "Delete",
51+
"chat.delete-room": "Delete Room",
52+
"chat.delete-prompt": "Are you sure you wish to delete this chat room?",
3953
"chat.in-room": "In this room",
4054
"chat.kick": "Kick",
4155
"chat.show-ip": "Show IP",

public/openapi/components/schemas/Chats.yaml

+13-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@ RoomObject:
99
description: unique identifier for the chat room
1010
roomName:
1111
type: string
12+
description: the name of the room, if set this is displayed instead of the usernames
1213
groupChat:
1314
type: boolean
14-
description: whether the chat room is a group chat or not
15+
description: whether the chat room is a group chat or not (if more than 2 users it is a group chat)
16+
public:
17+
type: boolean
18+
description: whether the chat room is public or private
19+
userCount:
20+
type: number
21+
description: number of users in this chat room
22+
timestamp:
23+
type: number
24+
description: Timestamp of when room was created
1525
MessageObject:
1626
type: object
1727
properties:
@@ -92,8 +102,6 @@ MessageObject:
92102
type: number
93103
newSet:
94104
type: boolean
95-
cleanedContent:
96-
type: string
97105
RoomUserList:
98106
type: object
99107
properties:
@@ -132,6 +140,8 @@ RoomUserList:
132140
type: boolean
133141
canKick:
134142
type: boolean
143+
index:
144+
type: number
135145
RoomObjectFull:
136146
# Messaging.loadRoom
137147
allOf:

public/openapi/read/user/userslug/chats/roomid.yaml

+171-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ get:
3030
type: number
3131
roomName:
3232
type: string
33+
public:
34+
type: boolean
35+
userCount:
36+
type: number
37+
timestamp:
38+
type: number
39+
description: Timestamp of when room was created
3340
messages:
3441
type: array
3542
items:
@@ -101,8 +108,6 @@ get:
101108
type: boolean
102109
index:
103110
type: number
104-
cleanedContent:
105-
type: string
106111
isOwner:
107112
type: boolean
108113
isOwner:
@@ -139,6 +144,8 @@ get:
139144
example: "#f44336"
140145
isOwner:
141146
type: boolean
147+
index:
148+
type: number
142149
canReply:
143150
type: boolean
144151
groupChat:
@@ -153,6 +160,8 @@ get:
153160
type: boolean
154161
isAdminOrGlobalMod:
155162
type: boolean
163+
isAdmin:
164+
type: boolean
156165
rooms:
157166
type: array
158167
items:
@@ -166,6 +175,162 @@ get:
166175
type: number
167176
roomName:
168177
type: string
178+
public:
179+
type: boolean
180+
userCount:
181+
type: number
182+
timestamp:
183+
type: number
184+
description: Timestamp of when room was created
185+
users:
186+
type: array
187+
items:
188+
type: object
189+
properties:
190+
uid:
191+
type: number
192+
description: A user identifier
193+
username:
194+
type: string
195+
description: A friendly name for a given user account
196+
displayname:
197+
type: string
198+
description: This is either username or fullname depending on forum and user settings
199+
userslug:
200+
type: string
201+
description: An URL-safe variant of the username (i.e. lower-cased, spaces
202+
removed, etc.)
203+
picture:
204+
nullable: true
205+
type: string
206+
status:
207+
type: string
208+
lastonline:
209+
type: number
210+
icon:text:
211+
type: string
212+
description: A single-letter representation of a username. This is used in the
213+
auto-generated icon given to users without
214+
an avatar
215+
icon:bgColor:
216+
type: string
217+
description: A six-character hexadecimal colour code assigned to the user. This
218+
value is used in conjunction with
219+
`icon:text` for the user's auto-generated
220+
icon
221+
example: "#f44336"
222+
lastonlineISO:
223+
type: string
224+
groupChat:
225+
type: boolean
226+
unread:
227+
type: boolean
228+
teaser:
229+
type: object
230+
properties:
231+
fromuid:
232+
type: number
233+
content:
234+
type: string
235+
timestamp:
236+
type: number
237+
timestampISO:
238+
type: string
239+
description: An ISO 8601 formatted date string (complementing `timestamp`)
240+
user:
241+
type: object
242+
properties:
243+
uid:
244+
type: number
245+
description: A user identifier
246+
username:
247+
type: string
248+
description: A friendly name for a given user account
249+
displayname:
250+
type: string
251+
description: This is either username or fullname depending on forum and user settings
252+
userslug:
253+
type: string
254+
description: An URL-safe variant of the username (i.e. lower-cased, spaces
255+
removed, etc.)
256+
picture:
257+
nullable: true
258+
type: string
259+
status:
260+
type: string
261+
lastonline:
262+
type: number
263+
icon:text:
264+
type: string
265+
description: A single-letter representation of a username. This is used in the
266+
auto-generated icon given to users
267+
without an avatar
268+
icon:bgColor:
269+
type: string
270+
description: A six-character hexadecimal colour code assigned to the user. This
271+
value is used in conjunction with
272+
`icon:text` for the user's
273+
auto-generated icon
274+
example: "#f44336"
275+
lastonlineISO:
276+
type: string
277+
nullable: true
278+
lastUser:
279+
type: object
280+
properties:
281+
uid:
282+
type: number
283+
description: A user identifier
284+
username:
285+
type: string
286+
description: A friendly name for a given user account
287+
displayname:
288+
type: string
289+
description: This is either username or fullname depending on forum and user settings
290+
userslug:
291+
type: string
292+
description: An URL-safe variant of the username (i.e. lower-cased, spaces
293+
removed, etc.)
294+
picture:
295+
nullable: true
296+
type: string
297+
status:
298+
type: string
299+
lastonline:
300+
type: number
301+
icon:text:
302+
type: string
303+
description: A single-letter representation of a username. This is used in the
304+
auto-generated icon given to users without
305+
an avatar
306+
icon:bgColor:
307+
type: string
308+
description: A six-character hexadecimal colour code assigned to the user. This
309+
value is used in conjunction with
310+
`icon:text` for the user's auto-generated
311+
icon
312+
example: "#f44336"
313+
lastonlineISO:
314+
type: string
315+
usernames:
316+
type: string
317+
chatWithMessage:
318+
type: string
319+
publicRooms:
320+
type: array
321+
items:
322+
type: object
323+
properties:
324+
owner:
325+
oneOf:
326+
- type: number
327+
- type: string
328+
roomId:
329+
type: number
330+
roomName:
331+
type: string
332+
public:
333+
type: boolean
169334
users:
170335
type: array
171336
items:
@@ -300,6 +465,8 @@ get:
300465
type: string
301466
chatWithMessage:
302467
type: string
468+
privateRoomCount:
469+
type: number
303470
nextStart:
304471
type: number
305472
title:
@@ -315,4 +482,6 @@ get:
315482
type: boolean
316483
chatWithMessage:
317484
type: string
485+
bodyClasses:
486+
type: array
318487
- $ref: ../../../../components/schemas/CommonProps.yaml#/CommonProps

public/openapi/write.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ paths:
198198
$ref: 'write/admin/analytics.yaml'
199199
/admin/analytics/{set}:
200200
$ref: 'write/admin/analytics/set.yaml'
201+
/admin/chats/{roomId}:
202+
$ref: 'write/admin/chats/roomId.yaml'
201203
/admin/tokens:
202204
$ref: 'write/admin/tokens.yaml'
203205
/admin/tokens/{token}:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
delete:
2+
tags:
3+
- admin
4+
summary: delete chat room
5+
description: This operation deletes a chat room from the database
6+
parameters:
7+
- in: path
8+
name: roomId
9+
schema:
10+
type: number
11+
description: The roomId to be deleted
12+
example: 1
13+
required: true
14+
responses:
15+
'200':
16+
description: Chat room deleted
17+
content:
18+
application/json:
19+
schema:
20+
type: object
21+
properties:
22+
status:
23+
$ref: ../../../components/schemas/Status.yaml#/Status
24+
response:
25+
type: object
26+
properties: {}

public/openapi/write/chats/roomId.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ post:
8686
newSet:
8787
type: boolean
8888
description: Whether the message is considered part of a new "set" of messages. It is used in the frontend UI for explicitly denoting that a time gap existed between messages.
89-
cleanedContent:
90-
type: string
9189
mid:
9290
type: number
9391
put:

0 commit comments

Comments
 (0)