summaryrefslogtreecommitdiff
path: root/scripts/twitterstatusfetcher.php
diff options
context:
space:
mode:
authorZach Copley <zach@controlyourself.ca>2009-06-18 16:51:06 -0700
committerZach Copley <zach@controlyourself.ca>2009-06-18 16:51:06 -0700
commite506f82cdf8d88186c425a3f58e15b5126fdb248 (patch)
tree3ce482fa185e9a8cde5313851cf3bc4d35480246 /scripts/twitterstatusfetcher.php
parentd3fa832f76c90c194e0a60448ad8c53a043f5438 (diff)
Better avatar handling - pull in any missing Twitter avatars
Diffstat (limited to 'scripts/twitterstatusfetcher.php')
-rwxr-xr-xscripts/twitterstatusfetcher.php23
1 files changed, 20 insertions, 3 deletions
diff --git a/scripts/twitterstatusfetcher.php b/scripts/twitterstatusfetcher.php
index 9287b6d73..93a4ce92b 100755
--- a/scripts/twitterstatusfetcher.php
+++ b/scripts/twitterstatusfetcher.php
@@ -38,6 +38,9 @@ define('SCRIPT_DEBUG', true);
require_once(INSTALLDIR . '/lib/common.php');
require_once(INSTALLDIR . '/lib/daemon.php');
+// NOTE: an Avatar path MUST be set in config.php for this
+// script to work: e.g.: $config['avatar']['path'] = '/laconica/avatar';
+
class TwitterStatusFetcher extends Daemon
{
@@ -358,11 +361,11 @@ class TwitterStatusFetcher extends Daemon
$oldname = $profile->getAvatar(48)->filename;
- if ($newname != $oldname) {
+ if ($newname != $oldname || $this->missingAvatarFile($profile)) {
if (defined('SCRIPT_DEBUG')) {
common_debug('Avatar for Twitter user ' .
- "$profile->nickname has changed.");
+ "$profile->nickname has changed, or was missing locally.");
common_debug("old: $oldname new: $newname");
}
@@ -383,6 +386,21 @@ class TwitterStatusFetcher extends Daemon
}
}
+ function missingAvatarFile($profile) {
+
+ foreach (array(24, 48, 73) as $size) {
+
+ $filename = $profile->getAvatar($size)->filename;
+ $avatarpath = Avatar::path($filename);
+
+ if (file_exists($avatarpath) == FALSE) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
function getMediatype($ext)
{
$mediatype = null;
@@ -447,7 +465,6 @@ class TwitterStatusFetcher extends Daemon
if (defined('SCRIPT_DEBUG')) {
common_debug("Deleting $size avatar for $profile->nickname.");
}
- @unlink(INSTALLDIR . '/avatar/' . $avatar->filename);
$avatar->delete();
}