X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=pumpio%2Fpumpio.php;h=f5bf6496a01321992741988dccb2da64fdf8ac7f;hb=58495893b950574fddd06b94ee35503eb9ad2e34;hp=a59d761981c1873ff5bd04b21165086feddc313d;hpb=9c618c80af24108c1564b9f8bc198cfc6a1d6634;p=friendica-addons.git diff --git a/pumpio/pumpio.php b/pumpio/pumpio.php index a59d7619..f5bf6496 100644 --- a/pumpio/pumpio.php +++ b/pumpio/pumpio.php @@ -5,16 +5,17 @@ * Version: 0.2 * Author: Michael Vogel */ - use Friendica\Core\Config; use Friendica\Core\PConfig; use Friendica\Core\Worker; +use Friendica\Model\Contact; use Friendica\Model\GContact; +use Friendica\Model\Group; +use Friendica\Model\User; require 'addon/pumpio/oauth/http.php'; require 'addon/pumpio/oauth/oauth_client.php'; require_once 'include/enotify.php'; -require_once "include/Photo.php"; require_once "mod/share.php"; define('PUMPIO_DEFAULT_POLL_INTERVAL', 5); // given in minutes @@ -414,6 +415,13 @@ function pumpio_send(&$a,&$b) { if (!count($receiver) && ($b['private'] || !strstr($b['postopts'],'pumpio'))) return; + + // Dont't post if the post doesn't belong to us. + // This is a check for forum postings + $self = dba::select('contact', array('id'), array('uid' => $b['uid'], 'self' => true), array('limit' => 1)); + if ($b['contact-id'] != $self['id']) { + return; + } } if($b['verb'] == ACTIVITY_LIKE) { @@ -972,7 +980,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false) { "photo" => $contact->image->url, "name" => $contact->displayName, "hide" => true, "nick" => $contact->preferredUsername, "location" => $contact->location->displayName, "about" => $contact->summary, "addr" => str_replace("acct:", "", $contact->id))); - $cid = get_contact($contact->url, $uid); + $cid = Contact::getIdForURL($contact->url, $uid); if ($no_insert) return($cid); @@ -1016,14 +1024,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false) { $contact_id = $r[0]['id']; - $g = q("select def_gid from user where uid = %d limit 1", - intval($uid) - ); - - if($g && intval($g[0]['def_gid'])) { - require_once('include/group.php'); - group_add_member($uid,'',$contact_id,$g[0]['def_gid']); - } + Group::addMember(User::getDefaultGroup($uid), $contact_id); } else { $contact_id = $r[0]["id"]; @@ -1038,8 +1039,7 @@ function pumpio_get_contact($uid, $contact, $no_insert = false) { */ } - if (function_exists("update_contact_avatar")) - update_contact_avatar($contact->image->url, $uid, $contact_id); + Contact::updateAvatar($contact->image->url, $uid, $contact_id); return($contact_id); } @@ -1544,10 +1544,9 @@ function pumpio_getreceiver(&$a, $b) { $gid = trim($gid, " <>"); $r = q("SELECT `contact`.`name`, `contact`.`nick`, `contact`.`url`, `contact`.`network` ". - "FROM `group_member`, `contact` WHERE `group_member`.`gid` = %d AND `group_member`.`uid` = %d ". + "FROM `group_member`, `contact` WHERE `group_member`.`gid` = %d ". "AND `contact`.`id` = `group_member`.`contact-id` AND `contact`.`network` = '%s'", intval($gid), - intval($b["uid"]), dbesc(NETWORK_PUMPIO) );