From 66dc7388b55069d460cdc94ab6fde22ef3a600d9 Mon Sep 17 00:00:00 2001 From: rainzm Date: Mon, 27 Sep 2021 15:53:35 +0800 Subject: [PATCH] fix(notify): update database when change subscriber's identification --- pkg/notify/models/subscriber.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/pkg/notify/models/subscriber.go b/pkg/notify/models/subscriber.go index ea91026e72..0b4059e25f 100644 --- a/pkg/notify/models/subscriber.go +++ b/pkg/notify/models/subscriber.go @@ -260,9 +260,21 @@ func (s *SSubscriber) PerformChange(ctx context.Context, userCred mcclient.Token log.Errorf("unable to set receivers %s", input.Receivers) } case api.SUBSCRIBER_TYPE_ROBOT: - s.Identification = input.Robot + _, err := db.Update(s, func() error { + s.Identification = input.Robot + return nil + }) + if err != nil { + return nil, errors.Wrap(err, "unable to update subscriber") + } case api.SUBSCRIBER_TYPE_ROLE: - s.Identification = input.Role + _, err := db.Update(s, func() error { + s.Identification = input.Role + return nil + }) + if err != nil { + return nil, errors.Wrap(err, "unable to update subscriber") + } } return nil, nil }