XF2 [8WR] Discord Integration

XF2 [8WR] Discord Integration [Paid] 2.1.1.9

No permission to buy ($30.00)
Jaxel updated XF2 [8WR] Discord Integration with a new update entry:

2.1.1.1 - CHANGELOG

This is a continuation of the 2.1.1.0 update that came out a few hours ago. I HIGHLY recommend you read the patch notes for that update as well:


This update continues with the normalization and standardization which began in the last update. However, this update is a bit trickier. In this version, the connected account provider has been changed from...

Read the rest of this update entry...
 
Unfortunately, we can't just rename connected accounts and call it a day.
You can, actually :)

I took the liberty of writing the upgrade method for you:
PHP:
    public function upgrade2111Step1(array $stepParams)
    {
        $position = empty($stepParams[0]) ? 0 : $stepParams[0];
        $perPage = 250;
     
        $db = $this->db();
     
        if (!isset($stepParams['max']))
        {
            $stepParams['max'] = $db->fetchOne("
                SELECT MAX(user_id)
                FROM xf_user_connected_account
                WHERE provider = 'discord'
            ");
        }
     
        $userIds = $db->fetchAllColumn($db->limit(
            "
                SELECT DISTINCT user_id
                FROM xf_user_connected_account
                WHERE user_id > ?
                    AND provider = 'discord'
                ORDER BY user_id
            ", $perPage
        ), $position);
        if (!$userIds)
        {
            return true;
        }
     
        $db->beginTransaction();

        $repo = \XF::repository('XF:ConnectedAccount');
     
        $connectedAccounts = \XF::finder('XF:UserConnectedAccount')->where('user_id', $userIds)->with(['User'])->fetch();
        foreach ($connectedAccounts as $connectedAccount)
        {
            $connectedAccount->fastUpdate('provider', 'ewr_discord');
            $repo->rebuildUserConnectedAccountCache($connectedAccount->User);
        }
     
        $db->commit();
     
        $next = end($userIds);
     
        return [
            $next,
            "{$next} / {$stepParams['max']}",
            $stepParams
        ];
    }

This is untested, but I don't see why it wouldn't work. If it comes down to it, I'll test it on the live site running this add-on as that site certainly cannot afford to lose all associations.

EDIT: Made some tweaks based on further reading of the code
 
Last edited:
Jaxel updated XF2 [8WR] Discord Integration with a new update entry:
Unfortunately, we can't just rename connected accounts and call it a day. ALL users will be required to reconnect their discord accounts to their forum accounts. Previous connected accounts with Discord will be deleted with this upgrade in order to prevent email clashes as well. That's just the way it is. Not much that can be done about it.

Deleting member accounts is not okay. Please consider changing this update so that it does not delete member accounts.

Destroying existing links is also not okay. It took me months to get everyone properly linked up on my forum - forcing everyone to re-link is a big problem too.

Please re-consider this update. There has to be a way to be compliant with xenoforo guidelines without deleting member accounts or forcing everyone to re-link.
 
Last edited:
You can, actually :)

