cmgmyr / laravel-messenger

Simple user messaging package for Laravel
MIT License
2.47k stars 517 forks source link

Differ between thread types #192

Closed kirkegaard closed 7 years ago

kirkegaard commented 7 years ago

Im currently trying to adding a type to the theads model, so that i can use the same message api but for different things.

In my community thing ill have both private person to person messaging, but also a message board like thing. The two shares many elements api wise so i think it makes sense.

So im preposing to adding a type value to threads to differ between thead types. The api could be something like

// Get latest message board threads
$threads = Thread::from('MESSAGE_BOARD')->latest('updated_at')->get();
// Get private message threads
$threads = Thread::from('MESSAGE_PRIVATE')->forUser($currentUserId)->latest('updated_at')->get();
antonkomarev commented 7 years ago

I think it's Group & Private chats just in other words.

$threads = Thread::whereType('group')->get();

As for me, from it's so obvious.

kirkegaard commented 7 years ago

Wait, so the feature already exists? My idea would support infinit types since you could just add more types on the fly

antonkomarev commented 7 years ago

@kirkegaard It's not exists... this question was raised a lot of times, but this package don't have support of it. You can override Thread model in your AppServiceProvider and add functionality you need.

kirkegaard commented 7 years ago

Yes thats what im doing currently :) Wish it was part of the library though. Seems easy enough to add

antonkomarev commented 7 years ago

Seems so, but there could be some uncertain moments...

If one of participants adding third guy to private thread, should current thread change it's type to group or the new one group should be created with all 3 participants in it? As for me the new group should be created. But what if group with all 3 participants exists - should we just use it, or a new group should be created?

Group chats are pretty common stuff and I believe this package will include this into core one day.

kirkegaard commented 7 years ago

I dont think we're talking about the same thing. When im talking about private, i mean a thread between only the participants. If a third guy is added, the thread stays the same but only the persons who are participants are able to see it.

What i mean by types would be like a forum or bulletin board or conversations between multiple participants or maybe a guest log for a person or profile status updates

Gummibeer commented 7 years ago

@kirkegaard just to save your ass later - don't use this message/chat package for a forum, guestbook or any other kind that's not a chat!

For a forum I recommend you the https://github.com/Riari/laravel-forum package. And simple guestbooks or things like this just need one additional model (post).

What you try doesn't sound like a good usage of this package and it will/can break your neck if this package adds/removes features that you (don't) need or implemented yourself.

PS: If you need status posts, guestbook and things like this that behave the same just different related models you can take a look in the https://laravel.com/docs/5.2/eloquent-relationships#polymorphic-relations these will help you to have one code API, one database table but splitted view options.

cmgmyr commented 7 years ago

@kirkegaard overriding the models will work without a problem, but like @Gummibeer stated - this package might not be the best fit for a forum application (unless it's super simple).

Adding another column to the threads works, but you could also add something like tags with a polymorphic relationship (also what @Gummibeer pointed out).

At this point, I'm not sure if it makes sense to implement a tagging (or similar) system to the package in order to keep it as simple and open as possible.

I'm going to close this issue for now, but feel free to keep the discussion going if you'd like.