Chats icon application throws following error.
8/10 12:23:10 [16860] - error: TypeError: Cannot set property 'users' of undefined
at /opt/applications/nodebb/src/messaging.js:156:16
at Array.forEach (native)
at async.waterfall.plugins.fireHook.rooms (/opt/applications/nodebb/src/messaging.js:155:21)
at nextTask (/opt/applications/nodebb/node_modules/async/dist/async.js:5297:14)
at next (/opt/applications/nodebb/node_modules/async/dist/async.js:5304:9)
at /opt/applications/nodebb/node_modules/async/dist/async.js:906:16
at /opt/applications/nodebb/node_modules/async/dist/async.js:3861:9
at /opt/applications/nodebb/node_modules/async/dist/async.js:421:16
at iterateeCallback (/opt/applications/nodebb/node_modules/async/dist/async.js:928:24)
at /opt/applications/nodebb/node_modules/async/dist/async.js:906:16
at /opt/applications/nodebb/node_modules/async/dist/async.js:3858:13
at /opt/applications/nodebb/node_modules/async/dist/async.js:1074:9
at /opt/applications/nodebb/node_modules/async/dist/async.js:421:16
at iteratorCallback (/opt/applications/nodebb/node_modules/async/dist/async.js:998:13)
at /opt/applications/nodebb/node_modules/async/dist/async.js:906:16
at /opt/applications/nodebb/node_modules/async/dist/async.js:1071:13
8/10 12:23:10 [16860] - info: [app] Shutdown (SIGTERM/SIGINT) Initialised.
8/10 12:23:10 [16860] - info: [app] Database connection closed.
8/10 12:23:10 [16860] - info: [app] Web server closed to connections.
8/10 12:23:10 [16860] - info: [app] Shutdown complete.
[cluster] Child Process (16860) has exited (code: 1, signal: null)
[cluster] Spinning up another process...
8/10 12:23:11 [16889] - info: Initializing NodeBB v1.6.0 https://forum.mycontroller.org
8/10 12:23:13 [16889] - info: [socket.io] Restricting access to origin: https://forum.mycontroller.org:*
8/10 12:23:14 [16889] - info: Routes added
8/10 12:23:14 [16889] - info: NodeBB Ready
8/10 12:23:14 [16889] - info: Enabling 'trust proxy'
8/10 12:23:14 [16889] - info: NodeBB is now listening on: 0.0.0.0:4567
I did console.log** and I have the data on this step. If you need I can post that data too.
Are you able to share a database dump with us? If this is production data, then nevermind
@julianlam Yes, this is production database. I can share results object data, privately
Give me your email or some way to share the data.
Certainly, if you could do a mongo dump and send us the .bson file of your database, to julian [at] nodebb.org, we can try to reproduce with your db.
@julianlam Thank you! Kindly check your email.
@jkandasa let us know if you have issues on master
@barisusakli Thank you for the fix. After applied this fix. It doesn't fix the actual issue. Just handled the error in a place. I don't see any of my old chat histories. I lose my data with this fix.
It shows only one user on chat history. I remember I have many users in my chant history. Even for that one user, it doesn't show the history.
I tried to search user on history page and clicked that user. It throws an error, as shown here.

13/10 07:57:13 [9431] - error: /api/user/jkandasa/chats/7
Error: [[error:no-chat-room]]
at /opt/applications/nodebb/src/messaging/rooms.js:18:22
at nextTask (/opt/applications/nodebb/node_modules/async/dist/async.js:5297:14)
at next (/opt/applications/nodebb/node_modules/async/dist/async.js:5304:9)
at /opt/applications/nodebb/node_modules/async/dist/async.js:906:16
at handleCallback (/opt/applications/nodebb/node_modules/mongodb/lib/utils.js:120:56)
at /opt/applications/nodebb/node_modules/mongodb/lib/collection.js:1417:5
at handleCallback (/opt/applications/nodebb/node_modules/mongodb/lib/utils.js:120:56)
at /opt/applications/nodebb/node_modules/mongodb/lib/cursor.js:682:5
at handleCallback (/opt/applications/nodebb/node_modules/mongodb-core/lib/cursor.js:171:5)
at setCursorNotified (/opt/applications/nodebb/node_modules/mongodb-core/lib/cursor.js:515:3)
at /opt/applications/nodebb/node_modules/mongodb-core/lib/cursor.js:590:16
at queryCallback (/opt/applications/nodebb/node_modules/mongodb-core/lib/cursor.js:232:18)
at /opt/applications/nodebb/node_modules/mongodb-core/lib/connection/pool.js:469:18
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
Another issue:
I initiated the new chat with the new user. Now I see duplicate names on the chat history.

I guess I have the problem with chat history table migrations from the old build(I guess 0.9x). Can you provide a script to upgrade chat history to new schema?
If we cannot upgrade to the new schema, just provide a script to remove all old chat histories. That will remove my old data and should work with new chats.
This upgrade script is supposed to upgrade from pre 1.0.0 to the new chat rooms. Not sure why your room data is broken.
If you have a database backup pre upgrade you can try again.
If you want to remove all current chat room data you can run the following queries.
db.objects.remove({_key: /^uid:\d+:chat:room/});
db.objects.remove({_key: /^chat:room:\d+/});
As usual don't forget to make a backup.
There is also a way to run particular upgrade scripts.
@barisusakli thank you!
@pitaj Please guide me to run this upgrade script. I do not have much knowledge on javascript.
./nodebb upgrade chat_room_hashes && ./nodebb upgrade chat_upgrade
@pitaj
./nodebb upgrade chat_room_hashes && ./nodebb upgrade chat_upgrade
This line did awesome job! All fixed now :+1: Thank you so much!