Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #2807

Merged
merged 26 commits into from
Sep 25, 2024
Merged

Develop #2807

Changes from 3 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
e153c1d
fix: 兼容实例视图最后一个节点且当前拓扑层级child_type为空时,不需要请求下一层拓扑数据
lhzzforever Sep 4, 2024
0356755
Merge pull request #2799 from lhzzforever/dev/develop_ci
ielgnaw Sep 6, 2024
91d428c
fix: 【权限中心测试】平台管理》我的管理空间新建管理空间时,点击返回,页面返回异常
lhzzforever Sep 10, 2024
f605e96
Merge branch 'upstream/develop' into dev/develop_ci
lhzzforever Sep 10, 2024
0606918
Merge pull request #2800 from lhzzforever/dev/develop_ci
ielgnaw Sep 11, 2024
ac2d980
fix: 更改7.1版本链接跳转
lhzzforever Sep 11, 2024
dae6338
Merge branch 'upstream/develop' into dev/develop_ci
lhzzforever Sep 11, 2024
3dc89a3
Merge pull request #2801 from lhzzforever/dev/develop_ci
ielgnaw Sep 11, 2024
1180b17
feature: 添加开源社区选项跳转
lhzzforever Sep 11, 2024
5d0a9d8
Merge branch 'upstream/develop' into dev/develop_ci
lhzzforever Sep 11, 2024
b956c0b
Merge pull request #2802 from lhzzforever/dev/develop_ci
ielgnaw Sep 11, 2024
bdfe2fa
fix: 修复资源实例详情path数量与count不一致问题
lhzzforever Sep 23, 2024
407edcd
Merge branch 'upstream/develop' into dev/develop_ci
lhzzforever Sep 23, 2024
714b9ef
fix: 统一根据displayPath去掉重复path链路数据
lhzzforever Sep 23, 2024
146b679
fix: 修复由于拓扑实例是扁平化结构无法区分实例作用域范围,会存在分级管理员授权实例范围是父级,但是选择子集自动关联操作会造成数据错乱问题
lhzzforever Sep 24, 2024
2abd1f1
fix: 修复偶发path视图层展示数量与实际授权范围实例数量不一致
lhzzforever Sep 24, 2024
8cf4692
Merge pull request #2803 from lhzzforever/dev/develop_ci
ielgnaw Sep 24, 2024
197a7e6
feature: 对接蓝盾用户组权限页面iframe传递事件需求
lhzzforever Sep 24, 2024
14d4f65
Merge branch 'upstream/develop' into dev/develop_ci
lhzzforever Sep 24, 2024
93bb05c
feature: 整理统一事件
lhzzforever Sep 24, 2024
a21f076
Merge pull request #2804 from lhzzforever/dev/develop_ci
ielgnaw Sep 25, 2024
9d17b9d
feat: support exempt notification user
nannan00 Sep 25, 2024
dbcd6df
fix: minor
nannan00 Sep 25, 2024
b800520
Merge pull request #2805 from nannan00/ft_notification_exemption_user
normal-wls Sep 25, 2024
53f7876
docs: 1.10.34 version log
nannan00 Sep 25, 2024
ea21ddd
Merge pull request #2806 from nannan00/ft_version_log_v1.10.34
nannan00 Sep 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion saas/backend/component/bkbot.py
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@

from .constants import ComponentEnum
from .http import http_post
from .util import do_blueking_http_request
from .util import do_blueking_http_request, remove_notification_exemption_user


def _call_bk_bot_approval_api(http_func, url_path, data, timeout=30):
@@ -31,5 +31,10 @@ def _call_bk_bot_approval_api(http_func, url_path, data, timeout=30):


def send_iam_ticket(data):
# 移除豁免的用户,如果为空,则直接返回
data["approvers"] = ",".join(remove_notification_exemption_user(data["approvers"].split(",")))
if not data["approvers"]:
return {}

