GetStream / stream-chat-php

Stream Chat official PHP API Client
https://getstream.io/chat/
BSD 3-Clause "New" or "Revised" License
30 stars 9 forks source link

Unflag message not working. #53

Closed rebeccamcdougal closed 3 years ago

rebeccamcdougal commented 3 years ago

I'm using the queryMessageFlags call to get a list of flagged messages, but if I then try to use the unFlagMessage call to unflag the message that was just returned it fails with the error 'Unflag failed with error: "message xxxxxxx is not flagged"'

gz#12408

shodgetts commented 3 years ago

Agent comment from Zachery Converse in Zendesk ticket #12408:

Hi Rebecca,

Thanks for reaching out. Let me take a look into this and get back to you, soon.

Cheers, -Zachery Getstream.io

°°°

shodgetts commented 3 years ago

Agent comment from Zachery Converse in Zendesk ticket #12408:

Hi Rebecca,

unflagMeaage takes a string messageId - are you able to confirm that this is what is being passed? A code snippet would be super helpful if you're able to provide one. Feel free to provide any additional information that may help debug as well.

Cheers, -Zachery Getstream.io

°°°

rebeccamcdougal commented 3 years ago

Yes a string with a valid message id is being passed in. This is the code I'm using

$flagged_messages = $client->queryMessageFlags(["channel_cid" => "messaging:channel_105634751"]);

foreach ($flagged_messages['flags'] as $item) {
  $flag = $client->unFlagMessage($item['message']['id'], ['user_id' => 'user_10']);
}

This is the error

Error: [GetStream\StreamChat\StreamException] {"code":4,"message":"Unflag failed with error: \"message e73fd62b-c432-489b-8a63-73e089e53980 is not flaged\"","StatusCode":400,"duration":"0.00ms","more_info":"https://getstream.io/chat/docs/api_errors_response"}

ferhatelmas commented 3 years ago

@rebeccamcdougal You get all flags (message+user pair) but then you try to remove flag from a specific user. There flag can be from a different user so you need to use user id of the flag to remove it i.e. $client->unFlagMessage($item['message']['id'], ['user_id' => $item['user']['id']);

rebeccamcdougal commented 3 years ago

So would that mean that there isn't a way to unflag those that were flagged by the AI, so flagged_by_automod set to true?

ferhatelmas commented 3 years ago

That's correct as current behavior. Checking with PM to permit it or not. Stay tuned, please!