feat(jobs/runners): attachment cleanup + chat DeleteAttachments query/method

This commit is contained in:
2026-05-06 08:07:49 +08:00
parent c50621eeca
commit f56fe449fd
7 changed files with 193 additions and 0 deletions
+15
View File
@@ -58,6 +58,7 @@ type Repository interface {
ListExpiredOrphans(ctx context.Context, olderThan time.Duration) ([]AttachmentRef, error)
ListAttachmentsForSoftDeletedConversations(ctx context.Context, olderThan time.Duration) ([]AttachmentRef, error)
DeleteAttachment(ctx context.Context, id uuid.UUID) error
DeleteAttachments(ctx context.Context, ids []uuid.UUID) error
// ===== PromptTemplate =====
InsertPromptTemplate(ctx context.Context, p InsertTemplateParams) (*PromptTemplate, error)
@@ -778,6 +779,20 @@ func (r *pgRepo) DeleteAttachment(ctx context.Context, id uuid.UUID) error {
return nil
}
func (r *pgRepo) DeleteAttachments(ctx context.Context, ids []uuid.UUID) error {
if len(ids) == 0 {
return nil
}
pgIDs := make([]pgtype.UUID, len(ids))
for i, id := range ids {
pgIDs[i] = toPgUUID(id)
}
if err := r.q.DeleteAttachmentsByIDs(ctx, pgIDs); err != nil {
return errs.Wrap(err, errs.CodeInternal, "delete attachments")
}
return nil
}
// ===== PromptTemplate =====
func (r *pgRepo) InsertPromptTemplate(ctx context.Context, p InsertTemplateParams) (*PromptTemplate, error) {