warlof / seat-connector

Provide basic layer for SeAT connectors
GNU General Public License v3.0
1 stars 12 forks source link

Discord max nick length of 32 characters #32

Closed lk77 closed 4 years ago

lk77 commented 4 years ago

Hello,

discord has a max nick length of 32 characters, the connector should cut the IG nickname if it's too long for discord.

[2020-05-21 11:40:15] production.ERROR: Client error: `PUT https://discordapp.com/api/guilds/***/members/***` resulted in a `400 Bad Request` response:
{"nick": ["Must be 32 or fewer in length."]}
 {"userId":***,"email":"***","exception":"[object] (GuzzleHttp\\Exception\\ClientException(code: 400): Client error: `PUT https://discordapp.com/api/guilds/***/members/***` resulted in a `400 Bad Request` response:
{\"nick\": [\"Must be 32 or fewer in length.\"]}
 at /var/www/seat/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113)
[stacktrace]
#0 /var/www/seat/vendor/guzzlehttp/guzzle/src/Middleware.php(65): GuzzleHttp\\Exception\\RequestException::create(Object(GuzzleHttp\\Psr7\\Request), Object(GuzzleHttp\\Psr7\\Response))
#1 /var/www/seat/vendor/guzzlehttp/promises/src/Promise.php(203): GuzzleHttp\\Middleware::GuzzleHttp\\{closure}(Object(GuzzleHttp\\Psr7\\Response))
#2 /var/www/seat/vendor/guzzlehttp/promises/src/Promise.php(156): GuzzleHttp\\Promise\\Promise::callHandler(1, Object(GuzzleHttp\\Psr7\\Response), Array)
#3 /var/www/seat/vendor/guzzlehttp/promises/src/TaskQueue.php(47): GuzzleHttp\\Promise\\Promise::GuzzleHttp\\Promise\\{closure}()
#4 /var/www/seat/vendor/guzzlehttp/promises/src/Promise.php(246): GuzzleHttp\\Promise\\TaskQueue->run(true)
#5 /var/www/seat/vendor/guzzlehttp/promises/src/Promise.php(223): GuzzleHttp\\Promise\\Promise->invokeWaitFn()
#6 /var/www/seat/vendor/guzzlehttp/promises/src/Promise.php(267): GuzzleHttp\\Promise\\Promise->waitIfPending()
#7 /var/www/seat/vendor/guzzlehttp/promises/src/Promise.php(225): GuzzleHttp\\Promise\\Promise->invokeWaitList()
#8 /var/www/seat/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\\Promise\\Promise->waitIfPending()
#9 /var/www/seat/vendor/guzzlehttp/guzzle/src/Client.php(183): GuzzleHttp\\Promise\\Promise->wait()
#10 /var/www/seat/vendor/warlof/seat-discord-connector/src/Driver/DiscordClient.php(268): GuzzleHttp\\Client->request('PUT', 'guilds/60089847...', Array)

Thanks.

warlof commented 4 years ago

hello there,

it is the case https://github.com/warlof/seat-discord-connector/blob/4.0.4/src/Driver/DiscordMember.php#L107 Which versions of seat-connector and seat-discord-connector are you using ?

lk77 commented 4 years ago

Hello,

i use warlof/seat-discord-connector 4.0.4 and warlof/seat-connector 1.4.4

for me the issue seems to be in this method: https://github.com/warlof/seat-discord-connector/blob/4.0.4/src/Driver/DiscordClient.php#L231

i've done a dd of $arguments :

array:3 [▼
  "nick" => "*** (34 characters)"
  "roles" => array:6[...]
  "access_token" => "***"
]

Edit :

And also i have another issue with sendCall method, i was force to add a try catch, because there was an error on discord :

if ($method == 'GET') {
            $response = $this->client->request($method, $uri, [
                'query' => $arguments,
            ]);
        } else {
            try {
                $response = $this->client->request($method, $uri, [
                    'body' => json_encode($arguments),
                ]);
            } catch(\Exception $e) {
            }
        }
#message: """
    Client error: `PATCH https://discordapp.com/api/guilds/***/members/***` resulted in a `404 Not Found` response:\n
    {"message": "Unknown Member", "code": 10007}\n
    """
warlof commented 4 years ago

sendCall is only sending requests. If there is an error, it's upper in the stack.

When did you get the error exactly ?

lk77 commented 4 years ago

A user tried to link their discord to their seat account but, it was unsucessful, i don't know why.

warlof commented 4 years ago

I finally found it, should be fixed with v4.0.5. It was part of the registration specific flow.

akturis commented 4 years ago

In updateUserProfile need a small change As is $profile->connector_name = $nickname; To be $profile->connector_name = $user->getName();

warlof commented 4 years ago

Sounds legit Can you open a pull request please?

akturis commented 4 years ago

Pull request is opened #33

lk77 commented 4 years ago

thanks