From 623f1f17f1c1eab42fa156a9a41a399be8f5e6c4 Mon Sep 17 00:00:00 2001 From: rainzm Date: Tue, 6 Apr 2021 17:12:54 +0800 Subject: [PATCH] =?UTF-8?q?feat(notify):=20=E7=AE=A1=E7=90=86=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E6=96=B0=E5=BB=BA=E7=9A=84=E8=81=94=E7=B3=BB=E4=BA=BA?= =?UTF-8?q?=EF=BC=8C=E6=89=8B=E6=9C=BA=E5=8F=B7=E5=92=8C=E9=82=AE=E7=AE=B1?= =?UTF-8?q?=E6=97=A0=E9=9C=80=E8=BF=9B=E8=A1=8C=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/notify/models/receiver.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/notify/models/receiver.go b/pkg/notify/models/receiver.go index 3663d8a473..5cd3522e6e 100644 --- a/pkg/notify/models/receiver.go +++ b/pkg/notify/models/receiver.go @@ -35,6 +35,7 @@ import ( api "yunion.io/x/onecloud/pkg/apis/notify" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" + "yunion.io/x/onecloud/pkg/cloudcommon/policy" "yunion.io/x/onecloud/pkg/httperrors" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/auth" @@ -663,6 +664,13 @@ func (rm *SReceiverManager) OrderByExtraFields(ctx context.Context, q *sqlchemy. func (r *SReceiver) PostCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) { r.SStatusStandaloneResourceBase.PostCreate(ctx, userCred, ownerId, query, data) + // 需求:管理后台新建的联系人,手机号和邮箱无需进行校验 + // 方案:检查请求者对于创建联系人 是否具有system scope + allowScope := policy.PolicyManager.AllowScope(userCred, api.SERVICE_TYPE, ReceiverManager.KeywordPlural(), policy.PolicyActionCreate) + if allowScope == rbacutils.ScopeSystem { + r.VerifiedEmail = tristate.True + r.VerifiedMobile = tristate.True + } // set status r.SetStatus(userCred, api.RECEIVER_STATUS_PULLING, "") logclient.AddActionLogWithContext(ctx, r, logclient.ACT_CREATE, nil, userCred, true)