forked from GNUsocial/gnu-social
Better avatar handling - pull in any missing Twitter avatars
This commit is contained in:
parent
d3fa832f76
commit
e506f82cdf
@ -154,6 +154,9 @@ $config['sphinx']['port'] = 3312;
|
|||||||
// $config['integration']['source'] = 'Laconica';
|
// $config['integration']['source'] = 'Laconica';
|
||||||
|
|
||||||
// Enable bidirectional Twitter bridge
|
// Enable bidirectional Twitter bridge
|
||||||
|
//
|
||||||
|
// NOTE: if you enable this you must also set $config['avatar']['path']
|
||||||
|
//
|
||||||
// $config['twitterbridge']['enabled'] = true;
|
// $config['twitterbridge']['enabled'] = true;
|
||||||
|
|
||||||
// Edit throttling. Off by default. If turned on, you can only post 20 notices
|
// Edit throttling. Off by default. If turned on, you can only post 20 notices
|
||||||
|
@ -38,6 +38,9 @@ define('SCRIPT_DEBUG', true);
|
|||||||
require_once(INSTALLDIR . '/lib/common.php');
|
require_once(INSTALLDIR . '/lib/common.php');
|
||||||
require_once(INSTALLDIR . '/lib/daemon.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
|
class TwitterStatusFetcher extends Daemon
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -358,11 +361,11 @@ class TwitterStatusFetcher extends Daemon
|
|||||||
|
|
||||||
$oldname = $profile->getAvatar(48)->filename;
|
$oldname = $profile->getAvatar(48)->filename;
|
||||||
|
|
||||||
if ($newname != $oldname) {
|
if ($newname != $oldname || $this->missingAvatarFile($profile)) {
|
||||||
|
|
||||||
if (defined('SCRIPT_DEBUG')) {
|
if (defined('SCRIPT_DEBUG')) {
|
||||||
common_debug('Avatar for Twitter user ' .
|
common_debug('Avatar for Twitter user ' .
|
||||||
"$profile->nickname has changed.");
|
"$profile->nickname has changed, or was missing locally.");
|
||||||
common_debug("old: $oldname new: $newname");
|
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)
|
function getMediatype($ext)
|
||||||
{
|
{
|
||||||
$mediatype = null;
|
$mediatype = null;
|
||||||
@ -447,7 +465,6 @@ class TwitterStatusFetcher extends Daemon
|
|||||||
if (defined('SCRIPT_DEBUG')) {
|
if (defined('SCRIPT_DEBUG')) {
|
||||||
common_debug("Deleting $size avatar for $profile->nickname.");
|
common_debug("Deleting $size avatar for $profile->nickname.");
|
||||||
}
|
}
|
||||||
@unlink(INSTALLDIR . '/avatar/' . $avatar->filename);
|
|
||||||
$avatar->delete();
|
$avatar->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user