MCPcopy Index your code
hub / github.com/coder/coder / GetChatFilesByIDs

Method GetChatFilesByIDs

coderd/database/dbauthz/dbauthz.go:3029–3055  ·  view source on GitHub ↗
(ctx context.Context, ids []uuid.UUID)

Source from the content-addressed store, hash-verified

3027}
3028
3029func (q *querier) GetChatFilesByIDs(ctx context.Context, ids []uuid.UUID) ([]database.ChatFile, error) {
3030 files, err := q.db.GetChatFilesByIDs(ctx, ids)
3031 if err != nil {
3032 return nil, err
3033 }
3034 var prepared rbac.PreparedAuthorized
3035 for _, f := range files {
3036 fileAuthErr := q.authorizeContext(ctx, policy.ActionRead, f)
3037 if fileAuthErr == nil {
3038 continue
3039 }
3040 if prepared == nil {
3041 prepared, err = prepareSQLFilter(ctx, q.auth, policy.ActionRead, rbac.ResourceChat.Type)
3042 if err != nil {
3043 return nil, xerrors.Errorf("(dev error) prepare sql filter: %w", err)
3044 }
3045 }
3046 chats, err := q.db.GetAuthorizedChatsByChatFileID(ctx, f.ID, prepared)
3047 if err != nil {
3048 return nil, err
3049 }
3050 if len(chats) == 0 {
3051 return nil, fileAuthErr
3052 }
3053 }
3054 return files, nil
3055}
3056
3057func (q *querier) GetChatGeneralModelOverride(ctx context.Context) (string, error) {
3058 if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceDeploymentConfig); err != nil {

Callers

nothing calls this directly

Calls 5

authorizeContextMethod · 0.95
prepareSQLFilterFunction · 0.85
GetChatFilesByIDsMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected