TP-61307 | Auth middileware and relase service changes
This commit is contained in:
@@ -21,9 +21,9 @@ type SourceMapService struct {
|
||||
}
|
||||
|
||||
type SourceMapAckBody struct {
|
||||
ProjectId string `json:"project-id" binding:"required"`
|
||||
ReleaseId string `json:"releaseId" binding:"required"`
|
||||
FileName string `json:"file_name" binding:"required"`
|
||||
ProjectReferenceId string `json:"projectId" binding:"required"`
|
||||
ReleaseId string `json:"releaseId" binding:"required"`
|
||||
FileName string `json:"fileName" binding:"required"`
|
||||
}
|
||||
|
||||
func NewSourceMapService(dbClient *gorm.DB, s3Client *aws.Actions, config *configs.AwsConfig) *SourceMapService {
|
||||
@@ -45,10 +45,11 @@ func (s *SourceMapService) GetSourceMapUploadUrl(ctx *gin.Context) {
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
//generate s3 pre-signed url
|
||||
key := path.Join(projectId, releaseId, fileName)
|
||||
bucket := s.awsConfig.Bucket
|
||||
request, err := s.s3Client.S3PresignClient.PresignGetObject(context.TODO(), &s3.GetObjectInput{
|
||||
request, err := s.s3Client.S3PresignClient.PresignPutObject(context.TODO(), &s3.PutObjectInput{
|
||||
Bucket: &bucket,
|
||||
Key: &key,
|
||||
}, func(opts *s3.PresignOptions) {
|
||||
@@ -83,9 +84,10 @@ func (s *SourceMapService) SourceMapUploadAck(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
//find the record to update ack
|
||||
var existingSourceMap db.SourceMap
|
||||
existingRecordError := s.dbClient.First(&existingSourceMap, "project_reference_id = ? and release_reference_id= ? and file_name = ?", sourceMapAckBody.ProjectId, sourceMapAckBody.ReleaseId, sourceMapAckBody.FileName).Error
|
||||
existingRecordError := s.dbClient.First(&existingSourceMap, "project_reference_id = ? and release_reference_id= ? and file_name = ?", sourceMapAckBody.ProjectReferenceId, sourceMapAckBody.ReleaseId, sourceMapAckBody.FileName).Error
|
||||
if existingRecordError != nil {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": existingRecordError.Error()})
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user