1
0
mirror of synced 2024-11-24 22:16:05 +03:00

Previous message may not be present when deleted

This commit is contained in:
Alex Lushpai 2021-07-27 15:57:22 +03:00 committed by GitHub
commit b5df3a70bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 17 deletions

View File

@ -541,15 +541,15 @@ func (c *MgClient) AckMessage(request AckMessageRequest) (int, error) {
// 10,
// }
//
// data, status, err := client.DeleteMessage(msg)
//
// previousChatMessage, status, err := client.DeleteMessage(msg)
// if err != nil {
// fmt.Printf("%v", err)
// }
//
// fmt.Printf("%s\n", data.MessageID)
func (c *MgClient) DeleteMessage(request DeleteData) (MessagesResponse, int, error) {
var resp MessagesResponse
// if previousChatMessage != nil {
// fmt.Printf("Previous chat message id = %d", previousChatMessage.MessageID)
// }
func (c *MgClient) DeleteMessage(request DeleteData) (*MessagesResponse, int, error) {
outgoing, _ := json.Marshal(&request)
data, status, err := c.DeleteRequest(
@ -557,18 +557,18 @@ func (c *MgClient) DeleteMessage(request DeleteData) (MessagesResponse, int, err
[]byte(outgoing),
)
if err != nil {
return resp, status, err
return nil, status, err
}
if e := json.Unmarshal(data, &resp); e != nil {
return resp, status, e
}
if status != http.StatusOK {
return resp, status, c.Error(data)
return nil, status, c.Error(data)
}
return resp, status, err
var previousChatMessage *MessagesResponse
if e := json.Unmarshal(data, &previousChatMessage); e != nil {
return nil, status, e
}
return previousChatMessage, status, nil
}
// GetFile implement get file url

View File

@ -486,13 +486,16 @@ func TestMgClient_MarkMessageReadAndDelete(t *testing.T) {
channelID,
}
data, status, err := c.DeleteMessage(sndD)
previousChatMessage, status, err := c.DeleteMessage(sndD)
if status != http.StatusOK {
t.Errorf("%v", err)
}
t.Logf("Message %v deleted", data.MessageID)
t.Logf("Message %v deleted", ext)
if previousChatMessage != nil {
t.Logf("Previous chat message %+v", *previousChatMessage)
}
sndD = DeleteData{
Message{
@ -501,13 +504,16 @@ func TestMgClient_MarkMessageReadAndDelete(t *testing.T) {
channelID,
}
data, status, err = c.DeleteMessage(sndD)
previousChatMessage, status, err = c.DeleteMessage(sndD)
if status != http.StatusOK {
t.Errorf("%v", err)
}
t.Logf("Message %v deleted", data.MessageID)
t.Logf("Message %v deleted", ext+"file")
if previousChatMessage != nil {
t.Logf("Previous chat message %+v", *previousChatMessage)
}
}
func TestMgClient_DeactivateTransportChannel(t *testing.T) {