feat: add TusHandler::Uploads

This commit is contained in:
Derrick Hammer 2024-03-28 17:43:32 -04:00
parent b267ace017
commit a54238d4b6
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 11 additions and 0 deletions

View File

@ -175,6 +175,17 @@ func (t *TusHandler) UploadExists(ctx context.Context, hash []byte) (bool, model
return result.RowsAffected > 0, upload
}
func (t *TusHandler) Uploads(ctx context.Context, uploaderID uint) ([]models.TusUpload, error) {
var uploads []models.TusUpload
result := t.db.WithContext(ctx).Model(&models.TusUpload{}).Where(&models.TusUpload{UploaderID: uploaderID}).Find(&uploads)
if result.Error != nil {
return nil, result.Error
}
return uploads, nil
}
func (t *TusHandler) CreateUpload(ctx context.Context, hash []byte, uploadID string, uploaderID uint, uploaderIP string, protocol string) (*models.TusUpload, error) {
upload := &models.TusUpload{
Hash: hash,