-
-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathmessenger.php
383 lines (367 loc) · 15.8 KB
/
messenger.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
<?php
return [
/*
|--------------------------------------------------------------------------
| Messenger Providers Configuration
|--------------------------------------------------------------------------
|
| Define every model you wish to use within this messenger system.
| The name provided will be the alias used for that class,
| including upload folder names, channel names, etc.
|
| *PLEASE NOTE: Once you choose an alias, you should not change it
| unless you plan to move the uploads/directory names around yourself!
|
| *Each provider you list must implement our MessengerProvider contract.
| We also provide a Messagable trait you can use on your model that has
| the basic methods this messenger needs (name / avatar / etc).
| -RTippin\Messenger\Traits\Messageable
| -RTippin\Messenger\Contracts\MessengerProvider
|
| *To enable a provider to be searchable, you must implement our contract
| listed below, and implement the static method for the query builder. We
| include a trait you can use or reference to jump right in!
| -RTippin\Messenger\Traits\Search
| -RTippin\Messenger\Contracts\Searchable
|
| *Provider interactions give fine grain control over how your provider can interact with other providers, should you have
| multiple. A provider always has full permission for interactions between itself, e.g : User to User. To allow full
| interactions between other providers, simply mark each value as TRUE. For no other interactions, mark NULL or FALSE.
| To specify which and how each provider can interact with one another, declare each providers alias string, multiple
| separated by the PIPE, e.g : 'company', 'company|teacher|user', etc.
|
| 'company' => [ //alias given to your provider
| 'model' => App\Models\Company::class, //Path to the provider's model
| 'searchable' => true, //Provider implements/is searchable - true|false
| 'friendable' => true, //Provider is friendable - true|false
| 'devices' => true, //Provider has tokens for push notifications - true|false
| 'default_avatar' => public_path('pic.png') //Default avatar path used when provider has no upload avatar
| 'provider_interactions' => [ //What your provider can do with other providers
| 'can_message' => 'user', //Able to start new threads with other listed providers - true|false|null|string
| 'can_search' => 'user|teacher', //Able to search other listed providers - true|false|null|string
| 'can_friend' => false, //Able to send friend request to other listed providers - true|false|null|string
| ]
| ],
*/
'providers' => [
'user' => [
'model' => App\Models\User::class,
'searchable' => true,
'friendable' => true,
'devices' => false,
'default_avatar' => public_path('vendor/messenger/images/users.png'),
'provider_interactions' => [
'can_message' => true,
'can_search' => true,
'can_friend' => true,
],
],
],
/*
|--------------------------------------------------------------------------
| Provider UUIDs
|--------------------------------------------------------------------------
|
| All of our tables that have relations to one of your providers will use
| a morphTo. If your providers use UUIDs (char 36) as their primary keys,
| then set this to true. Please note that if you use multiple providers,
| they all must have matching primary key types (int / char / etc).
|
*/
'provider_uuids' => false,
/*
|--------------------------------------------------------------------------
| Filesystem settings for provider avatars and thread files
|--------------------------------------------------------------------------
|
| For each option below, please seleck the filesystem disk and leading
| directory you wish you use.
|
| *The avatar is where we will store a providers uploaded image. By default,
| this will store into the storage_path('app/public/images/{alias}/{id}'),
| given laravels default 'public' disk followed by 'images' directory
|
| *The threads option is where a thread avatar, image messages, and document
| messages will be stored. You should not use the public directory as we
| will process all files securely though the backend on request.
|
| //Thread files
|
| **Avatar - {disk}/{directory}/{threadID}/avatar
| **Images - {disk}/{directory}/{threadID}/images
| **Documents - {disk}/{directory}/{threadID}/documents
| **Audio - {disk}/{directory}/{threadID}/audio
|
*/
'storage' => [
'avatars' => [
'disk' => 'public',
'directory' => 'images',
],
'threads' => [
'disk' => 'messenger',
'directory' => 'threads',
],
],
/*
|--------------------------------------------------------------------------
| Messenger routing config
|--------------------------------------------------------------------------
|
| Our API is the core of this package, and bootstrap all of our policies
| and controllers for you. Our built in middleware 'messenger.provider'
| simply takes the authenticated user via the request and sets them
| as the current messenger provider. You are free to use your own
| custom middleware to set your provider, as well as any other
| middleware you may want, such as 'auth:api' etc.
|
| All API routes return json, and are best used stateless through
| auth:api such as passport or sanctum.
|
| Invite api has individual middleware control so you may allow
| both guest or authed users to access.
|
| *For the broadcasting channels to register, you must have already
| setup/defined your laravel apps broadcast driver.
|
*/
'routing' => [
'api' => [
'domain' => null,
'prefix' => 'api/messenger',
'middleware' => ['web', 'auth', 'messenger.provider:required'],
'invite_api_middleware' => ['web', 'auth.optional', 'messenger.provider'],
],
'assets' => [
'domain' => null,
'prefix' => 'messenger/assets',
'middleware' => ['web', 'cache.headers:public, max-age=86400;'],
],
'channels' => [
'enabled' => true,
'domain' => null,
'prefix' => 'api',
'middleware' => ['web', 'auth', 'messenger.provider:required'],
],
],
/*
|--------------------------------------------------------------------------
| API rate limits / request per minute allowed. Use 0 for unlimited
|--------------------------------------------------------------------------
|
*/
'rate_limits' => [
'api' => 1000, // Applies over entire API
'search' => 45, // Applies on search
'message' => 60, // Applies to sending messages per thread
'attachment' => 15, // Applies to uploading images/documents per thread
],
/*
|--------------------------------------------------------------------------
| File toggles to enable / disable features and default image paths.
| Size limits are the max upload size in kilobytes.
|--------------------------------------------------------------------------
|
*/
'files' => [
'message_documents' => [
'upload' => env('MESSENGER_MESSAGE_DOCUMENT_UPLOAD', true),
'size_limit' => env('MESSENGER_MESSAGE_DOCUMENT_SIZE_LIMIT', 10240),
'mime_types' => env('MESSENGER_MESSAGE_DOCUMENT_MIME_TYPES', 'csv,doc,docx,json,pdf,ppt,pptx,rar,rtf,txt,xls,xlsx,xml,zip,7z'),
],
'message_images' => [
'upload' => env('MESSENGER_MESSAGE_IMAGE_UPLOAD', true),
'size_limit' => env('MESSENGER_MESSAGE_IMAGE_SIZE_LIMIT', 5120),
'mime_types' => env('MESSENGER_MESSAGE_IMAGE_MIME_TYPES', 'jpg,jpeg,png,bmp,gif,webp'),
],
'message_audio' => [
'upload' => env('MESSENGER_MESSAGE_AUDIO_UPLOAD', true),
'size_limit' => env('MESSENGER_MESSAGE_AUDIO_SIZE_LIMIT', 10240),
'mime_types' => env('MESSENGER_MESSAGE_AUDIO_MIME_TYPES', 'aac,mp3,oga,ogg,wav,weba,webm'),
],
'avatars' => [
'providers' => env('MESSENGER_PROVIDER_AVATARS_ENABLED', true),
'threads' => env('MESSENGER_THREAD_AVATARS_ENABLED', true),
'bots' => env('MESSENGER_BOT_AVATARS_ENABLED', true),
'size_limit' => env('MESSENGER_AVATARS_SIZE_LIMIT', 5120),
'mime_types' => env('MESSENGER_AVATARS_MIME_TYPES', 'jpg,jpeg,png,bmp,gif,webp'),
],
'default_not_found_image' => public_path('vendor/messenger/images/image404.png'),
'default_ghost_avatar' => public_path('vendor/messenger/images/users.png'),
'default_thread_avatar' => public_path('vendor/messenger/images/threads.png'),
'default_bot_avatar' => public_path('vendor/messenger/images/bots.png'),
],
/*
|--------------------------------------------------------------------------
| Calling
|--------------------------------------------------------------------------
| Enable or disable the calling feature. If enabled, you must also declare
| the driver we will use within a boot method from one of your service
| providers. You may use our messenger facade to set the driver.
|
| Messenger::setVideoDriver(JanusBroker::class);
|
| We provide an event subscriber to listen and react to calling events. You
| may choose to enable it, whether it puts jobs on the queue or not, and
| which queue channel its jobs are dispatched on.
*/
'calling' => [
'enabled' => env('MESSENGER_CALLING_ENABLED', false),
'subscriber' => [
'enabled' => true,
'queued' => true,
'channel' => 'messenger',
],
],
/*
|--------------------------------------------------------------------------
| System Messages
|--------------------------------------------------------------------------
|
| Enable or disable system messages. These are messages generated by actions
| to give feedback in the thread history. Actions such as: call ended, left
| group, promoted admin, etc.
|
| We provide an event subscriber to listen and react to events that will
| generate the system messages. You may choose to enable it, whether it
| puts jobs on the queue or not, and which queue channel its jobs are
| dispatched on.
*/
'system_messages' => [
'enabled' => env('MESSENGER_SYSTEM_MESSAGES_ENABLED', true),
'subscriber' => [
'enabled' => true,
'queued' => true,
'channel' => 'messenger',
],
],
/*
|--------------------------------------------------------------------------
| Bots
|--------------------------------------------------------------------------
|
| Enable or disable the bots feature. When enabled, bots may be created
| within group threads. A bot may contain many actions with triggers
| that will respond to a message.
|
| We provide an event subscriber to listen and react to events that may
| trigger a bot response. You may choose to enable it, whether it puts
| jobs on the queue or not, and which queue channel its jobs are
| dispatched on.
*/
'bots' => [
'enabled' => env('MESSENGER_BOTS_ENABLED', false),
'subscriber' => [
'enabled' => true,
'queued' => true,
'channel' => 'messenger-bots',
],
],
/*
|--------------------------------------------------------------------------
| Push Notification Events
|--------------------------------------------------------------------------
|
| Enable or disable firing our push notification event for every broadcast
| that is not sent over presence. This system only works if you are using
| our default BroadcastBroker for our broadcast driver.
*/
'push_notifications' => env('MESSENGER_PUSH_NOTIFICATIONS_ENABLED', false),
/*
|--------------------------------------------------------------------------
| Message Edits
|--------------------------------------------------------------------------
|
| Enable or disable the edit message feature. When enabled, the owner of a
| message will be allowed to edit that message. A history of the edits will
| be stored, should you enable our default queued_event_listeners. You may
| also allow/deny users in a thread to view the edit history of the message.
|
*/
'message_edits' => [
'enabled' => env('MESSENGER_MESSAGE_EDITS_ENABLED', true),
'history_view' => env('MESSENGER_MESSAGE_EDITS_VIEW_HISTORY', true),
],
/*
|--------------------------------------------------------------------------
| Message Reactions
|--------------------------------------------------------------------------
|
| Enable or disable the message reactions feature and the max unique allowed
| per message. This feature behaves similar to discord, where a single user
| may react to a single message more than once with different emotes.
|
*/
'message_reactions' => [
'enabled' => env('MESSENGER_MESSAGE_REACTIONS_ENABLED', true),
'max_unique' => env('MESSENGER_MESSAGE_REACTIONS_MAX_UNIQUE', 10),
],
/*
|--------------------------------------------------------------------------
| Thread invitations
|--------------------------------------------------------------------------
|
| Enable or disable thread invites. You may also set the max active
| invites each thread may have at any given time. 0 for unlimited
|
*/
'invites' => [
'enabled' => env('MESSENGER_INVITES_ENABLED', true),
'max_per_thread' => env('MESSENGER_INVITES_THREAD_MAX', 3),
],
/*
|--------------------------------------------------------------------------
| Knock knock!! 👊
|--------------------------------------------------------------------------
|
| Enable or disable knocks, and set the timeout limit (in minutes).
| Set to 0 for no timeout.
|
*/
'knocks' => [
'enabled' => env('MESSENGER_KNOCKS_ENABLED', true),
'timeout' => env('MESSENGER_KNOCKS_TIMEOUT', 5),
],
/*
|--------------------------------------------------------------------------
| Provider online/away status
|--------------------------------------------------------------------------
|
| Enable or disable showing online/away states, and set the lifetime the
| status will live in cache (in minutes)
|
*/
'online_status' => [
'enabled' => env('MESSENGER_ONLINE_STATUS_ENABLED', true),
'lifetime' => env('MESSENGER_ONLINE_STATUS_LIFETIME', 4),
],
/*
|--------------------------------------------------------------------------
| Resource collection results limit
|--------------------------------------------------------------------------
|
| Here you can define the default query limits for resource collections
|
*/
'collections' => [
'search' => [
'page_count' => 25,
],
'threads' => [
'index_count' => 100,
'page_count' => 25,
],
'participants' => [
'index_count' => 500,
'page_count' => 50,
],
'messages' => [
'index_count' => 50,
'page_count' => 50,
],
'calls' => [
'index_count' => 25,
'page_count' => 25,
],
],
];