@param Model $recipient

@return bool
518312
public function hasSentFollowRequestTo(Model $recipient)
    {
        return $this->whenFollowing($recipient)->whereStatus(Status::PENDING)->exists();
    }
1327382
public function setRecipient($user)
    {
        if (!is_string($this->otherGuidAttribute) || empty($this->otherGuidAttribute)) {
            throw new \yii\base\InvalidConfigException('Recipient GUID Attribute Not Specified.');
        }
        if ($user instanceof BaseUserModel) {
            $user = $user->getGUID();
        }
        $otherGuidAttribute = $this->otherGuidAttribute;
        return $this->$otherGuidAttribute = $user;
    }
718552
public function blockFriend(Model $recipient)
    {
        // if there is a friendship between the two users and the sender is not blocked
        // by the recipient user then delete the friendship
        if (!$this->isBlockedBy($recipient)) {
            $this->findFriendship($recipient)->delete();
        }

        $friendship = (new Friendship)->fillRecipient($recipient)->fill([
            'status' => Status::BLOCKED,
        ]);
      
        $this->friends()->save($friendship);

        Event::fire('friendships.blocked', [$this, $recipient]);

        return $friendship;
    }
482704
public function hasBlocked(Model $recipient): bool
    {
        return $this->getFriendship($recipient)->status === Status::BLOCKED;
    }
1213324
public function hasUser( Model $user )
    {
        return $this->users()->where( $user->getKeyName(), "=", $user->getKey() )->first() ? true : false;
    }
685661
public function postMessage($sender, $recipient, $message)
    {
        if ($this->maxMessages) {
            $statement = $this->connection->prepare(
                'SELECT COUNT(*) FROM "phergie-plugin-tell"
                    WHERE "recipient" = ?;'
            );
            $statement->execute([ $recipient ]);

            if ($statement->fetchColumn(0) >= $this->maxMessages) {
                return false;
            }
        }

        $this->connection->prepare(
            'INSERT INTO "phergie-plugin-tell"
                ("sender", "recipient", "message")
                VALUES (?, ?, ?);'
        )->execute([ $sender, $recipient, $message ]);

        return true;
    }
1105074
public function follow(Model $recipient)
    {
        if ($this->followingCountReached()) {
            return false;
        }

        if (!$this->canFollow($recipient)) {
            return false;
        }

        $following = (new Follower)->fillRecipient($recipient)->fill([
            'status' => Status::PENDING,
        ]);

        $this->following()->save($following);

        return $following;
    }
1248333
public function addRecipient(Recipient $recipient){
        $this->to[] = array(
            'email' => $recipient->email,
            'name' => $recipient->name,
            'type' => $recipient->type
        );
        $this->merge_vars[] = array(
            'rcpt' => $recipient->email,
            'vars' => $recipient->getMergeVars()
        );
        $this->recipient_metadata[] = array(
            'rcpt' => $recipient->email,
            'values' => $recipient->getMetadata()
        );
        return $this;
    }
850049
protected function sendMail(Message $mail): bool
    {
        $allRecipients = $mail->getTo() + $mail->getCc() + $mail->getBcc();
        $totalNumberOfRecipients = count($allRecipients);
        $actualNumberOfRecipients = 0;
        $exceptionMessage = '';

        try {
            $actualNumberOfRecipients = $mail->send();
        } catch (\Exception $e) {
            $exceptionMessage = $e->getMessage();
            if ($this->logSendingErrors === self::LOG_LEVEL_LOG) {
                $this->systemLogger->logException($e);
            } elseif ($this->logSendingErrors === self::LOG_LEVEL_THROW) {
                throw $e;
            }
        }

        $emailInfo = [
            'recipients' => array_keys($mail->getTo() + $mail->getCc() + $mail->getBcc()),
            'failedRecipients' => $mail->getFailedRecipients(),
            'subject' => $mail->getSubject(),
            'id' => (string)$mail->getHeaders()->get('Message-ID')
        ];
        if (strlen($exceptionMessage) > 0) {
            $emailInfo['exception'] = $exceptionMessage;
        }

        if ($actualNumberOfRecipients < $totalNumberOfRecipients && $this->logSendingErrors === self::LOG_LEVEL_LOG) {
            $this->systemLogger->log(
                sprintf('Could not send an email to all given recipients. Given %s, sent to %s', $totalNumberOfRecipients, $actualNumberOfRecipients),
                LOG_ERR, $emailInfo);
            return false;
        }

        if ($this->logSendingSuccess === self::LOG_LEVEL_LOG) {
            $this->systemLogger->log('Email sent successfully.', LOG_INFO, $emailInfo);
        }
        return true;
    }
