if ($application_name == "")
$application_name = $a->get_hostname();
+ $adminlist = explode(",", str_replace(" ", "", $a->config['admin_email']));
+
$params["type"] = "client_associate";
- $params["contacts"] = $a->config['admin_email'];
+ $params["contacts"] = $adminlist[0];
$params["application_type"] = "native";
$params["application_name"] = $application_name;
$params["logo_url"] = $a->get_baseurl()."/images/friendica-256.png";
set_pconfig(local_user(),'pumpio','mirror',false);
set_pconfig(local_user(),'pumpio','post_by_default',false);
set_pconfig(local_user(),'pumpio','lastdate', 0);
+ set_pconfig(local_user(),'pumpio','last_id', '');
} else {
// filtering the username if it is filled wrong
$user = $_POST['pumpio_user'];
$title = trim($b['title']);
- //if ($title != '')
- // $title = "<h4>".$title."</h4>";
-
$content = bbcode($b['body'], false, false, 4);
// Enhance the way, videos are displayed
$success = $client->CallAPI($url, 'POST', $params, array('FailOnAccessError'=>true, 'RequestContentType'=>'application/json'), $user);
if($success) {
+
+ if ($user->generator->displayName)
+ set_pconfig($b["uid"], "pumpio", "application_name", $user->generator->displayName);
+
$post_id = $user->object->id;
logger('pumpio_send '.$username.': success '.$post_id);
if($post_id AND $iscomment) {
}
}
-
-function pumpio_cron(&$a,$b) {
+function pumpio_sync(&$a) {
$last = get_config('pumpio','last_poll');
$poll_interval = intval(get_config('pumpio','poll_interval'));
}
}
+ $abandon_days = intval(get_config('system','account_abandon_days'));
+ if ($abandon_days < 1)
+ $abandon_days = 0;
+
+ $abandon_limit = date("Y-m-d H:i:s", time() - $abandon_days * 86400);
+
$r = q("SELECT * FROM `pconfig` WHERE `cat` = 'pumpio' AND `k` = 'import' AND `v` = '1' ORDER BY RAND() ");
if(count($r)) {
foreach($r as $rr) {
+ if ($abandon_days != 0) {
+ $user = q("SELECT `login_date` FROM `user` WHERE uid=%d AND `login_date` >= '%s'", $rr['uid'], $abandon_limit);
+ if (!count($user)) {
+ logger('abandoned account: timeline from user '.$rr['uid'].' will not be imported');
+ continue;
+ }
+ }
+
logger('pumpio: importing timeline from user '.$rr['uid']);
pumpio_fetchinbox($a, $rr['uid']);
set_config('pumpio','last_poll', time());
}
+function pumpio_cron(&$a,$b) {
+ //pumpio_sync($a);
+ proc_run("php","addon/pumpio/pumpio_sync.php");
+}
+
function pumpio_fetchtimeline(&$a, $uid) {
$ckey = get_pconfig($uid, 'pumpio', 'consumer_key');
$csecret = get_pconfig($uid, 'pumpio', 'consumer_secret');
$hostname = get_pconfig($uid, 'pumpio','host');
$username = get_pconfig($uid, "pumpio", "user");
- $application_name = get_config('pumpio', 'application_name');
-
+ // get the application name for the pump.io app
+ // 1st try personal config, then system config and fallback to the
+ // hostname of the node if neither one is set.
+ $application_name = get_pconfig( $uid, 'pumpio', 'application_name');
+ if ($application_name == "")
+ $application_name = get_config('pumpio', 'application_name');
if ($application_name == "")
$application_name = $a->get_hostname();
if ($receiver->id == "http://activityschema.org/collection/public")
$public = true;
- if ($public AND !strstr($post->generator->displayName, $application_name)) {
+ if ($public AND !stristr($post->generator->displayName, $application_name)) {
require_once('include/html2bbcode.php');
$_SESSION["authenticated"] = true;
dbesc($contact->image->url),
dbesc(normalise_link($contact->url)));
+ if (DB_UPDATE_VERSION >= "1177")
+ q("UPDATE `unique_contacts` SET `location` = '%s', `about` = '%s' WHERE url = '%s'",
+ dbesc($contact->location->displayName),
+ dbesc($contact->summary),
+ dbesc(normalise_link($contact->url)));
+
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' LIMIT 1",
intval($uid), dbesc($contact->url));
dbesc(datetime_convert()),
intval($contact_id)
);
+
+ if (DB_UPDATE_VERSION >= "1177")
+ q("UPDATE `contact` SET `location` = '%s',
+ `about` = '%s'
+ WHERE `id` = %d",
+ dbesc($contact->location->displayName),
+ dbesc($contact->summary),
+ intval($contact_id)
+ );
} else {
// update profile photos once every two weeks as we have no notification of when they change.
-
- $update_photo = (($r[0]['avatar-date'] < datetime_convert('','','now -14 days')) ? true : false);
+ //$update_photo = (($r[0]['avatar-date'] < datetime_convert('','','now -14 days')) ? true : false);
+ $update_photo = ($r[0]['avatar-date'] < datetime_convert('','','now -12 hours'));
// check that we have all the photos, this has been known to fail on occasion
dbesc($contact->preferredUsername),
intval($r[0]['id'])
);
+
+ if (DB_UPDATE_VERSION >= "1177")
+ q("UPDATE `contact` SET `location` = '%s',
+ `about` = '%s'
+ WHERE `id` = %d",
+ dbesc($contact->location->displayName),
+ dbesc($contact->summary),
+ intval($r[0]['id'])
+ );
}
}
$public = true;
$postarray = array();
+ $postarray['network'] = NETWORK_PUMPIO;
$postarray['gravity'] = 0;
$postarray['uid'] = $uid;
$postarray['wall'] = 0;
$postarray['body'] = "[share author='".$post->object->author->displayName.
"' profile='".$post->object->author->url.
"' avatar='".$post->object->author->image->url.
+ "' posted='".datetime_convert('UTC','UTC',$post->object->created).
"' link='".$post->links->self->href."']".$postarray['body']."[/share]";
} else {
// Let shares look like wall-to-wall posts
return false;
$top_item = item_store($postarray);
+ $postarray["id"] = $top_item;
if (($top_item == 0) AND ($post->verb == "update")) {
$r = q("UPDATE `item` SET `title` = '%s', `body` = '%s' , `changed` = '%s' WHERE `uri` = '%s' AND `uid` = %d",