Skip to content

Commit d6a2fc1

Browse files
committed
fix(config): Refactor message options in exception-notify config
- Update message structure to include 'options' for various message types - Ensure correct assignment of properties like title and content under 'options' - Modify rescue function calls to use the correct namespaced function for consistency
1 parent a7ba61f commit d6a2fc1

File tree

2 files changed

+38
-22
lines changed

2 files changed

+38
-22
lines changed

config/exception-notify.php

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,10 @@
181181
// ],
182182
// 'message' => [
183183
// 'class' => Guanguans\Notify\Foo\Messages\Message::class,
184-
// 'title' => AbstractChannel::CONTENT_TEMPLATE,
185-
// 'content' => AbstractChannel::CONTENT_TEMPLATE,
184+
// 'options' => [
185+
// 'title' => AbstractChannel::CONTENT_TEMPLATE,
186+
// 'content' => AbstractChannel::CONTENT_TEMPLATE,
187+
// ],
186188
// ],
187189
// 'pipes' => [
188190
// LimitLengthPipe::with(1024),
@@ -200,8 +202,6 @@
200202
],
201203
'message' => [
202204
'class' => Guanguans\Notify\Bark\Messages\Message::class,
203-
'title' => AbstractChannel::TITLE_TEMPLATE,
204-
'body' => AbstractChannel::CONTENT_TEMPLATE,
205205
'options' => [
206206
'title' => AbstractChannel::TITLE_TEMPLATE,
207207
'body' => AbstractChannel::CONTENT_TEMPLATE,
@@ -223,8 +223,10 @@
223223
],
224224
'message' => [
225225
'class' => Guanguans\Notify\Chanify\Messages\TextMessage::class,
226-
'title' => AbstractChannel::TITLE_TEMPLATE,
227-
'text' => AbstractChannel::CONTENT_TEMPLATE,
226+
'options' => [
227+
'title' => AbstractChannel::TITLE_TEMPLATE,
228+
'text' => AbstractChannel::CONTENT_TEMPLATE,
229+
],
228230
],
229231
'pipes' => [
230232
LimitLengthPipe::with(1024),
@@ -243,8 +245,10 @@
243245
],
244246
'message' => [
245247
'class' => Guanguans\Notify\DingTalk\Messages\MarkdownMessage::class,
246-
'title' => AbstractChannel::TITLE_TEMPLATE,
247-
'text' => AbstractChannel::CONTENT_TEMPLATE,
248+
'options' => [
249+
'title' => AbstractChannel::TITLE_TEMPLATE,
250+
'text' => AbstractChannel::CONTENT_TEMPLATE,
251+
],
248252
],
249253
'pipes' => [
250254
AddKeywordChorePipe::with(env('EXCEPTION_NOTIFY_DINGTALK_KEYWORD')),
@@ -264,7 +268,9 @@
264268
],
265269
'message' => [
266270
'class' => Guanguans\Notify\Discord\Messages\Message::class,
267-
'content' => AbstractChannel::CONTENT_TEMPLATE,
271+
'options' => [
272+
'content' => AbstractChannel::CONTENT_TEMPLATE,
273+
],
268274
],
269275
'pipes' => [
270276
LimitLengthPipe::with(2000),
@@ -283,7 +289,9 @@
283289
],
284290
'message' => [
285291
'class' => Guanguans\Notify\Lark\Messages\TextMessage::class,
286-
'text' => AbstractChannel::CONTENT_TEMPLATE,
292+
'options' => [
293+
'text' => AbstractChannel::CONTENT_TEMPLATE,
294+
],
287295
],
288296
'pipes' => [
289297
AddKeywordChorePipe::with(env('EXCEPTION_NOTIFY_LARK_KEYWORD')),
@@ -303,9 +311,11 @@
303311
],
304312
'message' => [
305313
'class' => Guanguans\Notify\Ntfy\Messages\Message::class,
306-
'topic' => env('EXCEPTION_NOTIFY_NTFY_TOPIC', 'laravel-exception-notify'),
307-
'title' => AbstractChannel::TITLE_TEMPLATE,
308-
'message' => AbstractChannel::CONTENT_TEMPLATE,
314+
'options' => [
315+
'topic' => env('EXCEPTION_NOTIFY_NTFY_TOPIC', 'laravel-exception-notify'),
316+
'title' => AbstractChannel::TITLE_TEMPLATE,
317+
'message' => AbstractChannel::CONTENT_TEMPLATE,
318+
],
309319
],
310320
'pipes' => [
311321
LimitLengthPipe::with(4096),
@@ -323,9 +333,11 @@
323333
],
324334
'message' => [
325335
'class' => Guanguans\Notify\PushDeer\Messages\Message::class,
326-
'type' => 'markdown',
327-
'text' => AbstractChannel::TITLE_TEMPLATE,
328-
'desp' => AbstractChannel::CONTENT_TEMPLATE,
336+
'options' => [
337+
'type' => 'markdown',
338+
'text' => AbstractChannel::TITLE_TEMPLATE,
339+
'desp' => AbstractChannel::CONTENT_TEMPLATE,
340+
],
329341
],
330342
'pipes' => [
331343
SprintfMarkdownPipe::class,
@@ -344,8 +356,10 @@
344356
],
345357
'message' => [
346358
'class' => Guanguans\Notify\Slack\Messages\Message::class,
347-
'mrkdwn' => true,
348-
'text' => AbstractChannel::CONTENT_TEMPLATE,
359+
'options' => [
360+
'mrkdwn' => true,
361+
'text' => AbstractChannel::CONTENT_TEMPLATE,
362+
],
349363
],
350364
'pipes' => [
351365
SprintfMarkdownPipe::class,
@@ -364,8 +378,10 @@
364378
],
365379
'message' => [
366380
'class' => Guanguans\Notify\Telegram\Messages\TextMessage::class,
367-
'chat_id' => env('EXCEPTION_NOTIFY_TELEGRAM_CHAT_ID'),
368-
'text' => AbstractChannel::CONTENT_TEMPLATE,
381+
'options' => [
382+
'chat_id' => env('EXCEPTION_NOTIFY_TELEGRAM_CHAT_ID'),
383+
'text' => AbstractChannel::CONTENT_TEMPLATE,
384+
],
369385
],
370386
'pipes' => [
371387
LimitLengthPipe::with(4096),

src/Channels/StackChannel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function report(\Throwable $throwable): void
2828
{
2929
collect($this->configRepository->get('channels'))->each(
3030
static function (string $channel) use ($throwable): void {
31-
rescue(static fn (): mixed => ExceptionNotify::driver($channel)->report($throwable));
31+
\Guanguans\LaravelExceptionNotify\Support\rescue(static fn (): mixed => ExceptionNotify::driver($channel)->report($throwable));
3232
}
3333
);
3434
}
@@ -38,7 +38,7 @@ public function reportContent(string $content): array
3838
return collect($this->configRepository->get('channels'))
3939
->mapWithKeys(
4040
static fn (string $channel): array => [
41-
$channel => rescue(static fn () => ExceptionNotify::driver($channel)->reportContent($content)),
41+
$channel => \Guanguans\LaravelExceptionNotify\Support\rescue(static fn () => ExceptionNotify::driver($channel)->reportContent($content)),
4242
]
4343
)
4444
->all();

0 commit comments

Comments
 (0)