jacobwb / hashover-next

This branch will be HashOver 2.0
GNU Affero General Public License v3.0
419 stars 87 forks source link

Allow url avatars in xml #258

Open jcubic opened 5 years ago

jcubic commented 5 years ago

I'm in process of importing data from disqus and I've modified the code to allow:

<avatar>https://disqus.com/api/users/avatars/jcubic.jpg</avatar>

in xml for comment, because Disqus don't allow to get email (probably because of GDPR) but hey have avatars in their api.

It would be useful to have this feature in the project just for export from other commening system that don't export email addresses.

to allow this I've modified commentparser.php:

// Get avatar icons
if ($this->setup->iconMode !== 'none') {
    if ($this->setup->iconMode === 'image') {
        $hash = Misc::getArrayItem ($comment, 'email_hash') ?: '';
        $avatar = Misc::getArrayItem ($comment, 'avatar');
        if (!empty($avatar)) {
            $output['avatar'] = $avatar;
        } else {
            // Get MD5 hash for Gravatar
            $output['avatar'] = $this->avatars->getGravatar ($hash);
        }
    } else {
        $output['avatar'] = end ($key_parts);
    }
}