summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-10-02 15:27:55 -0400
committerEvan Prodromou <evan@status.net>2009-10-02 15:27:55 -0400
commitb3b3af9a2eff10c272bb213eccd3dd3060bc5830 (patch)
treeff0ae9108bcb085015a8e9f286963ad9fe58c13c /scripts
parent51ac34e80c5a99008b1a945b2c00b6dbfdde1529 (diff)
parent5309910b9b4dd2533ff5b2190f90bf415fd20113 (diff)
Merge branch '0.8.x' into deleteuser
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/allsites.php4
-rw-r--r--scripts/commandline.inc6
-rw-r--r--scripts/createsim.php142
-rw-r--r--scripts/decache.php4
-rwxr-xr-xscripts/delete_status_network.sh2
-rwxr-xr-xscripts/enjitqueuehandler.php4
-rwxr-xr-xscripts/facebookqueuehandler.php4
-rwxr-xr-xscripts/fixup_conversations.php4
-rwxr-xr-xscripts/fixup_hashtags.php7
-rwxr-xr-xscripts/fixup_inboxes.php7
-rwxr-xr-xscripts/fixup_notices_rendered.php7
-rwxr-xr-xscripts/fixup_replies.php7
-rwxr-xr-x[-rw-r--r--]scripts/fixup_utf8.php8
-rwxr-xr-xscripts/getpiddir.php4
-rwxr-xr-xscripts/getvaliddaemons.php13
-rwxr-xr-xscripts/inbox_users.php4
-rwxr-xr-xscripts/jabberqueuehandler.php4
-rwxr-xr-xscripts/maildaemon.php13
-rwxr-xr-xscripts/ombqueuehandler.php4
-rw-r--r--scripts/pingqueuehandler.php4
-rwxr-xr-xscripts/publicqueuehandler.php4
-rwxr-xr-xscripts/rebuilddb_psql.sh6
-rw-r--r--scripts/reportsnapshot.php4
-rw-r--r--scripts/sessiongc.php36
-rwxr-xr-xscripts/setpassword.php4
-rwxr-xr-xscripts/setup_status_network.sh4
-rw-r--r--scripts/showcache.php4
-rwxr-xr-xscripts/sitemap.php4
-rwxr-xr-xscripts/smsqueuehandler.php4
-rwxr-xr-xscripts/sphinx-cron.sh6
-rwxr-xr-xscripts/sphinx-indexer.sh6
-rwxr-xr-xscripts/startdaemons.sh6
-rw-r--r--scripts/statusnet.spec (renamed from scripts/laconica.spec)36
-rwxr-xr-xscripts/stopdaemons.sh8
-rwxr-xr-xscripts/synctwitterfriends.php286
-rw-r--r--scripts/triminboxes.php4
-rwxr-xr-xscripts/twitterqueuehandler.php4
-rwxr-xr-xscripts/twitterstatusfetcher.php339
-rw-r--r--scripts/uncache_users.php4
-rwxr-xr-xscripts/update_pot.sh2
-rwxr-xr-xscripts/update_translations.php21
-rwxr-xr-xscripts/xmppconfirmhandler.php4
-rwxr-xr-xscripts/xmppdaemon.php4
43 files changed, 665 insertions, 387 deletions
diff --git a/scripts/allsites.php b/scripts/allsites.php
index d6768c278..cf1419e55 100755
--- a/scripts/allsites.php
+++ b/scripts/allsites.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/commandline.inc b/scripts/commandline.inc
index 3b6ef6098..1573b569d 100644
--- a/scripts/commandline.inc
+++ b/scripts/commandline.inc
@@ -1,7 +1,7 @@
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - a distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -26,7 +26,7 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
exit();
}
-define('LACONICA', true);
+define('STATUSNET', true);
// Set various flags so we don't time out on long-running processes
diff --git a/scripts/createsim.php b/scripts/createsim.php
new file mode 100644
index 000000000..71ed3bf72
--- /dev/null
+++ b/scripts/createsim.php
@@ -0,0 +1,142 @@
+#!/usr/bin/env php
+<?php
+/*
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+
+$shortoptions = 'u:n:b:t:x:';
+$longoptions = array('users=', 'notices=', 'subscriptions=', 'tags=', 'prefix=');
+
+$helptext = <<<END_OF_CREATESIM_HELP
+Creates a lot of test users and notices to (loosely) simulate a real server.
+
+ -u --users Number of users (default 100)
+ -n --notices Average notices per user (default 100)
+ -b --subscriptions Average subscriptions per user (default no. users/20)
+ -t --tags Number of distinct hash tags (default 10000)
+ -x --prefix User name prefix (default 'testuser')
+
+END_OF_CREATESIM_HELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+
+// XXX: make these command-line options
+
+function newUser($i)
+{
+ global $userprefix;
+ User::register(array('nickname' => sprintf('%s%d', $userprefix, $i),
+ 'password' => sprintf('password%d', $i),
+ 'fullname' => sprintf('Test User %d', $i)));
+}
+
+function newNotice($i, $tagmax)
+{
+ global $userprefix;
+
+ $n = rand(0, $i - 1);
+ $user = User::staticGet('nickname', sprintf('%s%d', $userprefix, $n));
+
+ $is_reply = rand(0, 4);
+
+ $content = 'Test notice content';
+
+ if ($is_reply == 0) {
+ $n = rand(0, $i - 1);
+ $content = "@$userprefix$n " . $content;
+ }
+
+ $has_hash = rand(0, 2);
+
+ if ($has_hash == 0) {
+ $hashcount = rand(0, 2);
+ for ($j = 0; $j < $hashcount; $j++) {
+ $h = rand(0, $tagmax);
+ $content .= " #tag{$h}";
+ }
+ }
+
+ $notice = Notice::saveNew($user->id, $content, 'system');
+}
+
+function newSub($i)
+{
+ global $userprefix;
+ $f = rand(0, $i - 1);
+
+ $fromnick = sprintf('%s%d', $userprefix, $f);
+
+ $from = User::staticGet('nickname', $fromnick);
+
+ if (empty($from)) {
+ throw new Exception("Can't find user '$fromnick'.");
+ }
+
+ $t = rand(0, $i - 1);
+
+ if ($t == $f) {
+ $t++;
+ if ($t > $i - 1) {
+ $t = 0;
+ }
+ }
+
+ $tunic = sprintf('%s%d', $userprefix, $t);
+
+ $to = User::staticGet('nickname', $tunic);
+
+ if (empty($from)) {
+ throw new Exception("Can't find user '$tunic'.");
+ }
+
+ subs_subscribe_to($from, $to);
+}
+
+function main($usercount, $noticeavg, $subsavg, $tagmax)
+{
+ $n = 1;
+
+ newUser(0);
+
+ // # registrations + # notices + # subs
+
+ $events = $usercount + ($usercount * ($noticeavg + $subsavg));
+
+ for ($i = 0; $i < $events; $i++)
+ {
+ $e = rand(0, 1 + $noticeavg + $subsavg);
+
+ if ($e == 0) {
+ newUser($n);
+ $n++;
+ } else if ($e < $noticeavg + 1) {
+ newNotice($n, $tagmax);
+ } else {
+ newSub($n);
+ }
+ }
+}
+
+$usercount = (have_option('u', 'users')) ? get_option_value('u', 'users') : 100;
+$noticeavg = (have_option('n', 'notices')) ? get_option_value('n', 'notices') : 100;
+$subsavg = (have_option('b', 'subscriptions')) ? get_option_value('b', 'subscriptions') : max($usercount/20, 10);
+$tagmax = (have_option('t', 'tags')) ? get_option_value('t', 'tags') : 10000;
+$userprefix = (have_option('x', 'prefix')) ? get_option_value('x', 'prefix') : 'testuser';
+
+main($usercount, $noticeavg, $subsavg, $tagmax);
diff --git a/scripts/decache.php b/scripts/decache.php
index 90e1ec63c..7cabd78ad 100644
--- a/scripts/decache.php
+++ b/scripts/decache.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/delete_status_network.sh b/scripts/delete_status_network.sh
index 32187382c..f55f1486b 100755
--- a/scripts/delete_status_network.sh
+++ b/scripts/delete_status_network.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-source /etc/laconica/setup.cfg
+source /etc/statusnet/setup.cfg
export nickname=$1
diff --git a/scripts/enjitqueuehandler.php b/scripts/enjitqueuehandler.php
index 05e1d9366..08f733b07 100755
--- a/scripts/enjitqueuehandler.php
+++ b/scripts/enjitqueuehandler.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/facebookqueuehandler.php b/scripts/facebookqueuehandler.php
index 05a35577f..e13ac4e85 100755
--- a/scripts/facebookqueuehandler.php
+++ b/scripts/facebookqueuehandler.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/fixup_conversations.php b/scripts/fixup_conversations.php
index 0be0b4bac..8a9f7bb57 100755
--- a/scripts/fixup_conversations.php
+++ b/scripts/fixup_conversations.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/fixup_hashtags.php b/scripts/fixup_hashtags.php
index bd38e3105..5cfebd8ee 100755
--- a/scripts/fixup_hashtags.php
+++ b/scripts/fixup_hashtags.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -25,7 +25,8 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
}
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
+define('STATUSNET', true);
+define('LACONICA', true); // compatibility
require_once(INSTALLDIR . '/lib/common.php');
diff --git a/scripts/fixup_inboxes.php b/scripts/fixup_inboxes.php
index 3e55edef1..d55a53885 100755
--- a/scripts/fixup_inboxes.php
+++ b/scripts/fixup_inboxes.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -30,7 +30,8 @@ set_time_limit(0);
mb_internal_encoding('UTF-8');
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
+define('STATUSNET', true);
+define('LACONICA', true); // compatibility
require_once(INSTALLDIR . '/lib/common.php');
diff --git a/scripts/fixup_notices_rendered.php b/scripts/fixup_notices_rendered.php
index 3e7eb7acb..359cd6cce 100755
--- a/scripts/fixup_notices_rendered.php
+++ b/scripts/fixup_notices_rendered.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -25,7 +25,8 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
}
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
+define('STATUSNET', true);
+define('LACONICA', true); // compatibility
require_once(INSTALLDIR . '/lib/common.php');
diff --git a/scripts/fixup_replies.php b/scripts/fixup_replies.php
index 9d8cfda08..7328635d3 100755
--- a/scripts/fixup_replies.php
+++ b/scripts/fixup_replies.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -25,7 +25,8 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
}
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
+define('STATUSNET', true);
+define('LACONICA', true); // compatibility
require_once(INSTALLDIR . '/lib/common.php');
diff --git a/scripts/fixup_utf8.php b/scripts/fixup_utf8.php
index 8c9a9127f..5a9fba7c3 100644..100755
--- a/scripts/fixup_utf8.php
+++ b/scripts/fixup_utf8.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -25,7 +25,7 @@ define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
$helptext = <<<ENDOFHELP
fixup_utf8.php <maxdate> <maxid> <minid>
-Fixup records in a database that stored the data incorrectly (pre-0.7.4 for Laconica).
+Fixup records in a database that stored the data incorrectly (pre-0.7.4 for StatusNet).
ENDOFHELP;
@@ -42,7 +42,7 @@ class UTF8FixerUpper
{
$this->args = $args;
- if (array_key_exists('max_date', $args)) {
+ if (!empty($args['max_date'])) {
$this->max_date = strftime('%Y-%m-%d %H:%M:%S', strtotime($args['max_date']));
} else {
$this->max_date = strftime('%Y-%m-%d %H:%M:%S', time());
diff --git a/scripts/getpiddir.php b/scripts/getpiddir.php
index 9927cc6d9..8274c37c0 100755
--- a/scripts/getpiddir.php
+++ b/scripts/getpiddir.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/getvaliddaemons.php b/scripts/getvaliddaemons.php
index 1e4546dff..8f48e8e6f 100755
--- a/scripts/getvaliddaemons.php
+++ b/scripts/getvaliddaemons.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -43,7 +43,12 @@ if(common_config('twitterbridge','enabled')) {
echo "twitterstatusfetcher.php ";
}
echo "ombqueuehandler.php ";
-echo "twitterqueuehandler.php ";
+if (common_config('twitter', 'enabled')) {
+ echo "twitterqueuehandler.php ";
+ echo "synctwitterfriends.php ";
+}
echo "facebookqueuehandler.php ";
echo "pingqueuehandler.php ";
-echo "smsqueuehandler.php ";
+if (common_config('sms', 'enabled')) {
+ echo "smsqueuehandler.php ";
+}
diff --git a/scripts/inbox_users.php b/scripts/inbox_users.php
index 4883fea20..32adcea21 100755
--- a/scripts/inbox_users.php
+++ b/scripts/inbox_users.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/jabberqueuehandler.php b/scripts/jabberqueuehandler.php
index 5b581629d..8f3a56944 100755
--- a/scripts/jabberqueuehandler.php
+++ b/scripts/jabberqueuehandler.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/maildaemon.php b/scripts/maildaemon.php
index a4003b6b2..11911dcbd 100755
--- a/scripts/maildaemon.php
+++ b/scripts/maildaemon.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -317,6 +317,9 @@ class MailerDaemon
} else if ($parsed->ctype_primary == 'text'
&& $parsed->ctype_secondary=='plain') {
$msg = $parsed->body;
+ if(strtolower($parsed->ctype_parameters['charset']) != "utf-8"){
+ $msg = utf8_encode($msg);
+ }
}else if(!empty($parsed->body)){
if(common_config('attachments', 'uploads')){
//only save attachments if uploads are enabled
@@ -382,5 +385,7 @@ class MailerDaemon
}
}
-$md = new MailerDaemon();
-$md->handle_message('php://stdin');
+if (common_config('emailpost', 'enabled')) {
+ $md = new MailerDaemon();
+ $md->handle_message('php://stdin');
+}
diff --git a/scripts/ombqueuehandler.php b/scripts/ombqueuehandler.php
index 1587192b6..8e685f1c8 100755
--- a/scripts/ombqueuehandler.php
+++ b/scripts/ombqueuehandler.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/pingqueuehandler.php b/scripts/pingqueuehandler.php
index 23678ea4b..c92337e36 100644
--- a/scripts/pingqueuehandler.php
+++ b/scripts/pingqueuehandler.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/publicqueuehandler.php b/scripts/publicqueuehandler.php
index 701d50e01..50a11bcba 100755
--- a/scripts/publicqueuehandler.php
+++ b/scripts/publicqueuehandler.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/rebuilddb_psql.sh b/scripts/rebuilddb_psql.sh
index ac169c205..6b15b9212 100755
--- a/scripts/rebuilddb_psql.sh
+++ b/scripts/rebuilddb_psql.sh
@@ -5,7 +5,7 @@
# below, AND backed up your database. Failure to observe these instructions
# may result in losing all the data in your database.
#
-# This script is used to upgrade Laconica's PostgreSQL database to the
+# This script is used to upgrade StatusNet's PostgreSQL database to the
# latest version. It does the following:
#
# 1. Dumps the existing data to /tmp/rebuilddb_psql.sql
@@ -15,7 +15,7 @@
#
# You MUST run this script as the 'postgres' user.
# You MUST be able to write to /tmp/rebuilddb_psql.sql
-# You MUST specify the laconica database user and database name on the
+# You MUST specify the statusnet database user and database name on the
# command line, e.g. ./rebuilddb_psql.sh myuser mydbname
#
@@ -27,7 +27,7 @@ cd `dirname $0`
pg_dump -a -D --disable-trigger $DB > /tmp/rebuilddb_psql.sql
psql -c "drop schema public cascade; create schema public;" $DB
psql -c "grant all privileges on schema public to $user;" $DB
-psql $DB < ../db/laconica_pg.sql
+psql $DB < ../db/statusnet_pg.sql
psql $DB < /tmp/rebuilddb_psql.sql
for tab in `psql -c '\dts' $DB -tA | cut -d\| -f2`; do
psql -c "ALTER TABLE \"$tab\" OWNER TO $user;" $DB
diff --git a/scripts/reportsnapshot.php b/scripts/reportsnapshot.php
index c644b557f..71f1019ee 100644
--- a/scripts/reportsnapshot.php
+++ b/scripts/reportsnapshot.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/sessiongc.php b/scripts/sessiongc.php
new file mode 100644
index 000000000..af55ddf3f
--- /dev/null
+++ b/scripts/sessiongc.php
@@ -0,0 +1,36 @@
+#!/usr/bin/env php
+<?php
+/*
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
+
+$helptext = <<<END_OF_GC_HELP
+sessiongc.php
+
+Delete old sessions from the server
+
+END_OF_GC_HELP;
+
+require_once INSTALLDIR.'/scripts/commandline.inc';
+
+$maxlifetime = ini_get('session.gc_maxlifetime');
+
+print "Deleting sessions older than $maxlifetime seconds.\n";
+
+Session::gc($maxlifetime);
diff --git a/scripts/setpassword.php b/scripts/setpassword.php
index b70689f03..50d49d7db 100755
--- a/scripts/setpassword.php
+++ b/scripts/setpassword.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/setup_status_network.sh b/scripts/setup_status_network.sh
index 17440640e..d40d4724f 100755
--- a/scripts/setup_status_network.sh
+++ b/scripts/setup_status_network.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-source /etc/laconica/setup.cfg
+source /etc/statusnet/setup.cfg
export nickname=$1
export sitename=$2
@@ -13,7 +13,7 @@ export username=$nickname$USERBASE
mysqladmin -h $DBHOST -u $ADMIN --password=$ADMINPASS create $database
-for f in laconica.sql innodb.sql sms_carrier.sql foreign_services.sql notice_source.sql; do
+for f in statusnet.sql innodb.sql sms_carrier.sql foreign_services.sql notice_source.sql; do
mysql -h $DBHOST -u $ADMIN --password=$ADMINPASS $database < ../db/$f;
done
diff --git a/scripts/showcache.php b/scripts/showcache.php
index 7a88fdbbb..f17979572 100644
--- a/scripts/showcache.php
+++ b/scripts/showcache.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/sitemap.php b/scripts/sitemap.php
index 88ca2ba7a..f8c392146 100755
--- a/scripts/sitemap.php
+++ b/scripts/sitemap.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/smsqueuehandler.php b/scripts/smsqueuehandler.php
index 94b846d98..6583a77da 100755
--- a/scripts/smsqueuehandler.php
+++ b/scripts/smsqueuehandler.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/sphinx-cron.sh b/scripts/sphinx-cron.sh
index c16af3c4b..bc537af1a 100755
--- a/scripts/sphinx-cron.sh
+++ b/scripts/sphinx-cron.sh
@@ -1,8 +1,8 @@
#!/bin/sh
-# Laconica - a distributed open-source microblogging tool
+# StatusNet - a distributed open-source microblogging tool
-# Copyright (C) 2008, 2009, Control Yourself, Inc.
+# Copyright (C) 2008, 2009, StatusNet, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# This program tries to start the daemons for Laconica.
+# This program tries to start the daemons for StatusNet.
# Note that the 'maildaemon' needs to run as a mail filter.
/usr/local/bin/indexer --config /usr/local/etc/sphinx.conf --all --rotate
diff --git a/scripts/sphinx-indexer.sh b/scripts/sphinx-indexer.sh
index fe7c16bea..1ec0826be 100755
--- a/scripts/sphinx-indexer.sh
+++ b/scripts/sphinx-indexer.sh
@@ -1,8 +1,8 @@
#!/bin/sh
-# Laconica - a distributed open-source microblogging tool
+# StatusNet - a distributed open-source microblogging tool
-# Copyright (C) 2008, 2009, Control Yourself, Inc.
+# Copyright (C) 2008, 2009, StatusNet, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# This program tries to start the daemons for Laconica.
+# This program tries to start the daemons for StatusNet.
# Note that the 'maildaemon' needs to run as a mail filter.
/usr/local/bin/indexer --config /usr/local/etc/sphinx.conf --all
diff --git a/scripts/startdaemons.sh b/scripts/startdaemons.sh
index 9ead20acd..298162673 100755
--- a/scripts/startdaemons.sh
+++ b/scripts/startdaemons.sh
@@ -1,8 +1,8 @@
#!/bin/sh
-# Laconica - a distributed open-source microblogging tool
+# StatusNet - a distributed open-source microblogging tool
-# Copyright (C) 2008, 2009, Control Yourself, Inc.
+# Copyright (C) 2008, 2009, StatusNet, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# This program tries to start the daemons for Laconica.
+# This program tries to start the daemons for StatusNet.
# Note that the 'maildaemon' needs to run as a mail filter.
ARGSG=
diff --git a/scripts/laconica.spec b/scripts/statusnet.spec
index 331e10671..ca2e483a7 100644
--- a/scripts/laconica.spec
+++ b/scripts/statusnet.spec
@@ -4,13 +4,13 @@
BuildRequires: php-pear
BuildRequires: httpd-devel
-Name: laconica
+Name: statusnet
Version: %{LACVER}
Release: 1%{?dist}
License: GAGPL v3 or later
-Source: laconica-%{version}.tar.gz
+Source: statusnet-%{version}.tar.gz
Group: Applications/Internet
-Summary: Laconica, the Open Source microblogging platform
+Summary: StatusNet, the Open Source microblogging platform
BuildArch: noarch
Requires: httpd
@@ -31,7 +31,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build
%define confpath %{_sysconfdir}/%{name}
%description
-From the ABOUT file: Laconica (pronounced "luh-KAWN-ih-kuh") is a Free
+From the ABOUT file: StatusNet (pronounced "luh-KAWN-ih-kuh") is a Free
and Open Source microblogging platform. It helps people in a
community, company or group to exchange short (140 character) messages
over the Web. Users can choose which people to "follow" and receive
@@ -49,16 +49,16 @@ similar service to sites like Twitter, Jaiku, and Plurk.
mkdir -p %{buildroot}%{wwwpath}
cp -a * %{buildroot}%{wwwpath}
-mkdir -p %{buildroot}%{_datadir}/laconica
-cp -a db %{buildroot}%{_datadir}/laconica/db
+mkdir -p %{buildroot}%{_datadir}/statusnet
+cp -a db %{buildroot}%{_datadir}/statusnet/db
-mkdir -p %{buildroot}%{_datadir}/laconica/avatar
+mkdir -p %{buildroot}%{_datadir}/statusnet/avatar
mkdir -p %{buildroot}%{_sysconfdir}/httpd/conf.d
-cat > %{buildroot}%{_sysconfdir}/httpd/conf.d/laconica.conf <<"EOF"
-Alias /laconica/ "/var/www/laconica/"
+cat > %{buildroot}%{_sysconfdir}/httpd/conf.d/statusnet.conf <<"EOF"
+Alias /statusnet/ "/var/www/statusnet/"
-<Directory "/var/www/laconica">
+<Directory "/var/www/statusnet">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
@@ -73,26 +73,26 @@ rm -rf %buildroot
%defattr(-,root,root)
%dir %{wwwpath}
%{wwwpath}/*
-%{_datadir}/laconica/*
-%attr(-,apache,apache) %dir %{_datadir}/laconica/avatar
+%{_datadir}/statusnet/*
+%attr(-,apache,apache) %dir %{_datadir}/statusnet/avatar
%doc COPYING README doc-src/*
-%config(noreplace) %{_sysconfdir}/httpd/conf.d/laconica.conf
+%config(noreplace) %{_sysconfdir}/httpd/conf.d/statusnet.conf
%changelog
-* Wed Apr 03 2009 Zach Copley <zach@controlyourself.ca> - 0.7.3
+* Wed Apr 03 2009 Zach Copley <zach@status.net> - 0.7.3
- Changed version number to 0.7.3.
* Fri Mar 13 2009 Ken Sedgwick <ksedgwic@bonsai.com> - 0.7.2.1-1
-- Factored laconica version to the first line of the file.
+- Factored statusnet version to the first line of the file.
-* Wed Mar 03 2009 Zach Copley <zach@controlyourself.ca> - 0.7.2
+* Wed Mar 03 2009 Zach Copley <zach@status.net> - 0.7.2
- Changed version number to 0.7.2.
* Sat Feb 28 2009 Ken Sedgwick <ken@bonsai.com> - 0.7.1-1
- Modified RPM for Fedora.
* Thu Feb 13 2009 tuukka.pasanen@ilmi.fi
-- packaged laconica version 0.7.1
+- packaged statusnet version 0.7.1
* Wed Feb 04 2009 tuukka.pasanen@ilmi.fi
-- packaged laconica version 0.7.0 using the buildservice spec file wizard
+- packaged statusnet version 0.7.0 using the buildservice spec file wizard
diff --git a/scripts/stopdaemons.sh b/scripts/stopdaemons.sh
index 60ffd83ad..55b404c1a 100755
--- a/scripts/stopdaemons.sh
+++ b/scripts/stopdaemons.sh
@@ -1,8 +1,8 @@
#!/bin/bash
-# Laconica - a distributed open-source microblogging tool
+# StatusNet - a distributed open-source microblogging tool
-# Copyright (C) 2008, 2009, Control Yourself, Inc.
+# Copyright (C) 2008, 2009, StatusNet, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@@ -17,7 +17,7 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-# This program tries to stop the daemons for Laconica that were
+# This program tries to stop the daemons for StatusNet that were
# previously started by startdaemons.sh
SDIR=`dirname $0`
@@ -25,7 +25,7 @@ DIR=`php $SDIR/getpiddir.php`
for f in jabberhandler ombhandler publichandler smshandler pinghandler \
xmppconfirmhandler xmppdaemon twitterhandler facebookhandler \
- twitterstatusfetcher; do
+ twitterstatusfetcher synctwitterfriends; do
FILES="$DIR/$f.*.pid"
for ff in "$FILES" ; do
diff --git a/scripts/synctwitterfriends.php b/scripts/synctwitterfriends.php
index fe53ff44d..b30e700a1 100755
--- a/scripts/synctwitterfriends.php
+++ b/scripts/synctwitterfriends.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -20,85 +20,267 @@
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-// Uncomment this to get useful console output
+$shortoptions = 'di::';
+$longoptions = array('id::', 'debug');
+
+$helptext = <<<END_OF_TRIM_HELP
+Batch script for synching local friends with Twitter friends.
+ -i --id Identity (default 'generic')
+ -d --debug Debug (lots of log output)
+
+END_OF_TRIM_HELP;
+
+require_once INSTALLDIR . '/scripts/commandline.inc';
+require_once INSTALLDIR . '/lib/parallelizingdaemon.php';
+
+/**
+ * Daemon to sync local friends with Twitter friends
+ *
+ * @category Twitter
+ * @package StatusNet
+ * @author Zach Copley <zach@status.net>
+ * @author Evan Prodromou <evan@status.net>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://status.net/
+ */
$helptext = <<<END_OF_TWITTER_HELP
Batch script for synching local friends with Twitter friends.
END_OF_TWITTER_HELP;
-require_once INSTALLDIR.'/scripts/commandline.inc';
+require_once INSTALLDIR . '/scripts/commandline.inc';
+require_once INSTALLDIR . '/lib/parallelizingdaemon.php';
-// Make a lockfile
-$lockfilename = lockFilename();
-if (!($lockfile = @fopen($lockfilename, "w"))) {
- print "Already running... exiting.\n";
- exit(1);
-}
+class SyncTwitterFriendsDaemon extends ParallelizingDaemon
+{
+ /**
+ * Constructor
+ *
+ * @param string $id the name/id of this daemon
+ * @param int $interval sleep this long before doing everything again
+ * @param int $max_children maximum number of child processes at a time
+ * @param boolean $debug debug output flag
+ *
+ * @return void
+ *
+ **/
-// Obtain an exlcusive lock on file (will fail if script is already going)
-if (!@flock( $lockfile, LOCK_EX | LOCK_NB, &$wouldblock) || $wouldblock) {
- // Script already running - abort
- @fclose($lockfile);
- print "Already running... exiting.\n";
- exit(1);
-}
+ function __construct($id = null, $interval = 60,
+ $max_children = 2, $debug = null)
+ {
+ parent::__construct($id, $interval, $max_children, $debug);
+ }
-$flink = new Foreign_link();
-$flink->service = 1; // Twitter
-$flink->orderBy('last_friendsync');
-$flink->limit(25); // sync this many users during this run
-$cnt = $flink->find();
+ /**
+ * Name of this daemon
+ *
+ * @return string Name of the daemon.
+ */
-print "Updating Twitter friends subscriptions for $cnt users.\n";
+ function name()
+ {
+ return ('synctwitterfriends.' . $this->_id);
+ }
-while ($flink->fetch()) {
+ /**
+ * Find all the Twitter foreign links for users who have requested
+ * automatically subscribing to their Twitter friends locally.
+ *
+ * @return array flinks an array of Foreign_link objects
+ */
+ function getObjects()
+ {
+ $flinks = array();
+ $flink = new Foreign_link();
- if (($flink->friendsync & FOREIGN_FRIEND_RECV) == FOREIGN_FRIEND_RECV) {
+ $conn = &$flink->getDatabaseConnection();
- $user = User::staticGet($flink->user_id);
+ $flink->service = TWITTER_SERVICE;
+ $flink->orderBy('last_friendsync');
+ $flink->limit(25); // sync this many users during this run
+ $flink->find();
- if (empty($user)) {
- common_log(LOG_WARNING, "Unmatched user for ID " . $flink->user_id);
- print "Unmatched user for ID $flink->user_id\n";
- continue;
+ while ($flink->fetch()) {
+ if (($flink->friendsync & FOREIGN_FRIEND_RECV) == FOREIGN_FRIEND_RECV) {
+ $flinks[] = clone($flink);
+ }
}
- print "Updating Twitter friends for $user->nickname (Laconica ID: $user->id)... ";
+ $conn->disconnect();
- $fuser = $flink->getForeignUser();
+ global $_DB_DATAOBJECT;
+ unset($_DB_DATAOBJECT['CONNECTIONS']);
- if (empty($fuser)) {
- common_log(LOG_WARNING, "Unmatched user for ID " . $flink->user_id);
- print "Unmatched user for ID $flink->user_id\n";
- continue;
- }
+ return $flinks;
+ }
+
+ function childTask($flink) {
+
+ // Each child ps needs its own DB connection
- save_twitter_friends($user, $fuser->id, $fuser->nickname, $flink->credentials);
+ // Note: DataObject::getDatabaseConnection() creates
+ // a new connection if there isn't one already
+
+ $conn = &$flink->getDatabaseConnection();
+
+ $this->subscribeTwitterFriends($flink);
$flink->last_friendsync = common_sql_now();
$flink->update();
- if (defined('SCRIPT_DEBUG')) {
- print "\nDONE\n";
+ $conn->disconnect();
+
+ // XXX: Couldn't find a less brutal way to blow
+ // away a cached connection
+
+ global $_DB_DATAOBJECT;
+ unset($_DB_DATAOBJECT['CONNECTIONS']);
+ }
+
+ function fetchTwitterFriends($flink)
+ {
+ $friends = array();
+
+ $client = null;
+
+ if (TwitterOAuthClient::isPackedToken($flink->credentials)) {
+ $token = TwitterOAuthClient::unpackToken($flink->credentials);
+ $client = new TwitterOAuthClient($token->key, $token->secret);
+ common_debug($this->name() . '- Grabbing friends IDs with OAuth.');
} else {
- print "DONE\n";
+ $client = new TwitterBasicAuthClient($flink);
+ common_debug($this->name() . '- Grabbing friends IDs with basic auth.');
}
+
+ try {
+ $friends_ids = $client->friendsIds();
+ } catch (Exception $e) {
+ common_log(LOG_WARNING, $this->name() .
+ ' - cURL error getting friend ids ' .
+ $e->getCode() . ' - ' . $e->getMessage());
+ return $friends;
+ }
+
+ if (empty($friends_ids)) {
+ common_debug($this->name() .
+ " - Twitter user $flink->foreign_id " .
+ 'doesn\'t have any friends!');
+ return $friends;
+ }
+
+ common_debug($this->name() . ' - Twitter\'s API says Twitter user id ' .
+ "$flink->foreign_id has " .
+ count($friends_ids) . ' friends.');
+
+ // Calculate how many pages to get...
+ $pages = ceil(count($friends_ids) / 100);
+
+ if ($pages == 0) {
+ common_debug($this->name() . " - $user seems to have no friends.");
+ }
+
+ for ($i = 1; $i <= $pages; $i++) {
+
+ try {
+ $more_friends = $client->statusesFriends(null, null, null, $i);
+ } catch (Exception $e) {
+ common_log(LOG_WARNING, $this->name() .
+ ' - cURL error getting Twitter statuses/friends ' .
+ "page $i - " . $e->getCode() . ' - ' .
+ $e->getMessage());
+ }
+
+ if (empty($more_friends)) {
+ common_log(LOG_WARNING, $this->name() .
+ " - Couldn't retrieve page $i " .
+ "of Twitter user $flink->foreign_id friends.");
+ continue;
+ } else {
+ $friends = array_merge($friends, $more_friends);
+ }
+ }
+
+ return $friends;
}
-}
-function lockFilename()
-{
- $piddir = common_config('daemon', 'piddir');
- if (!$piddir) {
- $piddir = '/var/run';
+ function subscribeTwitterFriends($flink)
+ {
+ $friends = $this->fetchTwitterFriends($flink);
+
+ if (empty($friends)) {
+ common_debug($this->name() .
+ ' - Couldn\'t get friends from Twitter for ' .
+ "Twitter user $flink->foreign_id.");
+ return false;
+ }
+
+ $user = $flink->getUser();
+
+ foreach ($friends as $friend) {
+
+ $friend_name = $friend->screen_name;
+ $friend_id = (int) $friend->id;
+
+ // Update or create the Foreign_user record for each
+ // Twitter friend
+
+ if (!save_twitter_user($friend_id, $friend_name)) {
+ common_log(LOG_WARNING, $this-name() .
+ " - Couldn't save $screen_name's friend, $friend_name.");
+ continue;
+ }
+
+ // Check to see if there's a related local user
+
+ $friend_flink = Foreign_link::getByForeignID($friend_id,
+ TWITTER_SERVICE);
+
+ if (!empty($friend_flink)) {
+
+ // Get associated user and subscribe her
+
+ $friend_user = User::staticGet('id', $friend_flink->user_id);
+
+ if (!empty($friend_user)) {
+ $result = subs_subscribe_to($user, $friend_user);
+
+ if ($result === true) {
+ common_log(LOG_INFO,
+ $this->name() . ' - Subscribed ' .
+ "$friend_user->nickname to $user->nickname.");
+ } else {
+ common_debug($this->name() .
+ ' - Tried subscribing ' .
+ "$friend_user->nickname to $user->nickname - " .
+ $result);
+ }
+ }
+ }
+ }
+
+ return true;
}
- return $piddir . '/synctwitterfriends.lock';
}
-// Cleanup
-fclose($lockfile);
-unlink($lockfilename);
+$id = null;
+$debug = null;
+
+if (have_option('i')) {
+ $id = get_option_value('i');
+} else if (have_option('--id')) {
+ $id = get_option_value('--id');
+} else if (count($args) > 0) {
+ $id = $args[0];
+} else {
+ $id = null;
+}
+
+if (have_option('d') || have_option('debug')) {
+ $debug = true;
+}
+
+$syncer = new SyncTwitterFriendsDaemon($id, 60, 2, $debug);
+$syncer->runOnce();
-exit(0);
diff --git a/scripts/triminboxes.php b/scripts/triminboxes.php
index 27e200fef..da09817e5 100644
--- a/scripts/triminboxes.php
+++ b/scripts/triminboxes.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/twitterqueuehandler.php b/scripts/twitterqueuehandler.php
index 00e735d98..ce4d824d0 100755
--- a/scripts/twitterqueuehandler.php
+++ b/scripts/twitterqueuehandler.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/twitterstatusfetcher.php b/scripts/twitterstatusfetcher.php
index e1745cfc0..3cdf1867a 100755
--- a/scripts/twitterstatusfetcher.php
+++ b/scripts/twitterstatusfetcher.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/**
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -46,27 +46,33 @@ require_once INSTALLDIR . '/lib/daemon.php';
* system.
*
* @category Twitter
- * @package Laconica
- * @author Zach Copley <zach@controlyourself.ca>
- * @author Evan Prodromou <evan@controlyourself.ca>
+ * @package StatusNet
+ * @author Zach Copley <zach@status.net>
+ * @author Evan Prodromou <evan@status.net>
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link http://laconi.ca/
+ * @link http://status.net/
*/
// NOTE: an Avatar path MUST be set in config.php for this
-// script to work: e.g.: $config['avatar']['path'] = '/laconica/avatar';
+// script to work: e.g.: $config['avatar']['path'] = '/statusnet/avatar';
-class TwitterStatusFetcher extends Daemon
+class TwitterStatusFetcher extends ParallelizingDaemon
{
- private $_children = array();
-
- function __construct($id=null, $daemonize=true)
+ /**
+ * Constructor
+ *
+ * @param string $id the name/id of this daemon
+ * @param int $interval sleep this long before doing everything again
+ * @param int $max_children maximum number of child processes at a time
+ * @param boolean $debug debug output flag
+ *
+ * @return void
+ *
+ **/
+ function __construct($id = null, $interval = 60,
+ $max_children = 2, $debug = null)
{
- parent::__construct($daemonize);
-
- if ($id) {
- $this->set_id($id);
- }
+ parent::__construct($id, $interval, $max_children, $debug);
}
/**
@@ -81,126 +87,22 @@ class TwitterStatusFetcher extends Daemon
}
/**
- * Run the daemon
+ * Find all the Twitter foreign links for users who have requested
+ * importing of their friends' timelines
*
- * @return void
+ * @return array flinks an array of Foreign_link objects
*/
- function run()
+ function getObjects()
{
- if (defined('SCRIPT_DEBUG')) {
- common_debug($this->name() .
- ': debugging log output enabled.');
- }
-
- do {
-
- $flinks = $this->refreshFlinks();
-
- foreach ($flinks as $f) {
-
- // We have to disconnect from the DB before forking so
- // each sub-process will open its own connection and
- // avoid stomping on the others
-
- $conn = &$f->getDatabaseConnection();
- $conn->disconnect();
-
- $pid = pcntl_fork();
-
- if ($pid == -1) {
- die ("Couldn't fork!");
- }
-
- if ($pid) {
-
- // Parent
- if (defined('SCRIPT_DEBUG')) {
- common_debug("Parent: forked new status ".
- " fetcher process " . $pid);
- }
-
- $this->_children[] = $pid;
-
- } else {
-
- // Child
- $this->getTimeline($f);
- exit();
- }
-
- // Remove child from ps list as it finishes
- while (($c = pcntl_wait($status, WNOHANG OR WUNTRACED)) > 0) {
-
- if (defined('SCRIPT_DEBUG')) {
- common_debug("Child $c finished.");
- }
-
- $this->removePs($this->_children, $c);
- }
-
- // Wait! We have too many damn kids.
- if (sizeof($this->_children) > MAXCHILDREN) {
-
- if (defined('SCRIPT_DEBUG')) {
- common_debug('Too many children. Waiting...');
- }
-
- if (($c = pcntl_wait($status, WUNTRACED)) > 0) {
-
- if (defined('SCRIPT_DEBUG')) {
- common_debug("Finished waiting for $c");
- }
-
- $this->removePs($this->_children, $c);
- }
- }
- }
-
- // Remove all children from the process list before restarting
- while (($c = pcntl_wait($status, WUNTRACED)) > 0) {
-
- if (defined('SCRIPT_DEBUG')) {
- common_debug("Child $c finished.");
- }
-
- $this->removePs($this->_children, $c);
- }
-
- // Rest for a bit before we fetch more statuses
-
- if (defined('SCRIPT_DEBUG')) {
- common_debug('Waiting ' . POLL_INTERVAL .
- ' secs before hitting Twitter again.');
- }
-
- if (POLL_INTERVAL > 0) {
- sleep(POLL_INTERVAL);
- }
-
- } while (true);
- }
-
- /**
- * Refresh the foreign links for this user
- *
- * @return void
- */
+ global $_DB_DATAOBJECT;
- function refreshFlinks()
- {
$flink = new Foreign_link();
+ $conn = &$flink->getDatabaseConnection();
- $flink->service = 1; // Twitter
-
+ $flink->service = TWITTER_SERVICE;
$flink->orderBy('last_noticesync');
-
- $cnt = $flink->find();
-
- if (defined('SCRIPT_DEBUG')) {
- common_debug('Updating Twitter friends subscriptions' .
- " for $cnt users.");
- }
+ $flink->find();
$flinks = array();
@@ -215,78 +117,88 @@ class TwitterStatusFetcher extends Daemon
$flink->free();
unset($flink);
+ $conn->disconnect();
+ unset($_DB_DATAOBJECT['CONNECTIONS']);
+
return $flinks;
}
- /**
- * Unknown
- *
- * @param array &$plist unknown.
- * @param string $ps unknown.
- *
- * @return unknown
- * @todo document
- */
+ function childTask($flink) {
- function removePs(&$plist, $ps)
- {
- for ($i = 0; $i < sizeof($plist); $i++) {
- if ($plist[$i] == $ps) {
- unset($plist[$i]);
- $plist = array_values($plist);
- break;
- }
- }
+ // Each child ps needs its own DB connection
+
+ // Note: DataObject::getDatabaseConnection() creates
+ // a new connection if there isn't one already
+
+ $conn = &$flink->getDatabaseConnection();
+
+ $this->getTimeline($flink);
+
+ $flink->last_friendsync = common_sql_now();
+ $flink->update();
+
+ $conn->disconnect();
+
+ // XXX: Couldn't find a less brutal way to blow
+ // away a cached connection
+
+ global $_DB_DATAOBJECT;
+ unset($_DB_DATAOBJECT['CONNECTIONS']);
}
function getTimeline($flink)
{
if (empty($flink)) {
- common_log(LOG_WARNING,
- "Can't retrieve Foreign_link for foreign ID $fid");
+ common_log(LOG_WARNING, $this->name() .
+ " - Can't retrieve Foreign_link for foreign ID $fid");
return;
}
- $fuser = $flink->getForeignUser();
-
- if (empty($fuser)) {
- common_log(LOG_WARNING, "Unmatched user for ID " .
- $flink->user_id);
- return;
- }
-
- if (defined('SCRIPT_DEBUG')) {
- common_debug('Trying to get timeline for Twitter user ' .
- "$fuser->nickname ($flink->foreign_id).");
- }
+ common_debug($this->name() . ' - Trying to get timeline for Twitter user ' .
+ $flink->foreign_id);
// XXX: Biggest remaining issue - How do we know at which status
// to start importing? How many statuses? Right now I'm going
// with the default last 20.
- $url = 'http://twitter.com/statuses/friends_timeline.json';
+ $client = null;
- $timeline_json = get_twitter_data($url, $fuser->nickname,
- $flink->credentials);
+ if (TwitterOAuthClient::isPackedToken($flink->credentials)) {
+ $token = TwitterOAuthClient::unpackToken($flink->credentials);
+ $client = new TwitterOAuthClient($token->key, $token->secret);
+ common_debug($this->name() . ' - Grabbing friends timeline with OAuth.');
+ } else {
+ $client = new TwitterBasicAuthClient($flink);
+ common_debug($this->name() . ' - Grabbing friends timeline with basic auth.');
+ }
+
+ $timeline = null;
- $timeline = json_decode($timeline_json);
+ try {
+ $timeline = $client->statusesFriendsTimeline();
+ } catch (Exception $e) {
+ common_log(LOG_WARNING, $this->name() .
+ ' - Twitter client unable to get friends timeline for user ' .
+ $flink->user_id . ' - code: ' .
+ $e->getCode() . 'msg: ' . $e->getMessage());
+ }
if (empty($timeline)) {
- common_log(LOG_WARNING, "Empty timeline.");
+ common_log(LOG_WARNING, $this->name() . " - Empty timeline.");
return;
}
// Reverse to preserve order
+
foreach (array_reverse($timeline) as $status) {
- // Hacktastic: filter out stuff coming from this Laconica
+ // Hacktastic: filter out stuff coming from this StatusNet
+
$source = mb_strtolower(common_config('integration', 'source'));
if (preg_match("/$source/", mb_strtolower($status->source))) {
- if (defined('SCRIPT_DEBUG')) {
- common_debug('Skipping import of status ' . $status->id .
- ' with source ' . $source);
- }
+ common_debug($this->name() . ' - Skipping import of status ' .
+ $status->id . ' with source ' . $source);
continue;
}
@@ -294,6 +206,7 @@ class TwitterStatusFetcher extends Daemon
}
// Okay, record the time we synced with Twitter for posterity
+
$flink->last_noticesync = common_sql_now();
$flink->update();
}
@@ -301,11 +214,12 @@ class TwitterStatusFetcher extends Daemon
function saveStatus($status, $flink)
{
$id = $this->ensureProfile($status->user);
+
$profile = Profile::staticGet($id);
- if (!$profile) {
- common_log(LOG_ERR,
- 'Problem saving notice. No associated Profile.');
+ if (empty($profile)) {
+ common_log(LOG_ERR, $this->name() .
+ ' - Problem saving notice. No associated Profile.');
return null;
}
@@ -318,7 +232,7 @@ class TwitterStatusFetcher extends Daemon
// check to see if we've already imported the status
- if (!$notice) {
+ if (empty($notice)) {
$notice = new Notice();
@@ -329,7 +243,7 @@ class TwitterStatusFetcher extends Daemon
$notice->content = common_shorten_links($status->text); // XXX
$notice->rendered = common_render_content($notice->content, $notice);
$notice->source = 'twitter';
- $notice->reply_to = null; // XXX lookup reply
+ $notice->reply_to = null; // XXX: lookup reply
$notice->is_local = Notice::GATEWAY;
if (Event::handle('StartNoticeSave', array(&$notice))) {
@@ -355,24 +269,22 @@ class TwitterStatusFetcher extends Daemon
function ensureProfile($user)
{
// check to see if there's already a profile for this user
+
$profileurl = 'http://twitter.com/' . $user->screen_name;
$profile = Profile::staticGet('profileurl', $profileurl);
- if ($profile) {
- if (defined('SCRIPT_DEBUG')) {
- common_debug("Profile for $profile->nickname found.");
- }
+ if (!empty($profile)) {
+ common_debug($this->name() .
+ " - Profile for $profile->nickname found.");
// Check to see if the user's Avatar has changed
- $this->checkAvatar($user, $profile);
+ $this->checkAvatar($user, $profile);
return $profile->id;
} else {
- if (defined('SCRIPT_DEBUG')) {
- common_debug('Adding profile and remote profile ' .
- "for Twitter user: $profileurl");
- }
+ common_debug($this->name() . ' - Adding profile and remote profile ' .
+ "for Twitter user: $profileurl.");
$profile = new Profile();
$profile->query("BEGIN");
@@ -394,9 +306,10 @@ class TwitterStatusFetcher extends Daemon
}
// check for remote profile
+
$remote_pro = Remote_profile::staticGet('uri', $profileurl);
- if (!$remote_pro) {
+ if (empty($remote_pro)) {
$remote_pro = new Remote_profile();
@@ -433,23 +346,18 @@ class TwitterStatusFetcher extends Daemon
$oldname = $profile->getAvatar(48)->filename;
if ($newname != $oldname) {
-
- if (defined('SCRIPT_DEBUG')) {
- common_debug('Avatar for Twitter user ' .
- "$profile->nickname has changed.");
- common_debug("old: $oldname new: $newname");
- }
+ common_debug($this->name() . ' - Avatar for Twitter user ' .
+ "$profile->nickname has changed.");
+ common_debug($this->name() . " - old: $oldname new: $newname");
$this->updateAvatars($twitter_user, $profile);
}
if ($this->missingAvatarFile($profile)) {
-
- if (defined('SCRIPT_DEBUG')) {
- common_debug('Twitter user ' . $profile->nickname .
- ' is missing one or more local avatars.');
- common_debug("old: $oldname new: $newname");
- }
+ common_debug($this->name() . ' - Twitter user ' .
+ $profile->nickname .
+ ' is missing one or more local avatars.');
+ common_debug($this->name() ." - old: $oldname new: $newname");
$this->updateAvatars($twitter_user, $profile);
}
@@ -529,23 +437,20 @@ class TwitterStatusFetcher extends Daemon
if ($this->fetchAvatar($url, $filename)) {
$this->newAvatar($id, $size, $mediatype, $filename);
} else {
- common_log(LOG_WARNING, "Problem fetching Avatar: $url", __FILE__);
+ common_log(LOG_WARNING, $this->id() .
+ " - Problem fetching Avatar: $url");
}
}
}
function updateAvatar($profile_id, $size, $mediatype, $filename) {
- if (defined('SCRIPT_DEBUG')) {
- common_debug("Updating avatar: $size");
- }
+ common_debug($this->name() . " - Updating avatar: $size");
$profile = Profile::staticGet($profile_id);
if (empty($profile)) {
- if (defined('SCRIPT_DEBUG')) {
- common_debug("Couldn't get profile: $profile_id!");
- }
+ common_debug($this->name() . " - Couldn't get profile: $profile_id!");
return;
}
@@ -553,6 +458,7 @@ class TwitterStatusFetcher extends Daemon
$avatar = $profile->getAvatar($sizes[$size]);
// Delete the avatar, if present
+
if ($avatar) {
$avatar->delete();
}
@@ -579,7 +485,7 @@ class TwitterStatusFetcher extends Daemon
default:
// Note: Twitter's big avatars are a different size than
- // Laconica's (Laconica's = 96)
+ // StatusNet's (StatusNet's = 96)
$avatar->width = 73;
$avatar->height = 73;
@@ -590,9 +496,7 @@ class TwitterStatusFetcher extends Daemon
$avatar->filename = $filename;
$avatar->url = Avatar::url($filename);
- if (defined('SCRIPT_DEBUG')) {
- common_debug("new filename: $avatar->url");
- }
+ common_debug($this->name() . " - New filename: $avatar->url");
$avatar->created = common_sql_now();
@@ -603,9 +507,8 @@ class TwitterStatusFetcher extends Daemon
return null;
}
- if (defined('SCRIPT_DEBUG')) {
- common_debug("Saved new $size avatar for $profile_id.");
- }
+ common_debug($this->name() .
+ " - Saved new $size avatar for $profile_id.");
return $id;
}
@@ -618,13 +521,12 @@ class TwitterStatusFetcher extends Daemon
$out = fopen($avatarfile, 'wb');
if (!$out) {
- common_log(LOG_WARNING, "Couldn't open file $filename", __FILE__);
+ common_log(LOG_WARNING, $this->name() .
+ " - Couldn't open file $filename");
return false;
}
- if (defined('SCRIPT_DEBUG')) {
- common_debug("Fetching avatar: $url");
- }
+ common_debug($this->name() . " - Fetching Twitter avatar: $url");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
@@ -641,7 +543,8 @@ class TwitterStatusFetcher extends Daemon
}
}
-declare(ticks = 1);
+$id = null;
+$debug = null;
if (have_option('i')) {
$id = get_option_value('i');
@@ -654,9 +557,9 @@ if (have_option('i')) {
}
if (have_option('d') || have_option('debug')) {
- define('SCRIPT_DEBUG', true);
+ $debug = true;
}
-$fetcher = new TwitterStatusFetcher($id);
+$fetcher = new TwitterStatusFetcher($id, 60, 2, $debug);
$fetcher->runOnce();
diff --git a/scripts/uncache_users.php b/scripts/uncache_users.php
index b0b576eb4..5a1d33030 100644
--- a/scripts/uncache_users.php
+++ b/scripts/uncache_users.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/update_pot.sh b/scripts/update_pot.sh
index a7f5e4d3a..9419e4337 100755
--- a/scripts/update_pot.sh
+++ b/scripts/update_pot.sh
@@ -1,3 +1,3 @@
cd `dirname $0`
cd ..
-xgettext --from-code=UTF-8 --default-domain=laconica --output=locale/laconica.po --language=PHP --join-existing actions/*.php classes/*.php lib/*.php scripts/*.php
+xgettext --from-code=UTF-8 --default-domain=statusnet --output=locale/statusnet.po --language=PHP --join-existing actions/*.php classes/*.php lib/*.php scripts/*.php
diff --git a/scripts/update_translations.php b/scripts/update_translations.php
index 2f4ca8720..f145c1f0b 100755
--- a/scripts/update_translations.php
+++ b/scripts/update_translations.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -25,12 +25,13 @@ if (isset($_SERVER) && array_key_exists('REQUEST_METHOD', $_SERVER)) {
}
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
-define('LACONICA', true);
+define('STATUSNET', true);
+define('LACONICA', true); // compatibility
require_once(INSTALLDIR . '/lib/common.php');
-// Master Laconica .pot file location (created by update_pot.sh)
-$laconica_pot = INSTALLDIR . '/locale/laconica.po';
+// Master StatusNet .pot file location (created by update_pot.sh)
+$statusnet_pot = INSTALLDIR . '/locale/statusnet.po';
set_time_limit(60);
@@ -42,12 +43,12 @@ $languages = get_all_languages();
foreach ($languages as $language) {
$code = $language['lang'];
- $file_url = 'http://laconi.ca/pootle/' . $code .
- '/laconica/LC_MESSAGES/laconica.po';
+ $file_url = 'http://status.net/pootle/' . $code .
+ '/statusnet/LC_MESSAGES/statusnet.po';
$lcdir = INSTALLDIR . '/locale/' . $code;
$msgdir = "$lcdir/LC_MESSAGES";
- $pofile = "$msgdir/laconica.po";
- $mofile = "$msgdir/laconica.mo";
+ $pofile = "$msgdir/statusnet.po";
+ $mofile = "$msgdir/statusnet.mo";
/* Check for an existing */
if (!is_dir($msgdir)) {
@@ -71,7 +72,7 @@ foreach ($languages as $language) {
if (sha1($new_file) != $existingSHA1 || !file_exists($mofile)) {
echo "Updating ".$code."\n";
file_put_contents($pofile, $new_file);
- system(sprintf('msgmerge -U %s %s', $pofile, $laconica_pot));
+ system(sprintf('msgmerge -U %s %s', $pofile, $statusnet_pot));
system(sprintf('msgfmt -f -o %s %s', $mofile, $pofile));
} else {
echo "Unchanged - ".$code."\n";
diff --git a/scripts/xmppconfirmhandler.php b/scripts/xmppconfirmhandler.php
index d6821ddef..c7ed15e49 100755
--- a/scripts/xmppconfirmhandler.php
+++ b/scripts/xmppconfirmhandler.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php
index 69512f243..9e621e725 100755
--- a/scripts/xmppdaemon.php
+++ b/scripts/xmppdaemon.php
@@ -1,8 +1,8 @@
#!/usr/bin/env php
<?php
/*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, 2009, Control Yourself, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by