url_path = "/iam_app_ticket/"
return _call_bk_bot_approval_api(http_post, url_path, data=data)
7 changes: 6 additions & 1 deletion saas/backend/component/esb.py
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@

from .constants import ComponentEnum
from .http import http_get, http_post
from .util import do_blueking_http_request
from .util import do_blueking_http_request, remove_notification_exemption_user


def _call_esb_api(http_func, url_path, data, timeout=30, request_session=None):
@@ -49,6 +49,11 @@ def get_api_public_key() -> Dict:

def send_mail(username, title, content, body_format="Html"):
"""发送邮件"""
# 移除豁免的用户,如果为空,则直接返回
username = ",".join(remove_notification_exemption_user(username.split(",")))
if not username:
return None

url_path = "/api/c/compapi/cmsi/send_mail/"
data = {"receiver__username": username, "title": title, "content": content, "body_format": body_format}
return _call_esb_api(http_post, url_path, data=data)
13 changes: 13 additions & 0 deletions saas/backend/component/util.py
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@
from typing import Any, Callable, Dict, List, Optional, Tuple
from urllib.parse import urlparse

from django.conf import settings

from backend.common.error_codes import error_codes
from backend.common.local import local

@@ -124,3 +126,14 @@ def do_blueking_http_request(
f"Request=[{http_func.__name__} {urlparse(url).path} request_id={local.request_id}] "
f"Response[code={code}, message={message}]"
)


def remove_notification_exemption_user(usernames: List[str]) -> List[str]:
"""
从给定的用户列表里移除豁免通知的人员
:param usernames: 待处理的用户名列表
:return: 处理后的用户名列表
"""
exemption_user_set = {u.strip().lower() for u in settings.BK_NOTIFICATION_EXEMPTION_USERS if u.strip()}

return [u for u in usernames if u.strip().lower() not in exemption_user_set]
2 changes: 2 additions & 0 deletions saas/config/default.py
Original file line number Diff line number Diff line change
@@ -483,6 +483,8 @@
# BK BOT approval审批机器人通知
BK_IAM_BOT_APPROVAL_CALLBACK_APIGW_URL = env.str("BK_IAM_BOT_APPROVAL_CALLBACK_APIGW_URL", default="")

# 通知的豁免名单,企业内部分人员不接收通知
BK_NOTIFICATION_EXEMPTION_USERS = env.list("BK_NOTIFICATION_EXEMPTION_USERS", default=[])

# 文档地址
BK_DOCS_URL_PREFIX = env.str("BK_DOCS_URL_PREFIX", default="https://bk.tencent.com/docs/")
10 changes: 10 additions & 0 deletions saas/tests/component/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-
"""
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-用户管理(Bk-User) available.
Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://opensource.org/licenses/MIT
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""
35 changes: 35 additions & 0 deletions saas/tests/component/util_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
"""
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-用户管理(Bk-User) available.
Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://opensource.org/licenses/MIT
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""
import pytest
from django.test.utils import override_settings

from backend.component.util import remove_notification_exemption_user


@pytest.mark.parametrize(
"usernames, expected",
[
# Case 1: List without any exempt users
(["user1", "user2"], ["user1", "user2"]),
# Case 2: List with some exempt users
(["exempt_user1", "user1", "exempt_user2", "user2"], ["user1", "user2"]),
# Case 3: List with only exempt users
(["exempt_user1", "exempt_user2"], []),
# Case 4: List with mixed cases and spaces
(["Exempt_User1", " user1 ", "ExEmPt_UsEr2", " user2 ", " exempt_user3 "], [" user1 ", " user2 "]),
# Case 5: Empty list
([], []),
],
)
def test_remove_notification_exemption_user(usernames, expected):
with override_settings(BK_NOTIFICATION_EXEMPTION_USERS=["exempt_user1", "exempt_user2", "exempt_user3 "]):
result = remove_notification_exemption_user(usernames)
assert result == expected