1157402
public static function create(Model $model, Model $recipient, $notify = true): Mention
    {
        $mention = Mention::firstOrCreate([
            'model_type' => get_class($model),
            'model_id' => $model->getKey(),
            'recipient_type' => get_class($recipient),
            'recipient_id' => $recipient->getKey()
        ]);

        if ($notify) {
            $mention->notify($model, $recipient);
        }

        return $mention;
    }
91846
public function canBefriend($recipient)
    {
        // if user has Blocked the recipient and changed his mind
        // he can send a friend request after unblocking
        if ($this->hasBlocked($recipient)) {
            $this->unblockFriend($recipient);
            return true;
        }

        // if sender has a friendship with the recipient return false
        if ($friendship = $this->getFriendship($recipient)) {
            // if previous friendship was Denied then let the user send fr
            if ($friendship->status != Status::DENIED) {
                return false;
            }
        }
        return true;
    }
317262
protected function isWhitelisted($recipient)
    {
        if (in_array($recipient, (array) $this->recipient)) {
            return true;
        }

        foreach ($this->whitelist as $pattern) {
            if (preg_match($pattern, $recipient)) {
                return true;
            }
        }

        return false;
    }
102193
public function decryptUsingKeySet(JWE &$jwe, JWKSet $jwkset, int $recipient): bool
    {
        $this->checkJWKSet($jwkset);
        $this->checkPayload($jwe);
        $this->checkRecipients($jwe);

        $plaintext = $this->decryptRecipientKey($jwe, $jwkset, $recipient);
        if (null !== $plaintext) {
            $jwe = $jwe->withPayload($plaintext);

            return true;
        }

        return false;
    }
1108945
public function email($subject) : bool
    {
        if ($subject === null) {
            return false;
        }
        // FILTER_VALIDATE_EMAIL doesn't reliably require .tld.
        $v = '' . $subject;
        return $v === '' ? false : (
            !!filter_var($v, FILTER_VALIDATE_EMAIL)
            && !!preg_match('/\.[a-zA-Z\d]+$/', $v)
        );
    }
386531
public function addRecipient($recipient)
    {
        if (!is_string($recipient)) {
            throw new \Exception('Recipient is not string.');
        }

        try {
            $new = new EmailUser;
            $new->email = $recipient;

            $this->addRecipientUser($new);
        } catch (\Exception $e) {
            return false;
        }

        return true;
    }
455365
public function isFollowedBy(Model $sender)
    {
        return $sender->whenFollowing($this)->where('status', Status::ACCEPTED)->exists();
    }
956685
public function getText(Kwc_Mail_Recipient_Interface $recipient = null)
    {
        $renderer = new Kwf_Component_Renderer_Mail();
        $renderer->setRenderFormat(Kwf_Component_Renderer_Mail::RENDER_TXT);
        $renderer->setRecipient($recipient);
        $ret = $renderer->renderComponent($this->getData());
        Kwf_Benchmark::checkpoint('text: render');
        $ret = $this->_processPlaceholder($ret, $recipient);
        Kwf_Benchmark::checkpoint('text: placeholder');
        $ret = str_replace('&nbsp;', ' ', $ret);
        $redirect = $this->getData()->getChildComponent('_redirect');
        if ($redirect) {
            $ret = $redirect->getComponent()->replaceLinks($ret, $recipient, 'mailtext');
        }
        Kwf_Benchmark::checkpoint('text: replaceLinks');
        return $ret;
    }