Compare commits
24 Commits
main
...
channelPag
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbd62c8b0c | ||
|
|
202c796896 | ||
|
|
89edc583a3 | ||
|
|
a9372af65c | ||
|
|
397526c4c8 | ||
|
|
84440ade4d | ||
|
|
79ef5a56fc | ||
|
|
39006d2cef | ||
|
|
0d811278b7 | ||
|
|
deacf812ca | ||
|
|
0dfb1b1d4d | ||
|
|
5fffb5cfb8 | ||
|
|
21d8ec9d4a | ||
|
|
93607f5cd5 | ||
|
|
07e772ee0e | ||
|
|
63080485a8 | ||
|
|
27990e6174 | ||
|
|
7de04b98ab | ||
|
|
aef4c688ac | ||
|
|
54d5e05950 | ||
|
|
5fbc37fbc1 | ||
|
|
d1f0d683af | ||
|
|
fa1a432a87 | ||
|
|
8d4277b1c7 |
@ -3,6 +3,7 @@ package api
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/alcionai/clues"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
"github.com/microsoftgraph/msgraph-sdk-go/models"
|
||||||
"github.com/microsoftgraph/msgraph-sdk-go/teams"
|
"github.com/microsoftgraph/msgraph-sdk-go/teams"
|
||||||
|
|
||||||
@ -79,6 +80,130 @@ func (c Channels) NewChannelMessageDeltaPager(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// var _ ChannelMessageDeltaEnumerator = &ChannelMessageDeltaPageCtrl{}
|
||||||
|
var _ Pager[models.Channelable] = &channelPageCtrl{}
|
||||||
|
|
||||||
|
type ChannelMessageDeltaPageCtrl struct {
|
||||||
|
gs graph.Servicer
|
||||||
|
builder *teams.ItemChannelsItemMessagesDeltaRequestBuilder
|
||||||
|
options *teams.ItemChannelsItemMessagesDeltaRequestBuilderGetRequestConfiguration
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Channels) NewMessagePager(
|
||||||
|
teamID, channelID string,
|
||||||
|
fields []string,
|
||||||
|
) *ChannelMessageDeltaPageCtrl {
|
||||||
|
res := &ChannelMessageDeltaPageCtrl{
|
||||||
|
gs: c.Stable,
|
||||||
|
options: nil,
|
||||||
|
builder: c.Stable.
|
||||||
|
Client().
|
||||||
|
Teams().
|
||||||
|
ByTeamId(teamID).
|
||||||
|
Channels().
|
||||||
|
ByChannelId(channelID).
|
||||||
|
Messages().
|
||||||
|
Delta(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *ChannelMessageDeltaPageCtrl) SetNext(nextLink string) {
|
||||||
|
p.builder = teams.NewItemChannelsItemMessagesDeltaRequestBuilder(nextLink, p.gs.Adapter())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *ChannelMessageDeltaPageCtrl) GetPage(ctx context.Context) (DeltaPageLinker, error) {
|
||||||
|
var (
|
||||||
|
resp DeltaPageLinker
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
resp, err = p.builder.Get(ctx, p.options)
|
||||||
|
if err != nil {
|
||||||
|
return nil, graph.Stack(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *ChannelMessageDeltaPageCtrl) ValuesIn(l PageLinker) ([]models.ChatMessageable, error) {
|
||||||
|
return getValues[models.ChatMessageable](l)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// non delta channel message pager
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
type MessageItemIDType struct {
|
||||||
|
ItemID string
|
||||||
|
}
|
||||||
|
|
||||||
|
type channelMessagePageCtrl struct {
|
||||||
|
gs graph.Servicer
|
||||||
|
builder *teams.ItemChannelsItemMessagesRequestBuilder
|
||||||
|
options *teams.ItemChannelsItemMessagesRequestBuilderGetRequestConfiguration
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Channels) GetItemIDsInContainer(
|
||||||
|
ctx context.Context,
|
||||||
|
teamID, channelID string,
|
||||||
|
) (map[string]struct{}, error) {
|
||||||
|
ctx = clues.Add(ctx, "channel_id", channelID)
|
||||||
|
pager := c.NewChannelItemPager(teamID, channelID)
|
||||||
|
|
||||||
|
items, err := enumerateItems(ctx, pager)
|
||||||
|
if err != nil {
|
||||||
|
return nil, graph.Wrap(ctx, err, "enumerating contacts")
|
||||||
|
}
|
||||||
|
|
||||||
|
m := map[string]struct{}{}
|
||||||
|
|
||||||
|
for _, item := range items {
|
||||||
|
m[ptr.Val(item.GetId())] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Channels) NewChannelItemPager(
|
||||||
|
teamID, containerID string,
|
||||||
|
selectProps ...string,
|
||||||
|
) itemPager[models.ChatMessageable] {
|
||||||
|
options := &teams.ItemChannelsItemMessagesRequestBuilderGetRequestConfiguration{
|
||||||
|
QueryParameters: &teams.ItemChannelsItemMessagesRequestBuilderGetQueryParameters{},
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(selectProps) > 0 {
|
||||||
|
options.QueryParameters.Select = selectProps
|
||||||
|
}
|
||||||
|
|
||||||
|
builder := c.Stable.
|
||||||
|
Client().
|
||||||
|
Teams().
|
||||||
|
ByTeamId(teamID).
|
||||||
|
Channels().
|
||||||
|
ByChannelId(containerID).
|
||||||
|
Messages()
|
||||||
|
|
||||||
|
return &channelMessagePageCtrl{c.Stable, builder, options}
|
||||||
|
}
|
||||||
|
|
||||||
|
//lint:ignore U1000 False Positive
|
||||||
|
func (p *channelMessagePageCtrl) getPage(ctx context.Context) (PageLinkValuer[models.ChatMessageable], error) {
|
||||||
|
page, err := p.builder.Get(ctx, p.options)
|
||||||
|
if err != nil {
|
||||||
|
return nil, graph.Stack(ctx, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return EmptyDeltaLinker[models.ChatMessageable]{PageLinkValuer: page}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
//lint:ignore U1000 False Positive
|
||||||
|
func (p *channelMessagePageCtrl) setNext(nextLink string) {
|
||||||
|
p.builder = teams.NewItemChannelsItemMessagesRequestBuilder(nextLink, p.gs.Adapter())
|
||||||
|
}
|
||||||
|
|
||||||
// GetChannelMessagesDelta fetches a delta of all messages in the channel.
|
// GetChannelMessagesDelta fetches a delta of all messages in the channel.
|
||||||
func (c Channels) GetChannelMessagesDelta(
|
func (c Channels) GetChannelMessagesDelta(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user