]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/FacebookBridge/lib/facebookclient.php
TwitterBridge messing about, Twitter OAuth requires Authorization header now?
[quix0rs-gnu-social.git] / plugins / FacebookBridge / lib / facebookclient.php
index 00b313b6a4d9320d1c4891300a0fe08430c7eec7..e55e19d88be8c960eb369ce1ad5bb00eba097b36 100644 (file)
@@ -176,7 +176,8 @@ class Facebookclient
 
         // If it's not a reply, or if the user WANTS to send @-replies,
         // then, yeah, it can go to Facebook.
-        if (!preg_match('/@[a-zA-Z0-9_]{1,15}\b/u', $this->notice->content) ||
+
+        if (empty($this->notice->reply_to) ||
             ($this->flink->noticesync & FOREIGN_NOTICE_SEND_REPLY)) {
             return true;
         }
@@ -627,7 +628,7 @@ class Facebookclient
 
         // Facebook has a 420-char hardcoded max.
         if (mb_strlen($statustxt) > 420) {
-            $noticeUrl = common_shorten_url($this->notice->uri);
+            $noticeUrl = common_shorten_url($this->notice->getUrl());
             $urlLen = mb_strlen($noticeUrl);
             $txt = mb_substr($statustxt, 0, 420 - ($urlLen + 3)) . ' … ' . $noticeUrl;
         }
@@ -650,9 +651,10 @@ class Facebookclient
 
         foreach($attachments as $attachment)
         {
-            if($enclosure = $attachment->getEnclosure()){
+            try {
+                $enclosure = $attachment->getEnclosure();
                 $fbmedia = $this->getFacebookMedia($enclosure);
-            }else{
+            } catch (ServerException $e) {
                 $fbmedia = $this->getFacebookMedia($attachment);
             }
             if($fbmedia){
@@ -896,7 +898,7 @@ class Facebookclient
      */
     static function facebookStatusId($notice)
     {
-        $n2i = Notice_to_item::staticGet('notice_id', $notice->id);
+        $n2i = Notice_to_item::getKV('notice_id', $notice->id);
 
         if (empty($n2i)) {
             return null;
@@ -916,12 +918,9 @@ class Facebookclient
     static function addFacebookUser($fbuser)
     {
         // remove any existing, possibly outdated, record
-        $luser = Foreign_user::getForeignUser($fbuser->id, FACEBOOK_SERVICE);
-
-        if (!empty($luser)) {
-
-            $result = $luser->delete();
-
+        try {
+            $fuser = Foreign_user::getForeignUser($fbuser->id, FACEBOOK_SERVICE);
+            $result = $fuser->delete();
             if ($result != false) {
                 common_log(
                     LOG_INFO,
@@ -933,6 +932,8 @@ class Facebookclient
                     __FILE__
                 );
             }
+        } catch (NoResultException $e) {
+            // no old foreign users exist for this id
         }
 
         $fuser = new Foreign_user();
@@ -978,7 +979,7 @@ class Facebookclient
      */
     function streamRemove()
     {
-        $n2i = Notice_to_item::staticGet('notice_id', $this->notice->id);
+        $n2i = Notice_to_item::getKV('notice_id', $this->notice->id);
 
         if (!empty($this->flink) && !empty($n2i)) {
             try {
@@ -1033,7 +1034,7 @@ class Facebookclient
      */
     function like()
     {
-        $n2i = Notice_to_item::staticGet('notice_id', $this->notice->id);
+        $n2i = Notice_to_item::getKV('notice_id', $this->notice->id);
 
         if (!empty($this->flink) && !empty($n2i)) {
             try {
@@ -1084,7 +1085,7 @@ class Facebookclient
      */
     function unLike()
     {
-        $n2i = Notice_to_item::staticGet('notice_id', $this->notice->id);
+        $n2i = Notice_to_item::getKV('notice_id', $this->notice->id);
 
         if (!empty($this->flink) && !empty($n2i)) {
             try {