1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class MessageType extends \BaseController { |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Display a listing of messages. |
7
|
|
|
* |
8
|
|
|
* @return Response |
9
|
|
|
*/ |
10
|
|
|
public function index() { |
11
|
|
|
$message='typing'; |
12
|
|
|
$data = array( |
13
|
|
|
'room' => Input::get('conversation'), |
|
|
|
|
14
|
|
|
'message' => array( 'body' => Str::words($message, 5), 'user_id' => '') |
|
|
|
|
15
|
|
|
); |
16
|
|
|
|
17
|
|
|
Event::fire(ChatMessagesEventHandler::EVENT, array(json_encode($data))); |
18
|
|
|
|
19
|
|
|
return Response::json([ |
|
|
|
|
20
|
|
|
'success' => true, |
21
|
|
|
'result' => $message |
22
|
|
|
]); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Store a newly created message in storage. |
27
|
|
|
* |
28
|
|
|
* @return Response |
29
|
|
|
*/ |
30
|
|
|
public function store() { |
31
|
|
|
|
32
|
|
|
$rules = array('body' => 'required'); |
33
|
|
|
$validator = Validator::make(Input::all(), $rules); |
34
|
|
|
|
35
|
|
|
if($validator->fails()) { |
36
|
|
|
return Response::json([ |
|
|
|
|
37
|
|
|
'success' => false, |
38
|
|
|
'result' => $validator->messages() |
39
|
|
|
]); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
$conversation = Conversation::where('name', Input::get('conversation'))->first(); |
43
|
|
|
|
44
|
|
|
$params = array( |
45
|
|
|
'conversation_id' => $conversation->id, |
46
|
|
|
'body' => Input::get('body'), |
47
|
|
|
'user_id' => Input::get('user_id'), |
48
|
|
|
'created_at' => new DateTime |
49
|
|
|
); |
50
|
|
|
|
51
|
|
|
$message = Message::create($params); |
52
|
|
|
|
53
|
|
|
// Create Message Notifications |
54
|
|
|
$messages_notifications = array(); |
55
|
|
|
|
56
|
|
|
foreach($conversation->users()->get() as $user) { |
57
|
|
|
array_push($messages_notifications, new MessageNotification(array('user_id' => $user->id, 'conversation_id' => $conversation->id, 'read' => false))); |
|
|
|
|
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
$message->messages_notifications()->saveMany($messages_notifications); |
61
|
|
|
|
62
|
|
|
// Publish Data To Redis |
63
|
|
|
$data = array( |
64
|
|
|
'room' => Input::get('conversation'), |
65
|
|
|
'message' => array( 'body' => Str::words($message->body, 5), 'user_id' => Input::get('user_id')) |
66
|
|
|
); |
67
|
|
|
|
68
|
|
|
Event::fire(ChatMessagesEventHandler::EVENT, array(json_encode($data))); |
69
|
|
|
|
70
|
|
|
return Response::json([ |
|
|
|
|
71
|
|
|
'success' => true, |
72
|
|
|
'result' => $message |
73
|
|
|
]); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths