]> git.mxchange.org Git - friendica.git/commitdiff
Some cleaning up
authorMichael <heluecht@pirati.ca>
Mon, 6 May 2019 18:46:30 +0000 (18:46 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 6 May 2019 18:46:30 +0000 (18:46 +0000)
src/Model/Contact.php
src/Module/FollowConfirm.php

index a0e746f511514248e7a2de6c15dacfd80ddc2595..326bae0ff8569882d78f9882a196e0f6e5824705 100644 (file)
@@ -125,13 +125,14 @@ class Contact extends BaseObject
        }
 
        /**
-        * @param  integer       $id
+        * @param integer $id     Contact ID
+        * @param array   $fields Array of selected fields, empty for all
         * @return array|boolean Contact record if it exists, false otherwise
         * @throws \Exception
         */
-       public static function getById($id)
+       public static function getById($id, $fields = [])
        {
-               return DBA::selectFirst('contact', [], ['id' => $id]);
+               return DBA::selectFirst('contact', $fields, ['id' => $id]);
        }
 
        /**
index 1e632d92a9e0a805f62ff3e6135968a28d0c30e6..1921e748a8161dddb51ff33edb702935506ff5f8 100644 (file)
@@ -8,10 +8,14 @@ use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Database\DBA;
 use Friendica\Model\Contact;
+use Friendica\Model\User;
 use Friendica\Protocol\Diaspora;
 use Friendica\Protocol\ActivityPub;
 use Friendica\Util\DateTimeFormat;
 
+/**
+ * Process follow request confirmations
+ */
 class FollowConfirm extends BaseModule
 {
        public static function post()
@@ -34,11 +38,11 @@ class FollowConfirm extends BaseModule
                        return;
                }
 
-               Logger::log('Confirming follower with contact_id: ' . $cid);
+               Logger::info('Confirming follower', ['cid' => $cid]);
 
                $contact = DBA::selectFirst('contact', [], ['id' => $cid, 'uid' => $uid]);
                if (!DBA::isResult($contact)) {
-                       Logger::log('Contact not found in DB.');
+                       Logger::warning('Contact not found in DB.', ['cid' => $cid]);
                        notice(L10n::t('Contact not found.') . EOL);
                        return;
                }
@@ -77,10 +81,10 @@ class FollowConfirm extends BaseModule
 
                if ($new_relation == Contact::FRIEND) {
                        if ($protocol == Protocol::DIASPORA) {
-                               $user = DBA::selectFirst('user', [], ['uid' => $uid]);
-                               $contact = DBA::select('contact', [], ['id' => $cid]);
+                               $user = User::getById($uid);
+                               $contact = Contact::getById($cid);
                                $ret = Diaspora::sendShare($user, $contact);
-                               Logger::log('share returns: ' . $ret);
+                               Logger::info('share returns', ['return' => $ret]);
                        } elseif ($protocol == Protocol::ACTIVITYPUB) {
                                ActivityPub\Transmitter::sendActivity('Follow', $contact['url'], $uid);
                        }