reply APIs
This commit is contained in:
parent
ed72e63e03
commit
ce16e12f8a
@ -200,8 +200,7 @@ func (c Channels) PatchChannel(
|
|||||||
// items
|
// items
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
// GetItem retrieves a Messageable item. If the item contains an attachment, that
|
// GetItem retrieves a Messageable item.
|
||||||
// attachment is also downloaded.
|
|
||||||
func (c Channels) GetItem(
|
func (c Channels) GetItem(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
teamID, channelID, itemID string,
|
teamID, channelID, itemID string,
|
||||||
@ -218,9 +217,9 @@ func (c Channels) GetItem(
|
|||||||
Teams().
|
Teams().
|
||||||
ByTeamId(teamID).
|
ByTeamId(teamID).
|
||||||
Channels().
|
Channels().
|
||||||
ByChannelId(itemID).
|
ByChannelId(channelID).
|
||||||
Messages().
|
Messages().
|
||||||
ByChatMessageId("").
|
ByChatMessageId(itemID).
|
||||||
Get(ctx, nil)
|
Get(ctx, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, graph.Stack(ctx, err)
|
return nil, nil, graph.Stack(ctx, err)
|
||||||
@ -280,6 +279,87 @@ func (c Channels) DeleteItem(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// replies
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// GetItem retrieves a Messageable item.
|
||||||
|
func (c Channels) GetReplies(
|
||||||
|
ctx context.Context,
|
||||||
|
teamID, channelID, itemID string,
|
||||||
|
) (serialization.Parsable, error) {
|
||||||
|
replies, err := c.Stable.
|
||||||
|
Client().
|
||||||
|
Teams().
|
||||||
|
ByTeamId(teamID).
|
||||||
|
Channels().
|
||||||
|
ByChannelId(channelID).
|
||||||
|
Messages().
|
||||||
|
ByChatMessageId(itemID).
|
||||||
|
Replies().
|
||||||
|
Get(ctx, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, graph.Stack(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return replies, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Channels) PostReply(
|
||||||
|
ctx context.Context,
|
||||||
|
teamID, containerID, messageID string,
|
||||||
|
body models.ChatMessageable,
|
||||||
|
) (models.ChatMessageable, error) {
|
||||||
|
itm, err := c.Stable.
|
||||||
|
Client().
|
||||||
|
Teams().
|
||||||
|
ByTeamId(teamID).
|
||||||
|
Channels().
|
||||||
|
ByChannelId(containerID).
|
||||||
|
Messages().
|
||||||
|
ByChatMessageId(messageID).
|
||||||
|
Replies().
|
||||||
|
Post(ctx, body, nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, graph.Wrap(ctx, err, "creating reply message")
|
||||||
|
}
|
||||||
|
|
||||||
|
if itm == nil {
|
||||||
|
return nil, clues.New("nil response reply to message creation").WithClues(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
return itm, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Channels) DeleteReply(
|
||||||
|
ctx context.Context,
|
||||||
|
teamID, itemID, containerID, replyID string,
|
||||||
|
) error {
|
||||||
|
// deletes require unique http clients
|
||||||
|
// https://github.com/alcionai/corso/issues/2707
|
||||||
|
srv, err := NewService(c.Credentials)
|
||||||
|
if err != nil {
|
||||||
|
return graph.Stack(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = srv.
|
||||||
|
Client().
|
||||||
|
Teams().
|
||||||
|
ByTeamId(teamID).
|
||||||
|
Channels().
|
||||||
|
ByChannelId(containerID).
|
||||||
|
Messages().
|
||||||
|
ByChatMessageId(itemID).
|
||||||
|
Replies().
|
||||||
|
ByChatMessageId1(replyID).
|
||||||
|
Delete(ctx, nil)
|
||||||
|
if err != nil {
|
||||||
|
return graph.Wrap(ctx, err, "deleting mail message")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Helpers
|
// Helpers
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user