Skip to content

Commit

Permalink
fix ambiguous container matches.
Browse files Browse the repository at this point in the history
  • Loading branch information
m1k1o committed Oct 25, 2023
1 parent a4734ff commit 0349af9
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion internal/room/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,12 @@ func (manager *RoomManagerCtx) Create(ctx context.Context, settings types.RoomSe
}

func (manager *RoomManagerCtx) GetEntry(ctx context.Context, id string) (*types.RoomEntry, error) {
// we don't support id shorter than 12 chars
// because they can be ambiguous
if len(id) < 12 {
return nil, types.ErrRoomNotFound
}

container, err := manager.containerById(ctx, id)
if err != nil {
return nil, err
Expand All @@ -706,7 +712,18 @@ func (manager *RoomManagerCtx) GetEntryByName(ctx context.Context, name string)
return nil, err
}

return manager.containerToEntry(*container)
roomEntry, err := manager.containerToEntry(*container)
if err != nil {
return nil, err
}

// we can match containers starting with given name
// but we want to match only exact name
if roomEntry.Name != name {
return nil, types.ErrRoomNotFound
}

return roomEntry, nil
}

func (manager *RoomManagerCtx) Remove(ctx context.Context, id string) error {
Expand Down

0 comments on commit 0349af9

Please sign in to comment.