| @@ -77,10 +77,16 @@ | ||
| 77 | 77 | // Sanitize data if needed based on webhook structure |
| 78 | 78 | if (isset($data['name'])) { |
| 79 | 79 | $data['name'] = sanitize_text_field($data['name']); |
| 80 | 80 | } |
| 81 | - $webhook->find($id)->saveChanges($data); | |
| 82 | 81 | |
| 82 | + $foundWebhook = $webhook->find($id); | |
| 83 | + if (!$foundWebhook) { | |
| 84 | + return $this->sendError(__('Webhook not found', 'fluent-boards'), 404); | |
| 85 | + } | |
| 86 | + | |
| 87 | + $foundWebhook->saveChanges($data); | |
| 88 | + | |
| 83 | 89 | return [ |
| 84 | 90 | 'webhooks' => $webhook->latest()->get(), |
| 85 | 91 | 'message' => __('Successfully updated the webhook', 'fluent-boards'), |
| 86 | 92 | ]; |
| @@ -274,8 +280,13 @@ | ||
| 274 | 280 | $data['board_id'] = []; |
| 275 | 281 | } |
| 276 | 282 | |
| 277 | 283 | $webhook = Meta::find($id); |
| 284 | + | |
| 285 | + if (!$webhook || $webhook->object_type !== 'outgoing_webhook') { | |
| 286 | + return $this->sendError('Outgoing webhook not found.', 404); | |
| 287 | + } | |
| 288 | + | |
| 278 | 289 | $webhook->value = $data; |
| 279 | 290 | $webhook->save(); |
| 280 | 291 | |
| 281 | 292 | |