From a7da5cdebc0dfcb6d37c4431077608a900169102 Mon Sep 17 00:00:00 2001 From: romanskijdev Date: Mon, 29 Jun 2026 14:07:45 +0300 Subject: [PATCH] Fix comment input --- core/db/methods/approval_comment.go | 15 ++++++++++----- service/telegram_service/common/update/0_init.go | 2 +- .../handlers/approval/handler_comment.go | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/core/db/methods/approval_comment.go b/core/db/methods/approval_comment.go index 642be67..59932d1 100644 --- a/core/db/methods/approval_comment.go +++ b/core/db/methods/approval_comment.go @@ -92,18 +92,23 @@ func (u *ApprovalCommentDB) CreateApprovalCommentDB(ctx context.Context, tx pgx. }) if err != nil { - return nil, tx, err + return nil, nil, err } returnObjBool := len(returnObj) > 0 && returnObj[0] - if returnObjBool && insertedID > 0 { + if returnObjBool { + if insertedID == 0 { + return nil, nil, errors.New("inserted ID is 0 after insert") + } created, err := u.GetApprovalCommentByIDDB(ctx, insertedID) - return created, tx, err + if err != nil { + return nil, nil, err + } + return created, nil, nil } - return nil, tx, nil + return nil, nil, nil } - func (u *ApprovalCommentDB) UpdateApprovalCommentDB(ctx context.Context, tx pgx.Tx, paramsUpdate *typescore.ApprovalComment, returnObj ...bool) (*typescore.ApprovalComment, pgx.Tx, error) { if paramsUpdate.ID == nil { return nil, nil, errors.New("ApprovalComment obj is nil") diff --git a/service/telegram_service/common/update/0_init.go b/service/telegram_service/common/update/0_init.go index 02ff94b..201fef0 100644 --- a/service/telegram_service/common/update/0_init.go +++ b/service/telegram_service/common/update/0_init.go @@ -40,7 +40,7 @@ func NewUpdateHandler(ipc *types.InternalProviderControl) *UpdateHandler { // TODO: вызывается только после обновлений //go handler.broadcastBotUpdated() - go handler.sendSupportNotification() + //go handler.sendSupportNotification() return handler } diff --git a/service/telegram_service/handlers/approval/handler_comment.go b/service/telegram_service/handlers/approval/handler_comment.go index e549c7d..a258203 100644 --- a/service/telegram_service/handlers/approval/handler_comment.go +++ b/service/telegram_service/handlers/approval/handler_comment.go @@ -384,7 +384,7 @@ func (h *Handler) HandleCommentReplyInput(bot *tgbotapi.BotAPI, msg *tgbotapi.Me UserID: user.ID, Comment: &msg.Text, } - created, _, err := h.ipc.Database.ApprovalComment.CreateApprovalCommentDB(ctx, nil, comment, true) //nolint:errcheck + _, _, err = h.ipc.Database.ApprovalComment.CreateApprovalCommentDB(ctx, nil, comment) if err != nil { sendText(bot, chatID, "⚠️ Ошибка при создании комментария: "+err.Error()) return false -- 2.43.0