Esempio n. 1
0
 /**
  * Run the Update
  *
  * @return mixed|void
  */
 public function call()
 {
     $pheal = $this->setScope('char')->getPheal();
     foreach ($this->api_info->characters as $character) {
         $result = $pheal->MailMessages(['characterID' => $character->characterID]);
         foreach ($result->messages as $message) {
             MailMessage::firstOrCreate(['characterID' => $character->characterID, 'messageID' => $message->messageID, 'senderID' => $message->senderID, 'senderName' => $message->senderName, 'sentDate' => $message->sentDate, 'title' => $message->title, 'toCorpOrAllianceID' => $message->toCorpOrAllianceID === '' ? null : $message->toCorpOrAllianceID, 'toCharacterIDs' => $message->toCharacterIDs === '' ? null : $message->toCharacterIDs, 'toListID' => $message->toListID === '' ? null : $message->toListID]);
         }
     }
     return;
 }
Esempio n. 2
0
 /**
  * @param string $filter
  *
  * @return mixed
  */
 public function doSearchCharacterMail(string $filter)
 {
     // Get the User for permissions and affiliation
     // checks
     $user = auth()->user();
     $messages = MailMessage::join('character_mail_message_bodies', 'character_mail_messages.messageID', '=', 'character_mail_message_bodies.messageID')->join('account_api_key_info_characters', 'character_mail_messages.characterID', '=', 'account_api_key_info_characters.characterID')->join('eve_api_keys', 'eve_api_keys.key_id', '=', 'account_api_key_info_characters.keyID');
     // If the user is a super user, return all
     if (!$user->hasSuperUser()) {
         $messages = $messages->where(function ($query) use($user) {
             // If the user has any affiliations and can
             // list those characters, add them
             if ($user->has('character.mail', false)) {
                 $query = $query->whereIn('account_api_key_info_characters.characterID', array_keys($user->getAffiliationMap()['char']));
             }
             // Add any characters from owner API keys
             $query->orWhere('eve_api_keys.user_id', $user->id);
         });
     }
     // Filter by the query string
     $messages = $messages->where(function ($query) use($filter) {
         $query->where('character_mail_messages.title', 'like', '%' . $filter . '%')->orWhere('character_mail_message_bodies.body', 'like', '%' . $filter . '%');
     });
     return $messages->orderBy('character_mail_messages.sentDate', 'desc')->take(150)->get();
 }
Esempio n. 3
0
 /**
  * Get the mail timeline for all of the characters
  * a logged in user has access to. Either by owning the
  * api key with the characters, or having the correct
  * affiliation & role
  *
  * @return mixed
  */
 public function getCharacterMailTimeline()
 {
     // Get the User for permissions and affiliation
     // checks
     $user = auth()->user();
     $messages = MailMessage::join('character_mail_message_bodies', 'character_mail_messages.messageID', '=', 'character_mail_message_bodies.messageID')->join('account_api_key_info_characters', 'character_mail_messages.characterID', '=', 'account_api_key_info_characters.characterID')->join('eve_api_keys', 'eve_api_keys.key_id', '=', 'account_api_key_info_characters.keyID');
     // If the user is a super user, return all
     if (!$user->hasSuperUser()) {
         $messages = $messages->where(function ($query) use($user) {
             // If the user has any affiliations and can
             // list those characters, add them
             if ($user->has('character.mail', false)) {
                 $query = $query->whereIn('account_api_key_info_characters.characterID', array_keys($user->getAffiliationMap()['char']));
             }
             // Add any characters from owner API keys
             $query->orWhere('eve_api_keys.user_id', $user->id);
         });
     }
     return $messages->groupBy('character_mail_messages.messageID')->orderBy('character_mail_messages.sentDate', 'desc')->paginate(25);
 }
Esempio n. 4
0
 /**
  * The required method to handle the Alert.
  *
  * @return mixed
  */
 protected function getData() : Collection
 {
     return MailMessage::with('body')->where('sentDate', '>', carbon('now')->subMonth())->get();
 }
Esempio n. 5
0
 /**
  * @param int $character_id
  *
  * @return
  */
 public function characterTopMailInteractions(int $character_id)
 {
     return MailMessage::leftJoin('character_affiliations', function ($join) {
         $join->on('character_affiliations.characterID', '=', 'character_mail_messages.senderID');
     })->where('character_mail_messages.characterID', $character_id)->where('character_mail_messages.senderID', '<>', $character_id)->select('character_affiliations.characterID', 'character_affiliations.characterName', 'character_affiliations.corporationID', 'character_affiliations.corporationName', 'character_affiliations.allianceID', 'character_affiliations.allianceName')->selectRaw('count(senderID) as total')->groupBy('senderID');
 }