@param Model $recipient

@return bool
486844
public function denyFriendRequest(Model $recipient): bool
    {
        if (!$this->isFriendsWith($recipient)) {
            return false;
        }

        return (bool) $this->findFriendship($recipient)->update([
            'status' => Status::DENIED,
        ]);
    }
491704
public function notify(Model $model, Model $recipient): Mention
    {
        $pool = $this->pool($recipient);

        $notificationClass = class_exists($pool->notification) ? $pool->notification : $this->mentionNotification;

        if (class_exists($notificationClass)) {
            $recipient->notify(new $notificationClass($model));
        }

        return $this;
    }
1268649
public function addRecipient(Recipient $recipient)
    {
        if (!$recipient instanceof Device && !$recipient instanceof Topic) {
            throw new \UnexpectedValueException('currently phpFCM only supports topic and single device messages');
        }

        if (!isset($this->recipientType)) {
            $this->recipientType = get_class($recipient);
        }

        if ($this->recipientType !== get_class($recipient)) {
            throw new \InvalidArgumentException('mixed recepient types are not supported by FCM');
        }

        $this->recipients[] = $recipient;
        return $this;
    }
1339745
public function hasSentFriendRequestTo(Model $recipient)
    {
        return Friendship::whereRecipient($recipient)->whereSender($this)->whereStatus(Status::PENDING)->exists();
    }
819963
public function sendTo(Recipient $recipient, MessageInterface $message)
    {
        $driver = "\\Eyewitness\\Eye\\Notifications\\Drivers\\".ucfirst(strtolower($recipient->type));

        if (class_exists($driver)) {
            $channel = app($driver);
            $channel->fire($recipient, $message);
        } else {
            app(Eye::class)->logger()->debug('Notification Driver does not exist', $driver);
        }
    }
1028721
public function validateSender($sender)
    {
        if (is_null($sender)) {
            $this->addError('sender', 'Sender is null');
            return false;
        }

        if (false === filter_var(key($sender), FILTER_VALIDATE_EMAIL)) {
            $this->addError('sender', sprintf('Sender recipient `%s` must be a valid email address', key($sender)));

            return false;
        }

        return true;
    }
1366314
public function hasFollowRequestFrom(Model $sender)
    {
        return $this->whenFollowedBy($sender)->whereStatus(Status::PENDING)->exists();
    }
865321
public function addRecipients($recipients)
    {
        try {
            if (is_array($recipients)) {
                foreach ($recipients as $recipientsOne) {
                    $this->addRecipient($recipientsOne);
                }
            } else {
                $this->addRecipient($recipientsOne);
            }
        } catch (\Exception $e) {
            return false;
        }

        return true;
    }
1099459
public function retrieveMessages($recipient)
    {
        if (!isset($this->database[$recipient])) {
            return [];
        }

        $messages = $this->database[$recipient];
        unset($this->database[$recipient]);

        return $messages;
    }
218657
public function sendMail(
        $recipient,
        $templatePath,
        $data = array(),
        $blindCopyRecipients = array()
    ) {
        $tmplData = array_merge(
            $data,
            array(
                'footerTxt' => $this->templateFooterTxtPath,
                'footerHtml' => $this->templateFooterHtmlPath,
            )
        );

        // Load template from twig.
        $template = $this->twig->loadTemplate($templatePath);

        // Merge twig globals so that they also are available in renderBlock.
        $tmplData = $this->twig->mergeGlobals($tmplData);

        // Get subject from block.
        $subject = $template->renderBlock('subject', $tmplData);

        $emailBodyText = $template->renderBlock('body_text', $tmplData);
        $emailBodyHtml = $template->renderBlock('body_html', $tmplData);

        /** @var \Swift_Message $message */
        $message = \Swift_Message::newInstance()
            ->setSubject($subject)
            ->setFrom($this->emailFrom)
            ->setTo($recipient)
            ->setBody($emailBodyText, 'text/plain')
            ->addPart($emailBodyHtml, 'text/html');
        
        // add blind copy recipients
        foreach ($blindCopyRecipients as $bcc) {
            $message->addBcc($bcc);
        }

        $failedRecipients = array();
        $this->mailer->send($message, $failedRecipients);

        if (count($failedRecipients) > 0) {
            $this->writeLog('Could not send mail to the following recipients: ' . join(', ', $failedRecipients));

            return false;
        }

        return true;
    }
