diff --git a/deployments/staging/docker-compose.yaml b/deployments/staging/docker-compose.yaml index a53e41d..0eced51 100644 --- a/deployments/staging/docker-compose.yaml +++ b/deployments/staging/docker-compose.yaml @@ -23,6 +23,6 @@ services: MONGO_AUTH: "verification" MONGO_DATABASE_NAME: "verification" CUSTOMER_SVC_ADDRESS: "10.8.0.6:8065" - STAGING_URL: "sadmin.pena" + STAGING_URL: "https://sadmin.pena" tty: true diff --git a/internal/client/assets/new_verification.txt b/internal/client/assets/new_verification.txt index 80174ab..f183bb3 100644 --- a/internal/client/assets/new_verification.txt +++ b/internal/client/assets/new_verification.txt @@ -1,14 +1 @@ -New verification: -ID: {{ .ID }} -UserID: {{ .UserID }} -UserURL: {{ .UserURL }} -Accepted: {{ .Accepted }} -Status: {{ .Status }} -UpdatedAt: {{ .UpdatedAt.Format "Mon, 02 Jan 2006 15:04:05 MST"}} -Comment: {{ .Comment }} -============================= - Files -============================= -{{ range .Files }} -Название: {{ .Name }} ({{ .Url }}) -{{ end }} \ No newline at end of file +Пользователь {{ .UserURL }} подал запрос на верификацию diff --git a/internal/client/assets/updated_verification.txt b/internal/client/assets/updated_verification.txt index dfd4ec5..f183bb3 100644 --- a/internal/client/assets/updated_verification.txt +++ b/internal/client/assets/updated_verification.txt @@ -1,14 +1 @@ -Updated verification: -ID: {{ .ID }} -UserID: {{ .UserID }} -UserURL: {{ .UserURL }} -Accepted: {{ .Accepted }} -Status: {{ .Status }} -UpdatedAt: {{ .UpdatedAt.Format "Mon, 02 Jan 2006 15:04:05 MST"}} -Comment: {{ .Comment }} -============================= - Files -============================= -{{ range .Files }} -Название: {{ .Name }} ({{ .Url }}) -{{ end }} \ No newline at end of file +Пользователь {{ .UserURL }} подал запрос на верификацию diff --git a/internal/client/telegram.go b/internal/client/telegram.go index 39821cd..b42cae2 100644 --- a/internal/client/telegram.go +++ b/internal/client/telegram.go @@ -35,6 +35,7 @@ func NewTelegram(deps Deps) *Telegram { } func (t *Telegram) SendVerification(data *models.Verification, url string, isUpdate bool) error { + fmt.Println("VERT", data, url,isUpdate) var tplPath string if isUpdate { tplPath = UpdatedVerification @@ -42,14 +43,13 @@ func (t *Telegram) SendVerification(data *models.Verification, url string, isUpd tplPath = NewVerification } + fmt.Println("VERT1", tplPath) var userURL string - if url == t.stagingURL { - userURL = fmt.Sprintf("%s/users/%s", t.stagingURL, data.UserID) - } else { - userURL = fmt.Sprintf("https://admin.pena/users/%s", data.UserID) - } + userURL = fmt.Sprintf("%s/users/%s", t.stagingURL, data.UserID) + fmt.Println("VERT2", userURL) tpl, err := template.New("verification_template").Parse(tplPath) + fmt.Println("VERT333", tpl,err) if err != nil { return fmt.Errorf("error parsing template: %w", err) } @@ -69,12 +69,14 @@ func (t *Telegram) SendVerification(data *models.Verification, url string, isUpd } err = tpl.Execute(&text, toTG) + fmt.Println("VERT433", err) if err != nil { return fmt.Errorf("error executing template: %w", err) } msg := tgbotapi.NewMessage(t.chatID, text.String()) + fmt.Println("VERT433", err, t.chatID, text.String()) _, err = t.bot.Send(msg) if err != nil { return fmt.Errorf("error sending message: %w", err) diff --git a/internal/repository/verification.go b/internal/repository/verification.go index 588125c..b1caeaa 100644 --- a/internal/repository/verification.go +++ b/internal/repository/verification.go @@ -255,10 +255,8 @@ func (r *VerificationRepository) Update(ctx context.Context, record *models.Veri TaxNumber: record.TaxNumber, } - objId, _ := primitive.ObjectIDFromHex(record.ID) - var result models.Verification - err := r.mongo.FindOneAndUpdate(ctx, bson.M{"_id": objId}, bson.M{"$set": test}, options.FindOneAndUpdate().SetReturnDocument(options.After)).Decode(&result) + err := r.mongo.FindOneAndUpdate(ctx, bson.M{"_id": record.ID}, bson.M{"$set": test}, options.FindOneAndUpdate().SetReturnDocument(options.After)).Decode(&result) if r.err(err) { return nil, err } @@ -286,7 +284,12 @@ func (r *VerificationRepository) UpdateFile(ctx context.Context, userID, fileNam if r.err(err) { return nil, err } + + if verification == nil { + return nil, fmt.Errorf("no verification found") + } + fmt.Println("BUG",verification.Files) found := false for iterator, file := range verification.Files { if file.Name != fileName {