ЛР4 - БВТ2303 - Голиков- на 4 #13

Closed
Maximillan_Mercer wants to merge 64 commits from Maximillan_Mercer/mtusi2026lab4-fork:solution/BVT2303-Golikov into main
Showing only changes of commit cace078c65 - Show all commits
@@ -208,6 +208,25 @@ func (r *MessageRepo) ListByChat(ctx context.Context, chatID string, limit int,
c := encodeCursor(scope, last.CreatedAt, last.ID)
next = &c
}
if len(page) > 0 {
msgIDs := make([]string, len(page))
for i := range page {
msgIDs[i] = page[i].ID
}
links, err := r.loadAttachmentIDs(ctx, msgIDs)
if err != nil {
return nil, nil, err
}
for i := range page {
if ids, ok := links[page[i].ID]; ok {
page[i].AttachmentIDs = ids
} else {
page[i].AttachmentIDs = []string{}
}
}
}
return page, next, nil
}