From 1e9e192a9ca1a922d31bf43b98ced895605808a7 Mon Sep 17 00:00:00 2001 From: rainzm Date: Fri, 8 Oct 2021 17:19:24 +0800 Subject: [PATCH 1/3] fix(notify): add default policy for subscribers --- pkg/notify/policy/defaults.go | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/pkg/notify/policy/defaults.go b/pkg/notify/policy/defaults.go index f3e5bb3dfd..f08409a705 100644 --- a/pkg/notify/policy/defaults.go +++ b/pkg/notify/policy/defaults.go @@ -133,6 +133,48 @@ var ( }, }, }, + { + Auth: true, + Scope: rbacutils.ScopeDomain, + Rules: []rbacutils.SRbacRule{ + { + Service: api.SERVICE_TYPE, + Resource: "subscribers", + Action: PolicyActionGet, + Result: rbacutils.Allow, + }, + { + Service: api.SERVICE_TYPE, + Resource: "subscribers", + Action: PolicyActionList, + Result: rbacutils.Allow, + }, + { + Service: api.SERVICE_TYPE, + Resource: "subscribers", + Action: PolicyActionCreate, + Result: rbacutils.Allow, + }, + { + Service: api.SERVICE_TYPE, + Resource: "subscribers", + Action: PolicyActionUpdate, + Result: rbacutils.Allow, + }, + { + Service: api.SERVICE_TYPE, + Resource: "subscribers", + Action: PolicyActionDelete, + Result: rbacutils.Allow, + }, + { + Service: api.SERVICE_TYPE, + Resource: "subscribers", + Action: PolicyActionPerform, + Result: rbacutils.Allow, + }, + }, + }, } ) From 09a670d67b4fdf733424af0eed2a98a886ecd421 Mon Sep 17 00:00:00 2001 From: rainzm Date: Fri, 8 Oct 2021 21:20:02 +0800 Subject: [PATCH 2/3] fix(notify): modify the width of ReceiverId --- pkg/notify/models/subscriber_receiver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/notify/models/subscriber_receiver.go b/pkg/notify/models/subscriber_receiver.go index ccec29b2fe..daf331edb5 100644 --- a/pkg/notify/models/subscriber_receiver.go +++ b/pkg/notify/models/subscriber_receiver.go @@ -43,7 +43,7 @@ type SSubscriberReceiverManager struct { type SSubscriberReceiver struct { db.SJointResourceBase SubscriberId string `width:"36" charset:"ascii" nullable:"false" index:"true"` - ReceiverId string `width:"36" charset:"ascii" nullable:"false" index:"true"` + ReceiverId string `width:"128" charset:"ascii" nullable:"false" index:"true"` } func (srm *SSubscriberReceiverManager) GetMasterFieldName() string { From 27fac4b4843382aea368906caaa78c92c6eff126 Mon Sep 17 00:00:00 2001 From: rainzm Date: Fri, 8 Oct 2021 21:20:38 +0800 Subject: [PATCH 3/3] fix(notify): update mobile where appropriate --- pkg/notify/models/receiver.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/notify/models/receiver.go b/pkg/notify/models/receiver.go index d4378c42fc..5e8c183fb7 100644 --- a/pkg/notify/models/receiver.go +++ b/pkg/notify/models/receiver.go @@ -905,7 +905,6 @@ func (r *SReceiver) PreUpdate(ctx context.Context, userCred mcclient.TokenCreden mobile := input.InternationalMobile.String() if len(mobile) != 0 && mobile != r.Mobile { r.VerifiedMobile = tristate.False - r.Mobile = mobile for _, c := range r.subContactCache { if c.ParentContactType == api.MOBILE { c.Verified = tristate.False @@ -935,6 +934,7 @@ func (r *SReceiver) PreUpdate(ctx context.Context, userCred mcclient.TokenCreden r.VerifiedMobile = tristate.True } } + r.Mobile = mobile err = ReceiverManager.TableSpec().InsertOrUpdate(ctx, r) if err != nil { log.Errorf("InsertOrUpdate: %v", err)