1190554
protected function setPushableRecipient($recipientType, $recipient)
    {
        if ($recipientType === "device") {
            $this->recipientType = "device_iden";
            $this->recipient = $recipient;
        } else if ($recipientType === "channel") {
            $this->recipientType = "channel_tag";
            $this->recipient = $recipient;
        } else if ($recipientType === "email") {
            if (filter_var($recipient, FILTER_VALIDATE_EMAIL) !== false) {
                $this->recipientType = "email";
                $this->recipient = $recipient;
            } else {
                throw new Exceptions\InvalidRecipientException("Invalid email address.");
            }
        } else {
            throw new Exceptions\InvalidRecipientException("Unknown recipient type.");
        }
    }
695441
private function findFriendship(Model $recipient): Builder
    {
        return Friend::where(function ($query) use ($recipient) {
            $query->where('sender_id', $this->id);
            $query->where('sender_type', get_class($this));

            $query->where('recipient_id', $recipient->id);
            $query->where('recipient_type', get_class($recipient));
        })->orWhere(function ($query) use ($recipient) {
            $query->where('sender_id', $recipient->id);
            $query->where('sender_type', get_class($recipient));

            $query->where('recipient_id', $this->id);
            $query->where('recipient_type', get_class($this));
        });
    }
744149
public function send($message, $recipient, $mustInit = true)
    {
        if ($mustInit) $this->_init();

        $params = array(
            'api' => $this->api_key,
            'number' => $recipient,
            'message' => $message,
            'from' => $this->from,
        );

        $query = http_build_query($params);

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, Config::get('semaphore::url.sms.sms'));
        curl_setopt($ch, CURLOPT_POST, count($params));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $response = curl_exec($ch);
        curl_close($ch);

        return $response;
    }
1343233
protected function sendEmail(array $recipient, array $from, $subject, $bodyHTML = '', $bodyPlain = '', array $replyTo = NULL)
    {

        if ($replyTo == NULL) {
            $replyTo = $from;
        }
        $mail = GeneralUtility::makeInstance(MailMessage::class);
        $mail
            ->setTo($recipient)
            ->setFrom($from)
            ->setReplyTo($replyTo)
            ->setSubject($subject);

        if ($bodyHTML !== '' && $bodyHTML !== NULL ) {
            $mail->addPart($bodyHTML, 'text/html');
        }
        if ($bodyPlain !== '' && $bodyPlain !== NULL ) {
            $mail->addPart($bodyPlain, 'text/plain');
        }

        return $mail->send();
    }
257180
public function retrieveMessages($recipient)
    {
        $statement = $this->connection->prepare(
            'SELECT "timestamp", "sender", "message"
                FROM "phergie-plugin-tell"
                WHERE "recipient" = ?;'
        );

        if ($statement->execute([ $recipient ])) {
            $messages = $statement->fetchAll(\PDO::FETCH_ASSOC);

            $this->connection->prepare(
                'DELETE FROM "phergie-plugin-tell"
                    WHERE "recipient" = ?;'
            )->execute([ $recipient ]);

            return $messages;
        }

        return [];
    }
558845
public function befriend(Model $recipient): bool
    {
        if ($this->isFriendsWith($recipient)) {
            return true;
        }

        $friendship = (new Friend())->forceFill([
            'recipient_id'   => $recipient->id,
            'recipient_type' => get_class($recipient),
            'status'         => Status::PENDING,
        ]);

        return (bool) $this->friends()->save($friendship);
    }
120855
public function acceptFriendRequest(Model $recipient)
    {
        $updated = $this->findFriendship($recipient)->whereRecipient($this)->update([
            'status' => Status::ACCEPTED,
        ]);

        Event::fire('friendships.accepted', [$this, $recipient]);
      
        return $updated;
    }