Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: show push notification only for issue creator and owners (#9137)

Danny Xub304e4724393
diff --git a/backend/api/v1/logging_service.go b/backend/api/v1/logging_service.go
index 536e5a6702..daa52b71cc 100644
--- a/backend/api/v1/logging_service.go
+++ b/backend/api/v1/logging_service.go
@@ -32,7 +32,7 @@ func NewLoggingService(store *store.Store) *LoggingService {
}
}
-var resourceActionTypeMap = map[string][]api.ActivityType{
+var defaultResourceActionTypeMap = map[string][]api.ActivityType{
"users": {
api.ActivityMemberCreate,
api.ActivityMemberRoleUpdate,
@@ -183,11 +183,14 @@ func setActivityFindFilterAndOrder(ctx context.Context, stores *store.Store, act
if len(sections) != 2 {
return status.Errorf(codes.InvalidArgument, `invalid resource "%s" for filter`, spec.value)
}
- typeList, ok := resourceActionTypeMap[sections[0]]
- if !ok {
- return status.Errorf(codes.InvalidArgument, `unsupport resource %s`, spec.value)
+ // Handle the defaultResourceActionType.
+ if len(activityFind.TypeList) == 0 {
+ typeList, ok := defaultResourceActionTypeMap[sections[0]]
+ if !ok {
+ return status.Errorf(codes.InvalidArgument, `unsupport resource %s`, spec.value)
+ }
+ activityFind.TypeList = append(activityFind.TypeList, typeList...)
}
- activityFind.TypeList = append(activityFind.TypeList, typeList...)
switch fmt.Sprintf("%s/", sections[0]) {
case common.UserNamePrefix:
user, err := stores.GetUser(ctx, &store.FindUserMessage{
@@ -249,6 +252,10 @@ func setActivityFindFilterAndOrder(ctx context.Context, stores *store.Store, act
if spec.operator != comparatorTypeEqual {
return status.Errorf(codes.InvalidArgument, `only support "=" operation for "action" filter`)
}
+ // Handle the defaultResourceActionType.
+ if len(activityFind.TypeList) > 0 {
+ activityFind.TypeList = nil
+ }
for _, action := range strings.Split(spec.value, " | ") {
activityType, err := convertToActivityType(v1pb.LogEntity_Action(v1pb.LogEntity_Action_value[action]))
if err != nil {
diff --git a/frontend/src/views/ProjectDetail.vue b/frontend/src/views/ProjectDetail.vue
index 1f3a4ce19b..5534c94074 100644
--- a/frontend/src/views/ProjectDetail.vue
+++ b/frontend/src/views/ProjectDetail.vue
@@ -95,6 +95,7 @@ import {
hasFeature,
pushNotification,
} from "@/store";
+import { getUserEmailFromIdentifier } from "@/store/modules/v1/common";
import {
QuickActionType,
DEFAULT_PROJECT_V1_NAME,
@@ -109,6 +110,7 @@ import {
sortDatabaseV1List,
isOwnerOfProjectV1,
hasPermissionInProjectV1,
+ hasWorkspacePermissionV1,
getQuickActionList,
} from "@/utils";
@@ -170,6 +172,7 @@ onMounted(() => {
resource: project.value.name,
})
.then((resp) => {
+ const currentUserV1 = useCurrentUserV1();
for (const activity of resp.logEntities) {
if (cachedNotifiedActivities.value.includes(activity.name)) {
continue;
@@ -179,14 +182,29 @@ onMounted(() => {
cachedNotifiedActivities.value.shift();
}
- pushNotification({
- module: "bytebase",
- style: "INFO",
- title: activityName(activity.action),
- manualHide: true,
- link: `/project/${projectV1Slug(project.value)}#activities`,
- linkTitle: t("common.view"),
- });
+ // Only show notification for issue creator, project owner, workspace owner/DBA.
+ if (
+ getUserEmailFromIdentifier(activity.creator) ===
+ currentUserV1.value.email ||
+ hasWorkspacePermissionV1(
+ "bb.permission.workspace.manage-issue",
+ currentUserV1.value.userRole
+ ) ||
+ hasPermissionInProjectV1(
+ project.value.iamPolicy,
+ currentUserV1.value,
+ "bb.permission.project.change-database"
+ )
+ ) {
+ pushNotification({
+ module: "bytebase",
+ style: "INFO",
+ title: activityName(activity.action),
+ manualHide: true,
+ link: `/project/${projectV1Slug(project.value)}#activities`,
+ linkTitle: t("common.view"),
+ });
+ }
break;
}
});