From: Brion Vibber Date: Thu, 31 Mar 2011 00:01:06 +0000 (-0700) Subject: Provisional fix for ticket #3108: Facebook bridge sends "likes" as the notice's origi... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=347b57f72a705a0a1572de6b4ed43bddb1c3793b;p=quix0rs-gnu-social.git Provisional fix for ticket #3108: Facebook bridge sends "likes" as the notice's original poster instead of as the person doing the liking. Adds optional $profile parameter for Facebookclient constructor and uses that for the foreign_link lookup if provided instead of the notice's poster. --- diff --git a/plugins/FacebookBridge/FacebookBridgePlugin.php b/plugins/FacebookBridge/FacebookBridgePlugin.php index 37b931e23e..5d2442d579 100644 --- a/plugins/FacebookBridge/FacebookBridgePlugin.php +++ b/plugins/FacebookBridge/FacebookBridgePlugin.php @@ -526,7 +526,7 @@ ENDOFSCRIPT; */ function onEndFavorNotice(Profile $profile, Notice $notice) { - $client = new Facebookclient($notice); + $client = new Facebookclient($notice, $profile); $client->like(); return true; @@ -542,7 +542,7 @@ ENDOFSCRIPT; */ function onEndDisfavorNotice(Profile $profile, Notice $notice) { - $client = new Facebookclient($notice); + $client = new Facebookclient($notice, $profile); $client->unLike(); return true; diff --git a/plugins/FacebookBridge/lib/facebookclient.php b/plugins/FacebookBridge/lib/facebookclient.php index 516f252d98..37d6a0a7a0 100644 --- a/plugins/FacebookBridge/lib/facebookclient.php +++ b/plugins/FacebookBridge/lib/facebookclient.php @@ -48,7 +48,12 @@ class Facebookclient protected $notice = null; // The user's notice protected $user = null; // Sender of the notice - function __construct($notice) + /** + * + * @param Notice $notice the notice to manipulate + * @param Profile $profile local user to act as; if left empty, the notice's poster will be used. + */ + function __construct($notice, $profile=null) { $this->facebook = self::getFacebook(); @@ -60,8 +65,9 @@ class Facebookclient $this->notice = $notice; + $profile_id = $profile ? $profile->id : $notice->profile_id; $this->flink = Foreign_link::getByUserID( - $notice->profile_id, + $profile_id, FACEBOOK_SERVICE );