I took the liberty of writing the upgrade method for you:
PHP:
    public function upgrade2111Step1(array $stepParams)
    {
        $position = empty($stepParams[0]) ? 0 : $stepParams[0];
        $perPage = 250;
    
        $db = $this->db();
    
        if (!isset($stepParams['max']))
        {
            $stepParams['max'] = $db->fetchOne("
                SELECT MAX(user_id)
                FROM xf_user_connected_account
                WHERE provider = 'discord'
            ");
        }
    
        $userIds = $db->fetchAllColumn($db->limit(
            "
                SELECT DISTINCT user_id
                FROM xf_user_connected_account
                WHERE user_id > ?
                    AND provider = 'discord'
                ORDER BY user_id
            ", $perPage
        ), $position);
        if (!$userIds)
        {
            return true;
        }
    
        $db->beginTransaction();

        $repo = \XF::repository('XF:ConnectedAccount');
    
        $connectedAccounts = \XF::finder('XF:UserConnectedAccount')->where('user_id', $userIds)->with(['User'])->fetch();
        foreach ($connectedAccounts as $connectedAccount)
        {
            $connectedAccount->fastUpdate('provider', 'ewr_discord');
            $repo->rebuildUserConnectedAccountCache($connectedAccount->User);
        }
    
        $db->commit();
    
        $next = end($userIds);
    
        return [
            $next,
            "{$next} / {$stepParams['max']}",
            $stepParams
        ];
    }

This is untested, but I don't see why it wouldn't work. If it comes down to it, I'll test it on the live site running this add-on as that site certainly cannot afford to lose all associations.

EDIT: Made some tweaks based on further reading of the code
Okay, I've replaced the upgrade step with your code.
 
You can, actually :)
I actually had to make slight tweaks to your code. Your code only worked on forums which only used Discord. If they used facebook, twitter, google, etc as well, it had issues.
Code:
    public function upgrade2111Step1(array $stepParams)
    {
        $position = empty($stepParams[0]) ? 0 : $stepParams[0];
        $perPage = 250;
    
        $db = $this->db();
    
        if (!isset($stepParams['max']))
        {
            $stepParams['max'] = $db->fetchOne("
                SELECT MAX(user_id)
                FROM xf_user_connected_account
                WHERE provider = 'discord'
            ");
        }
    
        $userIds = $db->fetchAllColumn($db->limit("
                SELECT DISTINCT user_id
                FROM xf_user_connected_account
                WHERE user_id > ?
                    AND provider = 'discord'
                ORDER BY user_id
            ", $perPage
        ), $position);
        
        if (!$userIds) { return true; }
    
        $db->beginTransaction();
    
        $connectedAccounts = \XF::finder('XF:UserConnectedAccount')->where([
            ['user_id', $userIds],
            ['provider', 'discord']
        ])->with(['User'])->fetch();
        
        $repo = \XF::repository('XF:ConnectedAccount');
        foreach ($connectedAccounts as $connectedAccount)
        {
            $connectedAccount->fastUpdate('provider', 'ewr_discord');
            $repo->rebuildUserConnectedAccountCache($connectedAccount->User);
        }
        
        $db->commit();
    
        $next = end($userIds);
        return [$next, "{$next} / {$stepParams['max']}", $stepParams];
    }
 
Do you plan to also fix it so it won't delete our member accounts?
We can't really upgrade while there's a risk that member accounts will be deleted by the upgrade.
That's what the current 2.1.1.1 does. Download the most recent version.
 
That's what the current 2.1.1.1 does. Download the most recent version.
I used the update link you emailed us.
It resulted in a broken install. Not only was every linked user delinked, but the link page did not even work correctly. It displayed buttons with broken text like "con_acc_desc.discord"to users.
 
Last edited:
I am on 2.1.1.1, opening the Discord Log within the Admin panel gives me this:

ErrorException: [E_WARNING] Invalid argument supplied for foreach() in src/addons/EWR/Discord/Repository/Log.php at line 36

XF::handlePhpError() in src/addons/EWR/Discord/Repository/Log.php at line 36
EWR\Discord\Repository\Log->groupLogs() in src/addons/EWR/Discord/Admin/Controller/Log.php at line 50
EWR\Discord\Admin\Controller\Log->actionDiscord() in src/XF/Mvc/Dispatcher.php at line 350
XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 257
XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 113
XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 55
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2184
XF\App->run() in src/XF.php at line 391
XF::runApp() in admin.php at line 13
 
I just upgraded and don't have the option to link Discord in connected accounts..

1580235260479.webp

Provider options are blank

1580235274464.webp

How do I fix this?
 
Did you guys run the upgrade script? It should be looking for con_acc.ewr_discord, not con_acc.discord. Try rebuilding the addon.
 
Can you go into your DB, and into the table xf_connected_account_provider. Rename discord to ewr_discord and tell me if that fixess it.

I forgot to put that line in the upgrade script.
 
Hello,

After the update, it appears that my bot isn't sending private messages to people to notify them of forum conversations. I didn't notice anything regarding that on the change log. No error logs for the add-on. I confirmed that all token and keys are correct for the bot.

The bot still posts when a thread/etc is made in a forum, but its just not sending private messages as it used to.

As a note, running recommended PHP etc.

Any help is appreciated. Thanks!
 
Top Bottom