Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Do not post member change to inbox
天舟d7cbebaa8ded
diff --git a/api/activity.go b/api/activity.goindex abac54d572..1e29259590 100644--- a/api/activity.go+++ b/api/activity.go@@ -106,7 +106,6 @@ type ActivityPipelineTaskStatusUpdatePayload struct {}type ActivityMemberCreatePayload struct {- // Used by inbox to display info without paying the join costPrincipalId int `json:"principalId"`PrincipalName string `json:"principalName"`PrincipalEmail string `json:"principalEmail"`@@ -115,7 +114,6 @@ type ActivityMemberCreatePayload struct {}type ActivityMemberRoleUpdatePayload struct {- // Used by inbox to display info without paying the join costPrincipalId int `json:"principalId"`PrincipalName string `json:"principalName"`PrincipalEmail string `json:"principalEmail"`@@ -124,7 +122,6 @@ type ActivityMemberRoleUpdatePayload struct {}type ActivityMemberActivateDeactivatePayload struct {- // Used by inbox to display info without paying the join costPrincipalId int `json:"principalId"`PrincipalName string `json:"principalName"`PrincipalEmail string `json:"principalEmail"`diff --git a/frontend/src/components/InboxList.vue b/frontend/src/components/InboxList.vueindex 9673dd5a49..8cd31551bc 100644--- a/frontend/src/components/InboxList.vue+++ b/frontend/src/components/InboxList.vue@@ -89,18 +89,14 @@ import {ActionIssueCreatePayload,ActionIssueFieldUpdatePayload,ActionIssueStatusUpdatePayload,- ActionMemberActivateDeactivatePayload,- ActionMemberCreatePayload,- ActionMemberRoleUpdatePayload,ActionTaskStatusUpdatePayload,Activity,Inbox,- Principal,} from "../types";import { useStore } from "vuex";import { useRouter } from "vue-router";import { isEmpty } from "lodash";-import { issueActivityActionSentence, roleName } from "../utils";+import { issueActivityActionSentence } from "../utils";export default {name: "InboxList",@@ -123,18 +119,13 @@ export default {} else if (activity.actionType == "bb.pipeline.task.status.update") {const payload = activity.payload as ActionTaskStatusUpdatePayload;return `/issue/${activity.containerId}?task=${payload.taskId}`;- } else if (activity.actionType.startsWith("bb.member.")) {- return `/setting/member`;}return "";};const showCreator = (activity: Activity): boolean => {- return (- activity.actionType.startsWith("bb.issue.") ||- activity.actionType.startsWith("bb.member.")- );+ return activity.actionType.startsWith("bb.issue.");};const actionSentence = (activity: Activity): string => {@@ -187,47 +178,6 @@ export default {return `Task '${payload.taskName}' ${actionStr} - '${payload?.issueName || ""}'`;- } else if (activity.actionType.startsWith("bb.member.")) {- switch (activity.actionType) {- case "bb.member.create": {- const payload = activity.payload as ActionMemberCreatePayload;- if (payload.principalId == activity.creator.id) {- return `(${payload.principalEmail}) joined as a ${roleName(- payload.role- )}`;- }- var verb = "added";- if (payload.memberStatus == "INVITED") {- verb = "invited";- }- return `${verb} ${payload.principalName} (${- payload.principalEmail- }) as a ${roleName(payload.role)}`;- }- case "bb.member.role.update": {- const payload = activity.payload as ActionMemberRoleUpdatePayload;- return `changed ${payload.principalName} (${- payload.principalEmail- }) from ${roleName(payload.oldRole)} to ${roleName(- payload.newRole- )}`;- }- case "bb.member.activate": {- const payload =- activity.payload as ActionMemberActivateDeactivatePayload;- return `activated ${roleName(payload.role)} ${- payload.principalName- } (${payload.principalEmail})`;- }- case "bb.member.deactivate": {- const payload =- activity.payload as ActionMemberActivateDeactivatePayload;- return `deactivated ${roleName(payload.role)} ${- payload.principalName- } (${payload.principalEmail})`;- }- }- return "";}return "";diff --git a/frontend/src/views/Inbox.vue b/frontend/src/views/Inbox.vueindex c8d098476c..6da338aac1 100644--- a/frontend/src/views/Inbox.vue+++ b/frontend/src/views/Inbox.vue@@ -1,81 +1,62 @@<template><!-- This example requires Tailwind CSS v2.0+ -->- <div class="my-2 space-y-2 divide-y divide-block-border">- <div class="flex items-center justify-between">- <BBTabFilter- v-if="isCurrentUserDBAOrOwner"- class="mx-2"- :tabList="tabItemList.map((item) => item.name)"- :selectedIndex="state.selectedIndex"- @select-index="- (index) => {- selectTab(index);- }+ <div class="space-y-4">+ <div class="mt-6 mx-6 space-y-2">+ <div+ class="+ flex+ items-center+ justify-between+ pb-2+ border-b border-block-border"- />- <button- type="button"- class="mr-4 btn-normal"- @click.prevent="markAllAsRead">- <svg- class="-ml-1 mr-2 h-5 w-5 text-control-light"- fill="currentColor"- viewBox="0 0 20 20"- xmlns="http://www.w3.org/2000/svg"- >- <path- d="M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z"- ></path>- </svg>- <span>Mark all as read</span>- </button>+ <div class="text-lg leading-6 font-medium text-main">Unread</div>+ <button type="button" class="btn-normal" @click.prevent="markAllAsRead">+ <svg+ class="-ml-1 mr-2 h-5 w-5 text-control-light"+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M5 13l4 4L19 7"+ ></path>+ </svg>+ <span>Mark all as read</span>+ </button>+ </div>+ <InboxList :inboxList="state.unreadList" /></div>- <div>- <div class="mt-6 mx-6 space-y-2">- <div- class="- text-lg- leading-6- font-medium- text-main- pb-4- border-b border-block-border- "- >- Unread- </div>- <InboxList :inboxList="effectiveInboxList(state.unreadList)" />+ <div class="mt-6 mx-6 space-y-2">+ <div+ class="+ text-lg+ leading-6+ font-medium+ text-main+ pb-2+ border-b border-block-border+ "+ >+ Read</div>- <div class="mt-6 mx-6 space-y-2">- <div- class="- text-lg- leading-6- font-medium- text-main- pb-4- border-b border-block-border- "- >- Read- </div>- <InboxList- class="opacity-70"- :inboxList="effectiveInboxList(state.readList)"- />- <div class="mt-2 flex justify-end">- <button type="button" class="normal-link" @click.prevent="viewOlder">- View older- </button>- </div>+ <InboxList class="opacity-70" :inboxList="state.readList" />+ <div class="mt-2 flex justify-end">+ <button type="button" class="normal-link" @click.prevent="viewOlder">+ View older+ </button></div></div></div></template><script lang="ts">-import { computed, onMounted, reactive, watchEffect } from "vue";+import { computed, reactive, watchEffect } from "vue";import { useStore } from "vuex";import InboxList from "../components/InboxList.vue";import { Inbox, UNKNOWN_ID } from "../types";@@ -86,21 +67,7 @@ import { useRouter } from "vue-router";// And each time clicking "View older" will extend 7 days further.const READ_INBOX_DURATION_STEP = 3600 * 24 * 7;-const ISSUE_TAB = 0;-const MEMBER_TAB = 1;--type TabItem = {- name: string;- hash: string;-};--const tabItemList: TabItem[] = [- { name: "Issue", hash: "issue" },- { name: "Member", hash: "member" },-];-interface LocalState {- selectedIndex: number;readList: Inbox[];unreadList: Inbox[];readCreatedAfterTs: number;@@ -114,7 +81,6 @@ export default {const router = useRouter();const state = reactive<LocalState>({- selectedIndex: 0,readList: [],unreadList: [],readCreatedAfterTs:@@ -124,32 +90,6 @@ export default {const currentUser = computed(() => store.getters["auth/currentUser"]());- const selectTabOnHash = () => {- if (router.currentRoute.value.hash) {- for (let i = 0; i < tabItemList.length; i++) {- if (tabItemList[i].hash == router.currentRoute.value.hash.slice(1)) {- selectTab(i);- break;- }- }- } else {- selectTab(ISSUE_TAB);- }- };-- const selectTab = (index: number) => {- state.selectedIndex = index;- router.replace({- name: "workspace.inbox",- hash: "#" + tabItemList[index].hash,- query: router.currentRoute.value.query,- });- };-- onMounted(() => {- selectTabOnHash();- });-const prepareInboxList = () => {// It will also be called when user logoutif (currentUser.value.id != UNKNOWN_ID) {@@ -175,24 +115,6 @@ export default {watchEffect(prepareInboxList);- const isCurrentUserDBAOrOwner = computed((): boolean => {- return isDBAOrOwner(currentUser.value.role);- });-- const effectiveInboxList = (inboxList: Inbox[]) => {- return inboxList.filter((inbox: Inbox) => {- if (- (state.selectedIndex == ISSUE_TAB &&- inbox.activity.actionType.startsWith("bb.member.")) ||- (state.selectedIndex == MEMBER_TAB &&- !inbox.activity.actionType.startsWith("bb.member."))- ) {- return false;- }- return true;- });- };-const markAllAsRead = () => {var count = state.unreadList.length;state.unreadList.forEach((item: Inbox) => {@@ -233,11 +155,7 @@ export default {};return {- tabItemList,- selectTab,state,- isCurrentUserDBAOrOwner,- effectiveInboxList,markAllAsRead,viewOlder,};diff --git a/server/auth.go b/server/auth.goindex 30fbb1c73d..8bbfa1946c 100644--- a/server/auth.go+++ b/server/auth.go@@ -140,7 +140,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to construct activity payload").SetInternal(err)}- activity, err := s.ActivityService.CreateActivity(context.Background(), &api.ActivityCreate{+ _, err = s.ActivityService.CreateActivity(context.Background(), &api.ActivityCreate{CreatorId: user.ID,ContainerId: member.ID,Type: api.ActivityMemberCreate,@@ -150,10 +150,6 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to create activity after create member: %d", member.ID)).SetInternal(err)}-- if err := s.PostInboxMemberActivity(context.Background(), member, activity.ID); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to post activity to inbox").SetInternal(err)- }}if err := GenerateTokensAndSetCookies(c, user, s.mode, s.secret); err != nil {diff --git a/server/member.go b/server/member.goindex e899a7df26..718c311bdb 100644--- a/server/member.go+++ b/server/member.go@@ -53,7 +53,7 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to construct activity payload").SetInternal(err)}- activity, err := s.ActivityService.CreateActivity(context.Background(), &api.ActivityCreate{+ _, err = s.ActivityService.CreateActivity(context.Background(), &api.ActivityCreate{CreatorId: c.Get(GetPrincipalIdContextKey()).(int),ContainerId: member.ID,Type: api.ActivityMemberCreate,@@ -63,10 +63,6 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to create activity after creating member: %d", member.ID)).SetInternal(err)}-- if err := s.PostInboxMemberActivity(context.Background(), member, activity.ID); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to post activity to inbox").SetInternal(err)- }}if err := s.ComposeMemberRelationship(context.Background(), member); err != nil {@@ -146,7 +142,6 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Server error to find user ID: %d", updatedMember.PrincipalId)).SetInternal(err)}- var activity *api.Activityif memberPatch.Role != nil {bytes, err := json.Marshal(api.ActivityMemberRoleUpdatePayload{PrincipalId: updatedMember.PrincipalId,@@ -158,7 +153,7 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, "Failed to construct activity payload").SetInternal(err)}- createdActivity, err := s.ActivityService.CreateActivity(context.Background(), &api.ActivityCreate{+ _, err = s.ActivityService.CreateActivity(context.Background(), &api.ActivityCreate{CreatorId: c.Get(GetPrincipalIdContextKey()).(int),ContainerId: updatedMember.ID,Type: api.ActivityMemberRoleUpdate,@@ -167,7 +162,6 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to create activity after changing member role: %d", updatedMember.ID)).SetInternal(err)}- activity = createdActivity} else if memberPatch.RowStatus != nil {bytes, err := json.Marshal(api.ActivityMemberActivateDeactivatePayload{PrincipalId: updatedMember.PrincipalId,@@ -182,7 +176,7 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {if *memberPatch.RowStatus == "ARCHIVED" {theType = api.ActivityMemberDeactivate}- createdActivity, err := s.ActivityService.CreateActivity(context.Background(), &api.ActivityCreate{+ _, err = s.ActivityService.CreateActivity(context.Background(), &api.ActivityCreate{CreatorId: c.Get(GetPrincipalIdContextKey()).(int),ContainerId: updatedMember.ID,Type: theType,@@ -192,11 +186,6 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {if err != nil {return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to create activity after changing member role: %d", updatedMember.ID)).SetInternal(err)}- activity = createdActivity- }-- if err := s.PostInboxMemberActivity(context.Background(), updatedMember, activity.ID); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to post activity to inbox").SetInternal(err)}}@@ -232,28 +221,3 @@ func (s *Server) ComposeMemberRelationship(ctx context.Context, member *api.Membreturn nil}--// Post member activity to owner inbox-func (s *Server) PostInboxMemberActivity(ctx context.Context, member *api.Member, activity_id int) error {- role := api.Owner- memberFind := &api.MemberFind{- Role: &role,- }- list, err := s.MemberService.FindMemberList(context.Background(), memberFind)- if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to fetch owner member list").SetInternal(err)- }-- for _, member := range list {- inboxCreate := &api.InboxCreate{- ReceiverId: member.PrincipalId,- ActivityId: activity_id,- }- _, err := s.InboxService.CreateInbox(context.Background(), inboxCreate)- if err != nil {- return fmt.Errorf("failed to post activity to owner inbox: %d, error: %w", member.PrincipalId, err)- }- }-- return nil-}