Пример #1
0
 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;
 }