]> git.mxchange.org Git - friendica.git/blobdiff - include/diaspora.php
DFRN: Improved delivery status handling
[friendica.git] / include / diaspora.php
index 58a77dca8654f4f225dae35e69f444cdb3f58d6c..7cc3e8122663f9257f754816125533db4370ad65 100644 (file)
@@ -928,11 +928,9 @@ class Diaspora {
                 * Normally this should have handled by getting a request - but this could get lost
                 */
                if ($contact["rel"] == CONTACT_IS_FOLLOWER && in_array($importer["page-flags"], array(PAGE_FREELOVE))) {
-                       q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d",
-                               intval(CONTACT_IS_FRIEND),
-                               intval($contact["id"]),
-                               intval($importer["uid"])
-                       );
+                       dba::update('contact', array('rel' => CONTACT_IS_FRIEND, 'writable' => true),
+                                       array('id' => $contact["id"], 'uid' => $contact["uid"]));
+
                        $contact["rel"] = CONTACT_IS_FRIEND;
                        logger("defining user ".$contact["nick"]." as friend");
                }
@@ -1475,10 +1473,7 @@ class Diaspora {
 
                        // Formerly we stored the signed text, the signature and the author in different fields.
                        // We now store the raw data so that we are more flexible.
-                       q("INSERT INTO `sign` (`iid`,`signed_text`) VALUES (%d,'%s')",
-                               intval($message_id),
-                               dbesc(json_encode($data))
-                       );
+                       dba::insert('sign', array('iid' => $message_id, 'signed_text' => json_encode($data)));
 
                        // notify others
                        proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id);
@@ -1560,10 +1555,7 @@ class Diaspora {
 
                dba::unlock();
 
-               q("UPDATE `conv` SET `updated` = '%s' WHERE `id` = %d",
-                       dbesc(datetime_convert()),
-                       intval($conversation["id"])
-               );
+               dba::update('conv', array('updated' => datetime_convert()), array('id' => $conversation["id"]));
 
                notification(array(
                        "type" => NOTIFY_MAIL,
@@ -1783,10 +1775,7 @@ class Diaspora {
 
                        // Formerly we stored the signed text, the signature and the author in different fields.
                        // We now store the raw data so that we are more flexible.
-                       q("INSERT INTO `sign` (`iid`,`signed_text`) VALUES (%d,'%s')",
-                               intval($message_id),
-                               dbesc(json_encode($data))
-                       );
+                       dba::insert('sign', array('iid' => $message_id, 'signed_text' => json_encode($data)));
 
                        // notify others
                        proc_run(PRIORITY_HIGH, "include/notifier.php", "comment-import", $message_id);
@@ -1871,11 +1860,7 @@ class Diaspora {
 
                dba::unlock();
 
-               q("UPDATE `conv` SET `updated` = '%s' WHERE `id` = %d",
-                       dbesc(datetime_convert()),
-                       intval($conversation["id"])
-               );
-
+               dba::update('conv', array('updated' => datetime_convert()), array('id' => $conversation["id"]));
                return true;
        }
 
@@ -2019,11 +2004,8 @@ class Diaspora {
                $a = get_app();
 
                if ($contact["rel"] == CONTACT_IS_FOLLOWER && in_array($importer["page-flags"], array(PAGE_FREELOVE))) {
-                       q("UPDATE `contact` SET `rel` = %d, `writable` = 1 WHERE `id` = %d AND `uid` = %d",
-                               intval(CONTACT_IS_FRIEND),
-                               intval($contact["id"]),
-                               intval($importer["uid"])
-                       );
+                       dba::update('contact', array('rel' => CONTACT_IS_FRIEND, 'writable' => true),
+                                       array('id' => $contact["id"], 'uid' => $importer["uid"]));
                }
                // send notification
 
@@ -2474,11 +2456,10 @@ class Diaspora {
                }
 
                // Currently we don't have a central deletion function that we could use in this case. The function "item_drop" doesn't work for that case
-               q("UPDATE `item` SET `deleted` = 1, `edited` = '%s', `changed` = '%s', `body` = '' , `title` = '' WHERE `id` = %d",
-                       dbesc(datetime_convert()),
-                       dbesc(datetime_convert()),
-                       intval($r[0]["id"])
-               );
+               dba::update('item', array('deleted' => true, 'title' => '', 'body' => '',
+                                       'edited' => datetime_convert(), 'changed' => datetime_convert()),
+                               array('id' => $r[0]["id"]));
+
                delete_thread($r[0]["id"], $r[0]["parent-uri"]);
 
                logger("Deleted target ".$target_guid." (".$r[0]["id"].") from user ".$importer["uid"]." parent: ".$p[0]["id"], LOGGER_DEBUG);
@@ -3728,10 +3709,7 @@ class Diaspora {
                 * Now store the signature more flexible to dynamically support new fields.
                 * This will break Diaspora compatibility with Friendica versions prior to 3.5.
                 */
-               q("INSERT INTO `sign` (`iid`,`signed_text`) VALUES (%d,'%s')",
-                       intval($message_id),
-                       dbesc(json_encode($message))
-               );
+               dba::insert('sign', array('iid' => $post_id, 'signed_text' => json_encode($message)));
 
                logger('Stored diaspora like signature');
                return true;
@@ -3763,10 +3741,7 @@ class Diaspora {
                 * Now store the signature more flexible to dynamically support new fields.
                 * This will break Diaspora compatibility with Friendica versions prior to 3.5.
                 */
-               q("INSERT INTO `sign` (`iid`, `signed_text`) VALUES (%d, '%s')",
-                       intval($message_id),
-                       dbesc(json_encode($message))
-               );
+               dba::insert('sign', array('iid' => $message_id, 'signed_text' => json_encode($message)));
 
                logger('Stored diaspora comment signature');
                return true;