previous message may not be present when deleted
This commit is contained in:
parent
ebded3077b
commit
3cf31358d9
26
v1/client.go
26
v1/client.go
@ -543,15 +543,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(
|
||||
@ -559,18 +559,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
|
||||
|
@ -490,13 +490,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{
|
||||
@ -505,13 +508,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) {
|
||||
|
Loading…
Reference in New Issue
Block a user