Compare commits

...

24 Commits

Author SHA1 Message Date
neha-Gupta1
fbd62c8b0c merge main 2023-08-31 14:40:24 +05:30
neha-Gupta1
202c796896 remove fields restriction from query 2023-08-31 12:10:27 +05:30
neha-Gupta1
89edc583a3 lint code 2023-08-25 14:47:31 +05:30
neha-Gupta1
a9372af65c Merge branch 'main' of https://github.com/alcionai/corso into channelPagerImplementation 2023-08-25 14:39:35 +05:30
neha-Gupta1
397526c4c8 channel pager implementation 2023-08-25 13:29:50 +05:30
aviator-app[bot]
84440ade4d
Merge branch 'main' into HandlerImplemenation 2023-08-25 07:22:08 +00:00
neha-Gupta1
79ef5a56fc Merge branch 'HandlerImplemenation' of https://github.com/alcionai/corso into HandlerImplemenation 2023-08-25 12:31:06 +05:30
neha-Gupta1
39006d2cef comment message update 2023-08-25 12:06:55 +05:30
neha_gupta
0d811278b7
Merge branch 'main' into HandlerImplemenation 2023-08-25 12:02:05 +05:30
neha-Gupta1
deacf812ca comments message update 2023-08-25 12:00:27 +05:30
neha-Gupta1
0dfb1b1d4d lint changes 2023-08-24 16:52:33 +05:30
neha-Gupta1
5fffb5cfb8 remove extra test func 2023-08-24 16:08:25 +05:30
neha-Gupta1
21d8ec9d4a remove extra test func 2023-08-24 16:06:10 +05:30
neha-Gupta1
93607f5cd5 merge main 2023-08-24 15:32:36 +05:30
neha-Gupta1
07e772ee0e remove extra methods 2023-08-23 19:16:41 +05:30
neha-Gupta1
63080485a8 remove YAGNI 2023-08-23 16:03:03 +05:30
neha-Gupta1
27990e6174 item pager for channels 2023-08-22 12:48:11 +05:30
neha-Gupta1
7de04b98ab test cases channel api 2023-08-22 10:19:36 +05:30
neha-Gupta1
aef4c688ac lint code 2023-08-18 23:34:31 +05:30
neha-Gupta1
54d5e05950 channels and messages API 2023-08-18 18:27:03 +05:30
neha-Gupta1
5fbc37fbc1 Merge branch 'main' of https://github.com/alcionai/corso into channelHandlers 2023-08-18 13:41:01 +05:30
neha-Gupta1
d1f0d683af message handler 2023-08-18 13:40:42 +05:30
neha-Gupta1
fa1a432a87 lint changes 2023-08-17 16:42:14 +05:30
neha-Gupta1
8d4277b1c7 add handers for channels 2023-08-17 16:24:38 +05:30

View File

@ -3,6 +3,7 @@ package api
import (
"context"
"github.com/alcionai/clues"
"github.com/microsoftgraph/msgraph-sdk-go/models"
"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.
func (c Channels) GetChannelMessagesDelta(
ctx context.Context,