remove extra methods
This commit is contained in:
parent
63080485a8
commit
07e772ee0e
@ -37,8 +37,8 @@ const (
|
|||||||
// Folder Management(30x)
|
// Folder Management(30x)
|
||||||
FolderItem ItemType = 306
|
FolderItem ItemType = 306
|
||||||
|
|
||||||
// GroupChannel(40x)
|
// GroupChannelMessage(40x)
|
||||||
GroupChannel ItemType = 407
|
GroupChannelMessage ItemType = 407
|
||||||
)
|
)
|
||||||
|
|
||||||
func UpdateItem(item *ItemInfo, newLocPath *path.Builder) {
|
func UpdateItem(item *ItemInfo, newLocPath *path.Builder) {
|
||||||
|
|||||||
@ -56,23 +56,11 @@ func (c Channels) GetChannel(
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c Channels) GetChannelByID(
|
|
||||||
ctx context.Context,
|
|
||||||
teamID, containerID string,
|
|
||||||
) (graph.Container, error) {
|
|
||||||
channel, err := c.GetChannel(ctx, teamID, containerID)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return ChannelsDisplayable{Channelable: channel}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetChannelByName fetches a channel by name
|
// GetChannelByName fetches a channel by name
|
||||||
func (c Channels) GetChannelByName(
|
func (c Channels) GetChannelByName(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
teamID, containerName string,
|
teamID, containerName string,
|
||||||
) (graph.Container, error) {
|
) (models.Channelable, error) {
|
||||||
ctx = clues.Add(ctx, "channel_name", containerName)
|
ctx = clues.Add(ctx, "channel_name", containerName)
|
||||||
|
|
||||||
filter := fmt.Sprintf("displayName eq '%s'", containerName)
|
filter := fmt.Sprintf("displayName eq '%s'", containerName)
|
||||||
@ -94,7 +82,6 @@ func (c Channels) GetChannelByName(
|
|||||||
}
|
}
|
||||||
|
|
||||||
gv := resp.GetValue()
|
gv := resp.GetValue()
|
||||||
|
|
||||||
if len(gv) == 0 {
|
if len(gv) == 0 {
|
||||||
return nil, clues.New("channel not found").WithClues(ctx)
|
return nil, clues.New("channel not found").WithClues(ctx)
|
||||||
}
|
}
|
||||||
@ -105,31 +92,28 @@ func (c Channels) GetChannelByName(
|
|||||||
|
|
||||||
// Sanity check ID and name
|
// Sanity check ID and name
|
||||||
cal := gv[0]
|
cal := gv[0]
|
||||||
container := ChannelsDisplayable{Channelable: cal}
|
|
||||||
|
|
||||||
if err := graph.CheckIDAndName(container); err != nil {
|
if err := CheckIDAndName(cal); err != nil {
|
||||||
return nil, clues.Stack(err).WithClues(ctx)
|
return nil, clues.Stack(err).WithClues(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
return container, nil
|
return cal, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// message
|
// message
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
// GetItem retrieves a Messageable item.
|
// GetMessage retrieves a ChannelMessage item.
|
||||||
func (c Channels) GetMessage(
|
func (c Channels) GetMessage(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
teamID, channelID, itemID string,
|
teamID, channelID, itemID string,
|
||||||
immutableIDs bool,
|
|
||||||
errs *fault.Bus,
|
errs *fault.Bus,
|
||||||
) (serialization.Parsable, *details.GroupsInfo, error) {
|
) (serialization.Parsable, *details.GroupsInfo, error) {
|
||||||
var (
|
var (
|
||||||
size int64
|
size int64
|
||||||
)
|
)
|
||||||
|
|
||||||
// is preferImmutableIDs headers required here
|
|
||||||
message, err := c.Stable.
|
message, err := c.Stable.
|
||||||
Client().
|
Client().
|
||||||
Teams().
|
Teams().
|
||||||
@ -182,7 +166,7 @@ func ChannelMessageInfo(msg models.ChatMessageable, size int64) *details.GroupsI
|
|||||||
)
|
)
|
||||||
|
|
||||||
return &details.GroupsInfo{
|
return &details.GroupsInfo{
|
||||||
ItemType: details.GroupChannel,
|
ItemType: details.GroupChannelMessage,
|
||||||
Size: size,
|
Size: size,
|
||||||
Created: created,
|
Created: created,
|
||||||
Modified: ptr.OrNow(msg.GetLastModifiedDateTime()),
|
Modified: ptr.OrNow(msg.GetLastModifiedDateTime()),
|
||||||
@ -193,16 +177,22 @@ func ChannelMessageInfo(msg models.ChatMessageable, size int64) *details.GroupsI
|
|||||||
// helper funcs
|
// helper funcs
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
// ChannelsDisplayable is a wrapper that complies with the
|
// CheckIDAndName is a validator that ensures the ID
|
||||||
// models.Channelable interface with the graph.Container
|
// and name are populated and not zero valued.
|
||||||
// interfaces.
|
func CheckIDAndName(c models.Channelable) error {
|
||||||
type ChannelsDisplayable struct {
|
if c == nil {
|
||||||
models.Channelable
|
return clues.New("nil container")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetParentFolderId returns the default channe name address
|
id := ptr.Val(c.GetId())
|
||||||
|
if len(id) == 0 {
|
||||||
|
return clues.New("container missing ID")
|
||||||
|
}
|
||||||
|
|
||||||
|
dn := ptr.Val(c.GetDisplayName())
|
||||||
|
if len(dn) == 0 {
|
||||||
|
return clues.New("container missing display name").With("container_id", id)
|
||||||
|
}
|
||||||
|
|
||||||
//nolint:revive
|
|
||||||
func (c ChannelsDisplayable) GetParentFolderId() *string {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user