Skip to content

Commit

Permalink
v1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
andiwijaya-dev committed Oct 1, 2020
1 parent 374fba5 commit 7f7d723
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/Http/Controllers/ChatAdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Symfony\Component\HttpFoundation\StreamedResponse;

class ChatAdminController extends BaseController
Expand Down Expand Up @@ -256,7 +257,7 @@ public function show(Request $request, $id, array $extra = []){
$messages = $messages->splice(0, $item_per_page)->reverse();
$last_id = $messages->pluck('id')->last();

$customer_is_online = count(Redis::pubsub('channels', 'customer-discussion-' . $discussion->id)) > 0;
$customer_is_online = count(Redis::pubsub('channels', Str::slug(env('APP_NAME')) . '-' . 'customer-discussion-' . $discussion->id)) > 0;

$params = [
'discussion'=>$discussion,
Expand Down Expand Up @@ -424,22 +425,22 @@ public function handle(ChatEvent $event)
];

Redis::publish(
$this->channel_discussion,
Str::slug(env('APP_NAME')) . '-' . $this->channel_discussion,
json_encode($updates)
);

if(isset($event->message) && $event->message->direction == ChatMessage::DIRECTION_IN){
/*if(isset($event->message) && $event->message->direction == ChatMessage::DIRECTION_IN){
$title = "Pesan baru dari " . (Customer::find($event->discussion->key)->name ?? '');
$description = substr($event->message->text, 0, 30) . '...';
$target = "/chat-admin/{$event->discussion->id}";
Redis::publish(
'global-notification',
Str::slug(env('APP_NAME')) . '-' . 'global-notification',
json_encode([
['type' => 'script', 'script' => "$.notify({ title:\"{$title}\", description:\"{$description}\", target:\"{$target}\" })"]
])
);
}
}*/

}

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/ListPageController2.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function handle(ModelEvent $event){
}

Redis::publish(
$this->channel,
Str::slug(env('APP_NAME')) . '-' . $this->channel,
json_encode($updates)
);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Models/ChatDiscussion.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Redis;
use Illuminate\Support\Str;
use Illuminate\Support\Traits\Macroable;

class ChatDiscussion extends Model
Expand Down Expand Up @@ -167,7 +168,7 @@ public static function notifyUnsent($cmd = null){

foreach($discussions as $discussion){

$offline = count(Redis::pubsub('channels', "customer-discussion-{$discussion->id}")) <= 0;
$offline = count(Redis::pubsub('channels', Str::slug(env('APP_NAME')) . '-' . "customer-discussion-{$discussion->id}")) <= 0;

if($offline){
$discussion->sendEmailNotification();
Expand Down
2 changes: 1 addition & 1 deletion src/views/chat-admin.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function chatadmin_keyup(e){
window.scriptBuffer.push(function(){
$.wsListen('{{ $channel_discussion }}', '{{ env('UPDATER_HOST') }}');
$.wsListen('{{ Str::slug(env('APP_NAME')) . '-' . $channel_discussion }}', '{{ env('UPDATER_HOST') }}');
});
</script>
Expand Down

0 comments on commit 7f7d723

Please sign in to comment.