sdelements / lets-chat

Self-hosted chat app for small teams
http://sdelements.github.io/lets-chat
MIT License
9.76k stars 1.58k forks source link

Messages not realtime #814

Closed anubra266 closed 3 years ago

anubra266 commented 3 years ago

Just cloned it, and can't find all those advanced features, such as password protected rooms. And I have to refresh page to see messages after i send them. It's not realtime, what's causing this, The response makes me pretty sure, this is not how everyone's copy is behaving

simonhabran commented 3 years ago

Hello Anubra. Just installed and same issue for me

anubra266 commented 3 years ago

Thanks @simonhabran. What platform are you on? I'm on Ubuntu 20

src-r-r commented 3 years ago

Doing some investigation I think I found the source of this problem.

If you open the console (F12 for Firefox) and type a message, an error is raised:

Uncaught TypeError: message.owner is null
    addMessage http://localhost:5000/media/dist/chat-90111456a06d8b27e1c3ea2e0f460141.js:735

And doing some debugging, it seems that message.owner is indeed null, but only when posting a message (the addMethod is used when showing message history, and the owner is set accordingly).

I'll be doing more digging into this. Obviously, the owner is stored in Mongo, otherwise, they wouldn't appear. Somewhere along the line of passing the message to the callback the owner is not being set.

My only question: where is the callback for when a user posts a message? From there I can discover where the user is not being set.

eusebiu-biroas commented 3 years ago

Hi, The issue is on app/core/messages.js on line 44. A quickfix would be to replace it with this: User.findOne({'_id': message.owner}, function(err, user) {

alexdparis commented 3 years ago

Hi, thanks for the trick, but unfortunately file upload doesn't work either. Waiting forward for another fix :).

EDIT: just try this fix locally in app/core/files.js online 80 as well : User.findOne({'_id': options.owner}, function(err, user) { seems to work like a charm.

Cheers

YeKoHein commented 1 year ago

The issue is on app/core/messages.js on line 44. A quickfix would be to replace it with this: User.findOne({'_id': message.owner}, function(err, user) {

@eusebiu-biroas Thanks. It is work for me.