Previous message may not be present when deleted
This commit is contained in:
commit
b5df3a70bc
26
v1/client.go
26
v1/client.go
@ -541,15 +541,15 @@ func (c *MgClient) AckMessage(request AckMessageRequest) (int, error) {
|
|||||||
// 10,
|
// 10,
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// data, status, err := client.DeleteMessage(msg)
|
// previousChatMessage, status, err := client.DeleteMessage(msg)
|
||||||
//
|
|
||||||
// if err != nil {
|
// if err != nil {
|
||||||
// fmt.Printf("%v", err)
|
// fmt.Printf("%v", err)
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// fmt.Printf("%s\n", data.MessageID)
|
// if previousChatMessage != nil {
|
||||||
func (c *MgClient) DeleteMessage(request DeleteData) (MessagesResponse, int, error) {
|
// fmt.Printf("Previous chat message id = %d", previousChatMessage.MessageID)
|
||||||
var resp MessagesResponse
|
// }
|
||||||
|
func (c *MgClient) DeleteMessage(request DeleteData) (*MessagesResponse, int, error) {
|
||||||
outgoing, _ := json.Marshal(&request)
|
outgoing, _ := json.Marshal(&request)
|
||||||
|
|
||||||
data, status, err := c.DeleteRequest(
|
data, status, err := c.DeleteRequest(
|
||||||
@ -557,18 +557,18 @@ func (c *MgClient) DeleteMessage(request DeleteData) (MessagesResponse, int, err
|
|||||||
[]byte(outgoing),
|
[]byte(outgoing),
|
||||||
)
|
)
|
||||||
if err != nil {
|
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 {
|
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
|
// GetFile implement get file url
|
||||||
|
@ -486,13 +486,16 @@ func TestMgClient_MarkMessageReadAndDelete(t *testing.T) {
|
|||||||
channelID,
|
channelID,
|
||||||
}
|
}
|
||||||
|
|
||||||
data, status, err := c.DeleteMessage(sndD)
|
previousChatMessage, status, err := c.DeleteMessage(sndD)
|
||||||
|
|
||||||
if status != http.StatusOK {
|
if status != http.StatusOK {
|
||||||
t.Errorf("%v", err)
|
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{
|
sndD = DeleteData{
|
||||||
Message{
|
Message{
|
||||||
@ -501,13 +504,16 @@ func TestMgClient_MarkMessageReadAndDelete(t *testing.T) {
|
|||||||
channelID,
|
channelID,
|
||||||
}
|
}
|
||||||
|
|
||||||
data, status, err = c.DeleteMessage(sndD)
|
previousChatMessage, status, err = c.DeleteMessage(sndD)
|
||||||
|
|
||||||
if status != http.StatusOK {
|
if status != http.StatusOK {
|
||||||
t.Errorf("%v", err)
|
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) {
|
func TestMgClient_DeactivateTransportChannel(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user