Merge pull request #1051 from annando/catavatar

Catavatar: Fix handling of avatar generating for any address
This commit is contained in:
Hypolite Petovan 2020-12-06 18:36:02 -05:00 committed by GitHub
commit c623195e0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -126,12 +126,16 @@ function catavatar_addon_settings_post(App $a, &$s)
function catavatar_lookup(App $a, &$b) function catavatar_lookup(App $a, &$b)
{ {
$user = DBA::selectFirst('user', ['uid'], ['email' => $b['email']]); $user = DBA::selectFirst('user', ['uid'], ['email' => $b['email']]);
if (DBA::isResult($user)) {
$url = DI::baseUrl()->get() . '/catavatar/' . $user['uid']; $url = DI::baseUrl()->get() . '/catavatar/' . $user['uid'];
} else {
$url = DI::baseUrl()->get() . '/catavatar/' . md5(trim(strtolower($b['email'])));
}
switch($b['size']) { switch($b['size']) {
case 300: $url .= "/4"; break; case 300: $url .= "/4"; break;
case 80: $url .= "/5"; break; case 80: $url .= "/5"; break;
case 47: $url .= "/6"; break; case 48: $url .= "/6"; break;
} }
$b['url'] = $url; $b['url'] = $url;
@ -152,13 +156,8 @@ function catavatar_content(App $a)
throw new NotFoundException(); // this should be catched on index and show default "not found" page. throw new NotFoundException(); // this should be catched on index and show default "not found" page.
} }
if (is_numeric($a->argv[1])) {
$uid = intval($a->argv[1]); $uid = intval($a->argv[1]);
$size = 0;
if ($a->argc == 3) {
$size = intval($a->argv[2]);
}
$condition = ['uid' => $uid, $condition = ['uid' => $uid,
'account_expired' => false, 'account_removed' => false]; 'account_expired' => false, 'account_removed' => false];
$user = DBA::selectFirst('user', ['email'], $condition); $user = DBA::selectFirst('user', ['email'], $condition);
@ -168,6 +167,16 @@ function catavatar_content(App $a)
} }
$seed = DI::pConfig()->get($uid, "catavatar", "seed", md5(trim(strtolower($user['email'])))); $seed = DI::pConfig()->get($uid, "catavatar", "seed", md5(trim(strtolower($user['email']))));
} elseif (!empty($a->argv[1])) {
$seed = $a->argv[1];
} else {
throw new NotFoundException();
}
$size = 0;
if ($a->argc == 3) {
$size = intval($a->argv[2]);
}
// ...Or start generation // ...Or start generation
ob_start(); ob_start();
@ -180,8 +189,6 @@ function catavatar_content(App $a)
exit(); exit();
} }
/** /**
* ==================== * ====================
* CAT-AVATAR-GENERATOR * CAT-AVATAR-GENERATOR