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

Method GetChatFileByID

coderd/database/dbauthz/dbauthz.go:2998–3020  ·  view source on GitHub ↗
(ctx context.Context, id uuid.UUID)

Source from the content-addressed store, hash-verified

2996}
2997
2998func (q *querier) GetChatFileByID(ctx context.Context, id uuid.UUID) (database.ChatFile, error) {
2999 file, err := q.db.GetChatFileByID(ctx, id)
3000 if err != nil {
3001 return database.ChatFile{}, err
3002 }
3003 fileAuthErr := q.authorizeContext(ctx, policy.ActionRead, file)
3004 if fileAuthErr == nil {
3005 return file, nil
3006 }
3007
3008 prepared, err := prepareSQLFilter(ctx, q.auth, policy.ActionRead, rbac.ResourceChat.Type)
3009 if err != nil {
3010 return database.ChatFile{}, xerrors.Errorf("(dev error) prepare sql filter: %w", err)
3011 }
3012 chats, err := q.db.GetAuthorizedChatsByChatFileID(ctx, id, prepared)
3013 if err != nil {
3014 return database.ChatFile{}, err
3015 }
3016 if len(chats) == 0 {
3017 return database.ChatFile{}, fileAuthErr
3018 }
3019 return file, nil
3020}
3021
3022func (q *querier) GetChatFileMetadataByChatID(ctx context.Context, chatID uuid.UUID) ([]database.GetChatFileMetadataByChatIDRow, error) {
3023 if _, err := q.GetChatByID(ctx, chatID); err != nil {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected