]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Contact/Poke.php
Merge pull request #11003 from annando/fix-api
[friendica.git] / src / Module / Contact / Poke.php
index 955d4bab0e7cc2fa465c5bb6e078b8f6498b19ee..23ec95a435ff9f60c96f9d5dad117e9263f48481 100644 (file)
@@ -18,9 +18,9 @@ use Friendica\Util\XML;
 
 class Poke extends BaseModule
 {
-       public static function post(array $parameters = [])
+       public function post()
        {
-               if (!local_user() || empty($parameters['id'])) {
+               if (!local_user() || empty($this->parameters['id'])) {
                        return self::postReturn(false);
                }
 
@@ -39,14 +39,14 @@ class Poke extends BaseModule
 
                $activity = Activity::POKE . '#' . urlencode($verbs[$verb][0]);
 
-               $contact_id = intval($parameters['id']);
+               $contact_id = intval($this->parameters['id']);
                if (!$contact_id) {
                        return self::postReturn(false);
                }
 
                Logger::info('verb ' . $verb . ' contact ' . $contact_id);
 
-               $contact = DBA::selectFirst('contact', ['id', 'name', 'url', 'photo'], ['id' => $parameters['id'], 'uid' => local_user()]);
+               $contact = DBA::selectFirst('contact', ['id', 'name', 'url', 'photo'], ['id' => $this->parameters['id'], 'uid' => local_user()]);
                if (!DBA::isResult($contact)) {
                        return self::postReturn(false);
                }
@@ -55,10 +55,11 @@ class Poke extends BaseModule
 
                $private = !empty($_POST['private']) ? Model\Item::PRIVATE : Model\Item::PUBLIC;
 
-               $allow_cid     = ($private ? '<' . $contact['id']. '>' : $a->user['allow_cid']);
-               $allow_gid     = ($private ? '' : $a->user['allow_gid']);
-               $deny_cid      = ($private ? '' : $a->user['deny_cid']);
-               $deny_gid      = ($private ? '' : $a->user['deny_gid']);
+               $user = Model\User::getById($a->getLoggedInUserId());
+               $allow_cid     = ($private ? '<' . $contact['id']. '>' : $user['allow_cid']);
+               $allow_gid     = ($private ? '' : $user['allow_gid']);
+               $deny_cid      = ($private ? '' : $user['deny_cid']);
+               $deny_gid      = ($private ? '' : $user['deny_gid']);
 
                $actor = Contact::getById($a->getContactId());
 
@@ -122,17 +123,17 @@ class Poke extends BaseModule
                return $success;
        }
 
-       public static function content(array $parameters = [])
+       public function content(): string
        {
                if (!local_user()) {
                        throw new HTTPException\UnauthorizedException(DI::l10n()->t('You must be logged in to use this module.'));
                }
 
-               if (empty($parameters['id'])) {
+               if (empty($this->parameters['id'])) {
                        throw new HTTPException\BadRequestException();
                }
 
-               $contact = DBA::selectFirst('contact', ['id', 'url', 'name'], ['id' => $parameters['id'], 'uid' => local_user()]);
+               $contact = DBA::selectFirst('contact', ['id', 'url', 'name'], ['id' => $this->parameters['id'], 'uid' => local_user()]);
                if (!DBA::isResult($contact)) {
                        throw new HTTPException\NotFoundException();
                }