setPost($data); $curl->addHeader("$sign_header: $sign"); $curl->addHeader("Content-Type: application/json"); $curl->createCurl(); return true; } /** * Process the webhook. * */ public static function process($sender, &$params) { $item = $params['item']; if (!in_array($item->type, array('new_commit', 'upload'))) { // We do nothing. return; } if (isset($params['res']['IDF_Webhook::process']) and $params['res']['IDF_Webhook::process'] == true) { // Already processed. return; } if ($item->payload['url'] == '') { // We do nothing. return; } // We have either to retry or to push for the first time. $res = self::processNotification($item->payload); if ($res) { $params['res']['IDF_Webhook::process'] = true; } elseif ($item->trials >= 9) { // We are at trial 10, give up $params['res']['IDF_Webhook::process'] = true; } else { // Need to try again $params['res']['IDF_Webhook::process'] = false; } } }