/**
  * Push report into DB
  * @param string $address email address
  * @param array $data list of additional data
  * @return bool true on success, false otherwise
  */
 public function pushReport($address, array $data)
 {
     if (empty($data)) {
         return false;
     }
     if ($this->hasReport($address)) {
         return false;
     }
     if (!isset($data['critical'])) {
         $data['critical'] = false;
     }
     if (isset($data['status']) && in_array($data['status'], $this->softStatuses)) {
         $data['critical'] = false;
     }
     if ($this->numberOfBounces($address) > $this->maxSoftBounces) {
         $data['critical'] = true;
     }
     $history = new BounceHistory();
     $history->email = $address;
     $history->is_critical = $data['critical'] ? 1 : 0;
     $history->reason = isset($data['reason']) ? $data['reason'] : '';
     $history->status = isset($data['status']) ? $data['status'] : '';
     $history->type = isset($data['type']) ? $data['type'] : '';
     if ($history->save() && $data['critical']) {
         $bounce = new Bounce();
         $bounce->email = $address;
         $bounce->save();
     }
     return true;
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Bounce::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['time' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }