public function actionDelete($id) { $webhook = WebHook::findByPK(new \MongoId($id)); if ($webhook->delete() == false) { throw new ServerErrorHttpException('Failed to delete webhook for unknown reason.'); } Yii::$app->getResponse()->setStatusCode(204); }
public function syncWebHookChannels($accountId, $weChannels) { $webHook = WebHook::getByAccount($accountId); if (empty($webHook) || empty($webHook->channels)) { return true; } $wechannelIds = ArrayHelper::getColumn($weChannels, 'id'); $enableChannels = array_intersect($webHook->channels, $wechannelIds); if (count($enableChannels) === count($webHook->channels)) { return true; } $webHook->channels = $enableChannels; if (!$webHook->save(true, ['channels'])) { throw new ServerErrorHttpException(\Yii::t('channel', 'data_synchronization_failed')); } return true; }