Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: migrate inbox to v1 (#6625)
ecmadao0e9815226a68
diff --git a/backend/api/v1/common.go b/backend/api/v1/common.goindex ed9171f0ad..f3e3599be8 100644--- a/backend/api/v1/common.go+++ b/backend/api/v1/common.go@@ -50,6 +50,7 @@ const (issueNamePrefix = "issues/"pipelineNamePrefix = "pipelines/"logNamePrefix = "logs/"+ inboxNamePrefix = "inbox/"deploymentConfigSuffix = "/deploymentConfig"backupSettingSuffix = "/backupSetting"diff --git a/backend/api/v1/inbox_service.go b/backend/api/v1/inbox_service.gonew file mode 100644index 0000000000..ddc7a15c0a--- /dev/null+++ b/backend/api/v1/inbox_service.go@@ -0,0 +1,152 @@+package v1++import (+ "context"+ "fmt"+ "time"++ "google.golang.org/grpc/codes"+ "google.golang.org/grpc/status"++ "github.com/bytebase/bytebase/backend/common"+ api "github.com/bytebase/bytebase/backend/legacyapi"+ "github.com/bytebase/bytebase/backend/store"+ v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"+)++// InboxService implements the inbox service.+type InboxService struct {+ v1pb.UnimplementedInboxServiceServer+ store *store.Store+}++// NewInboxService creates a new InboxService.+func NewInboxService(store *store.Store) *InboxService {+ return &InboxService{+ store: store,+ }+}++// ListInbox lists the inbox messages.+func (s *InboxService) ListInbox(ctx context.Context, request *v1pb.ListInboxRequest) (*v1pb.ListInboxResponse, error) {+ filters, err := parseFilter(request.Filter)+ if err != nil {+ return nil, status.Errorf(codes.InvalidArgument, err.Error())+ }++ principalID := ctx.Value(common.PrincipalIDContextKey).(int)+ find := &store.FindInboxMessage{+ ReceiverUID: &principalID,+ }++ for _, spec := range filters {+ switch spec.key {+ case "create_time":+ if spec.operator != comparatorTypeGreaterEqual {+ return nil, status.Errorf(codes.InvalidArgument, `only support ">=" operation for "create_time" filter`)+ }+ t, err := time.Parse(time.RFC3339, spec.value)+ if err != nil {+ return nil, status.Errorf(codes.InvalidArgument, "invalid start_time filter %q", spec.value)+ }+ ts := t.Unix()+ find.ReadCreatedAfterTs = &ts+ default:+ return nil, status.Errorf(codes.InvalidArgument, "unsupport filter %s", spec.key)+ }+ }++ inboxList, err := s.store.FindInbox(ctx, find)+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to list inbox messages with error: %v", err.Error())+ }++ resp := &v1pb.ListInboxResponse{}+ for _, inbox := range inboxList {+ resp.InboxMessages = append(resp.InboxMessages, convertToInboxMessage(inbox))+ }++ return resp, nil+}++// GetInboxSummary gets the inbox summary.+func (s *InboxService) GetInboxSummary(ctx context.Context, _ *v1pb.GetInboxSummaryRequest) (*v1pb.InboxSummary, error) {+ principalID := ctx.Value(common.PrincipalIDContextKey).(int)+ summary, err := s.store.FindInboxSummary(ctx, principalID)+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to find inbox summary with error: %v", err.Error())+ }++ return &v1pb.InboxSummary{+ HasUnread: summary.HasUnread,+ HasUnreadError: summary.HasUnreadError,+ }, nil+}++// UpdateInbox updates the inbox.+func (s *InboxService) UpdateInbox(ctx context.Context, request *v1pb.UpdateInboxRequest) (*v1pb.InboxMessage, error) {+ if request.InboxMessage == nil {+ return nil, status.Errorf(codes.InvalidArgument, "inbox message must be set")+ }+ if request.UpdateMask == nil {+ return nil, status.Errorf(codes.InvalidArgument, "update_mask must be set")+ }++ inboxUID, err := getUIDFromName(request.InboxMessage.Name, inboxNamePrefix)+ if err != nil {+ return nil, status.Errorf(codes.InvalidArgument, err.Error())+ }++ inboxPatch := &store.UpdateInboxMessage{+ UID: inboxUID,+ }++ for _, path := range request.UpdateMask.Paths {+ switch path {+ case "status":+ inboxStatus, err := converToInboxAPIStatus(request.InboxMessage.Status)+ if err != nil {+ return nil, err+ }+ inboxPatch.Status = inboxStatus+ default:+ return nil, status.Errorf(codes.InvalidArgument, "unsupport update_mask %s", path)+ }+ }++ inbox, err := s.store.PatchInbox(ctx, inboxPatch)+ if err != nil {+ if common.ErrorCode(err) == common.NotFound {+ return nil, status.Errorf(codes.NotFound, "cannot found inbox message %s", request.InboxMessage.Name)+ }+ return nil, status.Errorf(codes.Internal, "failed to update inbox message %s with error: %v", request.InboxMessage.Name, err.Error())+ }++ return convertToInboxMessage(inbox), nil+}++func converToInboxAPIStatus(inboxStatus v1pb.InboxMessage_Status) (api.InboxStatus, error) {+ switch inboxStatus {+ case v1pb.InboxMessage_STATUS_READ:+ return api.Read, nil+ case v1pb.InboxMessage_STATUS_UNREAD:+ return api.Unread, nil+ default:+ return api.Unread, status.Errorf(codes.InvalidArgument, "invalid inbox status %v", inboxStatus)+ }+}++func convertToInboxMessage(inbox *store.InboxMessage) *v1pb.InboxMessage {+ status := v1pb.InboxMessage_STATUS_UNSPECIFIED+ switch inbox.Status {+ case api.Unread:+ status = v1pb.InboxMessage_STATUS_UNREAD+ case api.Read:+ status = v1pb.InboxMessage_STATUS_READ+ }+ return &v1pb.InboxMessage{+ Name: fmt.Sprintf("%s%d", inboxNamePrefix, inbox.UID),+ ActivityUid: fmt.Sprintf("%d", inbox.ActivityUID),+ Status: status,+ }+}diff --git a/backend/component/activity/manager.go b/backend/component/activity/manager.goindex fef2e2d6c2..69e364d0e6 100644--- a/backend/component/activity/manager.go+++ b/backend/component/activity/manager.go@@ -503,32 +503,29 @@ func (m *Manager) getWebhookContext(ctx context.Context, activity *api.Activity,func (m *Manager) postInboxIssueActivity(ctx context.Context, issue *store.IssueMessage, activityID int) error {if issue.Creator.ID != api.SystemBotID {- inboxCreate := &api.InboxCreate{- ReceiverID: issue.Creator.ID,- ActivityID: activityID,- }- if _, err := m.store.CreateInbox(ctx, inboxCreate); err != nil {+ if _, err := m.store.CreateInbox(ctx, &store.InboxMessage{+ ReceiverUID: issue.Creator.ID,+ ActivityUID: activityID,+ }); err != nil {return errors.Wrapf(err, "failed to post activity to creator inbox: %d", issue.Creator.ID)}}if issue.Assignee.ID != api.SystemBotID && issue.Assignee.ID != issue.Creator.ID {- inboxCreate := &api.InboxCreate{- ReceiverID: issue.Assignee.ID,- ActivityID: activityID,- }- if _, err := m.store.CreateInbox(ctx, inboxCreate); err != nil {+ if _, err := m.store.CreateInbox(ctx, &store.InboxMessage{+ ReceiverUID: issue.Assignee.ID,+ ActivityUID: activityID,+ }); err != nil {return errors.Wrapf(err, "failed to post activity to assignee inbox: %d", issue.Assignee.ID)}}for _, subscriber := range issue.Subscribers {if subscriber.ID != api.SystemBotID && subscriber.ID != issue.Creator.ID && subscriber.ID != issue.Assignee.ID {- inboxCreate := &api.InboxCreate{- ReceiverID: subscriber.ID,- ActivityID: activityID,- }- if _, err := m.store.CreateInbox(ctx, inboxCreate); err != nil {+ if _, err := m.store.CreateInbox(ctx, &store.InboxMessage{+ ReceiverUID: subscriber.ID,+ ActivityUID: activityID,+ }); err != nil {return errors.Wrapf(err, "failed to post activity to subscriber inbox: %d", subscriber.ID)}}diff --git a/backend/legacyapi/inbox.go b/backend/legacyapi/inbox.goindex ecbc97e575..82a0ce58b7 100644--- a/backend/legacyapi/inbox.go+++ b/backend/legacyapi/inbox.go@@ -1,9 +1,5 @@package api-import (- "encoding/json"-)-// InboxStatus is the status for inboxes.type InboxStatus string@@ -13,54 +9,3 @@ const (// Read is the inbox status for READ.Read InboxStatus = "READ")--// Inbox is the API message for an inbox.-type Inbox struct {- ID int `jsonapi:"primary,inbox"`-- // Domain specific fields- ReceiverID int `jsonapi:"attr,receiverId"`- ActivityID int `jsonapi:"attr,activityId"`- Status InboxStatus `jsonapi:"attr,status"`-}--// InboxCreate is the API message for creating an inbox.-type InboxCreate struct {- // Domain specific fields- ReceiverID int- ActivityID int-}--// InboxFind is the API message for finding inboxes.-type InboxFind struct {- ID *int-- // Domain specific fields- ReceiverID *int- // If specified, then it will only fetch "UNREAD" item or "READ" item whose activity created after "CreatedAfterTs"- ReadCreatedAfterTs *int64-}--func (find *InboxFind) String() string {- str, err := json.Marshal(*find)- if err != nil {- return err.Error()- }- return string(str)-}--// InboxPatch is the API message for patching an inbox.-type InboxPatch struct {- ID int-- // Domain specific fields- Status InboxStatus `jsonapi:"attr,status"`-}--// InboxSummary is the API message for inbox summary info.-// This is used by the frontend to render the inbox sidebar item without fetching the actual inbox items.-// This returns json instead of jsonapi since it't not dealing with a particular resource.-type InboxSummary struct {- HasUnread bool `json:"hasUnread"`- HasUnreadError bool `json:"hasUnreadError"`-}diff --git a/backend/server/acl.go b/backend/server/acl.goindex 8d64af30d4..9ea210f82a 100644--- a/backend/server/acl.go+++ b/backend/server/acl.go@@ -183,8 +183,6 @@ func enforceWorkspaceDeveloperProjectRouteACL(plan api.PlanType, path string, mefunc isOperatingSelf(ctx context.Context, c echo.Context, s *Server, curPrincipalID int, method string, path string) (bool, error) {switch method {- case http.MethodGet:- return isGettingSelf(ctx, c, s, curPrincipalID, path)case http.MethodPatch, http.MethodDelete:return isUpdatingSelf(ctx, c, s, curPrincipalID, path)default:@@ -192,19 +190,6 @@ func isOperatingSelf(ctx context.Context, c echo.Context, s *Server, curPrincipa}}-func isGettingSelf(_ context.Context, c echo.Context, _ *Server, curPrincipalID int, path string) (bool, error) {- if strings.HasPrefix(path, "/inbox/user") {- userID, err := strconv.Atoi(c.Param("userID"))- if err != nil {- return false, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("User ID is not a number: %s", c.Param("userID"))).SetInternal(err)- }-- return userID == curPrincipalID, nil- }-- return false, nil-}-func isUpdatingSelf(ctx context.Context, c echo.Context, s *Server, curPrincipalID int, path string) (bool, error) {const defaultErrMsg = "Failed to process authorize request."if strings.HasPrefix(path, "/principal") {@@ -229,23 +214,6 @@ func isUpdatingSelf(ctx context.Context, c echo.Context, s *Server, curPrincipalreturn activity.CreatorID == curPrincipalID, nil}- } else if strings.HasPrefix(path, "/inbox") {- if inboxIDStr := c.Param("inboxID"); inboxIDStr != "" {- inboxID, err := strconv.Atoi(inboxIDStr)- if err != nil {- return false, echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Inbox ID is not a number: %s", inboxIDStr)).SetInternal(err)- }-- inbox, err := s.store.GetInboxByID(ctx, inboxID)- if err != nil {- return false, echo.NewHTTPError(http.StatusInternalServerError, defaultErrMsg).SetInternal(err)- }- if inbox == nil {- return false, echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Inbox ID not found: %d", inboxID)).SetInternal(err)- }-- return inbox.ReceiverID == curPrincipalID, nil- }}return false, nil}diff --git a/backend/server/acl_casbin_policy_dba.csv b/backend/server/acl_casbin_policy_dba.csvindex bc9e2e4c24..c2ec3a0f45 100644--- a/backend/server/acl_casbin_policy_dba.csv+++ b/backend/server/acl_casbin_policy_dba.csv@@ -75,9 +75,6 @@ p, DBA, /issue/{issueID}/subscriber, POSTp, DBA, /issue/{issueID}/subscriber/{subscriberID}, DELETEp, DBA, /activity, POSTp, DBA, /activity/{activityID}, PATCH_SELF-p, DBA, /inbox/user/{userID}, GET_SELF-p, DBA, /inbox/user/{userID}/summary, GET_SELF-p, DBA, /inbox/{inboxID}, PATCH_SELFp, DBA, /pipeline/{pipelineID}/stage/{stageID}/status, PATCHp, DBA, /pipeline/{pipelineID}/task/all, PATCHp, DBA, /pipeline/{pipelineID}/task/{taskID}, PATCHdiff --git a/backend/server/acl_casbin_policy_developer.csv b/backend/server/acl_casbin_policy_developer.csvindex bfcceb636a..f56db06741 100644--- a/backend/server/acl_casbin_policy_developer.csv+++ b/backend/server/acl_casbin_policy_developer.csv@@ -63,9 +63,6 @@ p, DEVELOPER, /issue/{issueID}/subscriber, POSTp, DEVELOPER, /issue/{issueID}/subscriber/{subscriberID}, DELETEp, DEVELOPER, /activity, POSTp, DEVELOPER, /activity/{activityID}, PATCH_SELF-p, DEVELOPER, /inbox/user/{userID}, GET_SELF-p, DEVELOPER, /inbox/user/{userID}/summary, GET_SELF-p, DEVELOPER, /inbox/{inboxID}, PATCH_SELFp, DEVELOPER, /pipeline/{pipelineID}/stage/{stageID}/status, PATCHp, DEVELOPER, /pipeline/{pipelineID}/task/all, PATCHp, DEVELOPER, /pipeline/{pipelineID}/task/{taskID}, PATCHdiff --git a/backend/server/acl_casbin_policy_owner.csv b/backend/server/acl_casbin_policy_owner.csvindex 86c1e22e36..5d701a1eaa 100644--- a/backend/server/acl_casbin_policy_owner.csv+++ b/backend/server/acl_casbin_policy_owner.csv@@ -78,9 +78,6 @@ p, OWNER, /issue/{issueID}/subscriber, POSTp, OWNER, /issue/{issueID}/subscriber/{subscriberID}, DELETEp, OWNER, /activity, POSTp, OWNER, /activity/{activityID}, PATCH_SELF-p, OWNER, /inbox/user/{userID}, GET_SELF-p, OWNER, /inbox/user/{userID}/summary, GET_SELF-p, OWNER, /inbox/{inboxID}, PATCH_SELFp, OWNER, /pipeline/{pipelineID}/stage/{stageID}/status, PATCHp, OWNER, /pipeline/{pipelineID}/task/all, PATCHp, OWNER, /pipeline/{pipelineID}/task/{taskID}, PATCHdiff --git a/backend/server/inbox.go b/backend/server/inbox.godeleted file mode 100644index 5355bfc519..0000000000--- a/backend/server/inbox.go+++ /dev/null@@ -1,90 +0,0 @@-package server--import (- "fmt"- "net/http"- "strconv"-- "github.com/google/jsonapi"- "github.com/labstack/echo/v4"-- "github.com/bytebase/bytebase/backend/common"- api "github.com/bytebase/bytebase/backend/legacyapi"-)--func (s *Server) registerInboxRoutes(g *echo.Group) {- g.GET("/inbox/user/:userID", func(c echo.Context) error {- ctx := c.Request().Context()- userID, err := strconv.Atoi(c.Param("userID"))- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("User ID is not a number: %s", c.Param("userID"))).SetInternal(err)- }-- inboxFind := &api.InboxFind{- ReceiverID: &userID,- }-- createdAfterStr := c.QueryParams().Get("created")- if createdAfterStr != "" {- createdTs, err := strconv.ParseInt(createdAfterStr, 10, 64)- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Query parameter created is not a number: %s", createdAfterStr)).SetInternal(err)- }- inboxFind.ReadCreatedAfterTs = &createdTs- }- inboxList, err := s.store.FindInbox(ctx, inboxFind)- if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to fetch inbox list").SetInternal(err)- }-- c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, inboxList); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal inbox list response").SetInternal(err)- }- return nil- })-- g.GET("/inbox/user/:userID/summary", func(c echo.Context) error {- ctx := c.Request().Context()- userID, err := strconv.Atoi(c.Param("userID"))- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("User ID is not a number: %s", c.Param("userID"))).SetInternal(err)- }-- summary, err := s.store.FindInboxSummary(ctx, userID)- if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch inbox summary for user ID: %d", userID)).SetInternal(err)- }-- return c.JSON(http.StatusOK, summary)- })-- g.PATCH("/inbox/:inboxID", func(c echo.Context) error {- ctx := c.Request().Context()- id, err := strconv.Atoi(c.Param("inboxID"))- if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("inboxID"))).SetInternal(err)- }-- inboxPatch := &api.InboxPatch{- ID: id,- }- if err := jsonapi.UnmarshalPayload(c.Request().Body, inboxPatch); err != nil {- return echo.NewHTTPError(http.StatusBadRequest, "Malformed patch inbox request").SetInternal(err)- }-- inbox, err := s.store.PatchInbox(ctx, inboxPatch)- if err != nil {- if common.ErrorCode(err) == common.NotFound {- return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Inbox ID not found: %d", id))- }- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to patch inbox ID: %v", id)).SetInternal(err)- }-- c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)- if err := jsonapi.MarshalPayload(c.Response().Writer, inbox); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to marshal inbox ID response: %v", id)).SetInternal(err)- }- return nil- })-}diff --git a/backend/server/server.go b/backend/server/server.goindex c9e16d8f1a..91678d582c 100644--- a/backend/server/server.go+++ b/backend/server/server.go@@ -517,7 +517,6 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {s.registerTaskRoutes(apiGroup)s.registerStageRoutes(apiGroup)s.registerActivityRoutes(apiGroup)- s.registerInboxRoutes(apiGroup)s.registerSQLRoutes(apiGroup)s.registerAnomalyRoutes(apiGroup)@@ -602,6 +601,7 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {v1pb.RegisterCelServiceServer(s.grpcServer, v1.NewCelService())v1pb.RegisterLoggingServiceServer(s.grpcServer, v1.NewLoggingService(s.store))v1pb.RegisterBookmarkServiceServer(s.grpcServer, v1.NewBookmarkService(s.store))+ v1pb.RegisterInboxServiceServer(s.grpcServer, v1.NewInboxService(s.store))reflection.Register(s.grpcServer)// REST gateway proxy.@@ -668,6 +668,9 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {if err := v1pb.RegisterBookmarkServiceHandler(ctx, mux, grpcConn); err != nil {return nil, err}+ if err := v1pb.RegisterInboxServiceHandler(ctx, mux, grpcConn); err != nil {+ return nil, err+ }e.Any("/v1/*", echo.WrapHandler(mux))// GRPC web proxy.options := []grpcweb.Option{diff --git a/backend/store/inbox.go b/backend/store/inbox.goindex 2714c4fc6c..39541105eb 100644--- a/backend/store/inbox.go+++ b/backend/store/inbox.go@@ -12,111 +12,42 @@ import (api "github.com/bytebase/bytebase/backend/legacyapi")-// inboxRaw is the store model for an Inbox.-// Fields have exactly the same meanings as Inbox.-type inboxRaw struct {- ID int+// InboxMessage is the API message for inbox.+type InboxMessage struct {+ UID int// Domain specific fields- ReceiverID int- ActivityID int- Status api.InboxStatus+ ReceiverUID int+ ActivityUID int+ Status api.InboxStatus}-// toInbox creates an instance of Inbox based on the inboxRaw.-// This is intended to be called when we need to compose an Inbox relationship.-func (raw *inboxRaw) toInbox() *api.Inbox {- return &api.Inbox{- ID: raw.ID,-- ReceiverID: raw.ReceiverID,- ActivityID: raw.ActivityID,- Status: raw.Status,- }-}--// CreateInbox creates an instance of Inbox.-func (s *Store) CreateInbox(ctx context.Context, create *api.InboxCreate) (*api.Inbox, error) {- inboxRaw, err := s.createInboxRaw(ctx, create)- if err != nil {- return nil, errors.Wrapf(err, "failed to create Inbox with InboxCreate[%+v]", create)- }- return inboxRaw.toInbox(), nil+// InboxSummaryMessage is the API message for inbox summary info.+// This is used by the frontend to render the inbox sidebar item without fetching the actual inbox items.+// This returns json instead of jsonapi since it't not dealing with a particular resource.+type InboxSummaryMessage struct {+ HasUnread bool+ HasUnreadError bool}-// GetInboxByID gets an instance of Inbox.-func (s *Store) GetInboxByID(ctx context.Context, id int) (*api.Inbox, error) {- find := &api.InboxFind{ID: &id}- inboxRaw, err := s.getInboxRawByID(ctx, find)- if err != nil {- return nil, errors.Wrapf(err, "failed to get Inbox with ID %d", id)- }- if inboxRaw == nil {- return nil, nil- }- return inboxRaw.toInbox(), nil-}--// FindInbox finds a list of Inbox instances.-func (s *Store) FindInbox(ctx context.Context, find *api.InboxFind) ([]*api.Inbox, error) {- inboxRawList, err := s.findInboxRaw(ctx, find)- if err != nil {- return nil, errors.Wrapf(err, "failed to find Inbox list with InboxFind[%+v]", find)- }- var inboxList []*api.Inbox- for _, raw := range inboxRawList {- inboxList = append(inboxList, raw.toInbox())- }- return inboxList, nil-}--// PatchInbox patches an instance of Inbox.-func (s *Store) PatchInbox(ctx context.Context, patch *api.InboxPatch) (*api.Inbox, error) {- inboxRaw, err := s.patchInboxRaw(ctx, patch)- if err != nil {- return nil, errors.Wrapf(err, "failed to patch Inbox with InboxPatch[%+v]", patch)- }- return inboxRaw.toInbox(), nil+// FindInboxMessage is the API message for finding the inbox.+type FindInboxMessage struct {+ // Domain specific fields+ ReceiverUID *int+ // If specified, then it will only fetch "UNREAD" item or "READ" item whose activity created after "CreatedAfterTs"+ ReadCreatedAfterTs *int64}-// FindInboxSummary returns the inbox summary for a particular principal.-func (s *Store) FindInboxSummary(ctx context.Context, principalID int) (*api.InboxSummary, error) {- tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})- if err != nil {- return nil, err- }- defer tx.Rollback()-- query := `SELECT EXISTS (SELECT 1 FROM inbox WHERE receiver_id = $1 AND status = 'UNREAD')`- var inboxSummary api.InboxSummary- if err := tx.QueryRowContext(ctx, query, principalID).Scan(&inboxSummary.HasUnread); err != nil {- if err == sql.ErrNoRows {- return nil, common.FormatDBErrorEmptyRowWithQuery(query)- }- return nil, err- }-- if inboxSummary.HasUnread {- query2 := `SELECT EXISTS (SELECT 1 FROM inbox, activity WHERE inbox.receiver_id = $1 AND inbox.status = 'UNREAD' AND inbox.activity_id = activity.id AND activity.level = 'ERROR')`- if err := tx.QueryRowContext(ctx, query2, principalID).Scan(&inboxSummary.HasUnreadError); err != nil {- if err == sql.ErrNoRows {- return nil, common.FormatDBErrorEmptyRowWithQuery(query2)- }- return nil, err- }- } else {- inboxSummary.HasUnreadError = false- }+// UpdateInboxMessage is the API message to update the inbox.+type UpdateInboxMessage struct {+ UID int- return &inboxSummary, nil+ // Domain specific fields+ Status api.InboxStatus}-//-// private function-//--// createInboxRaw creates a new inbox.-func (s *Store) createInboxRaw(ctx context.Context, create *api.InboxCreate) (*inboxRaw, error) {+// CreateInbox creates an instance of Inbox.+func (s *Store) CreateInbox(ctx context.Context, create *InboxMessage) (*InboxMessage, error) {tx, err := s.db.BeginTx(ctx, nil)if err != nil {return nil, err@@ -135,8 +66,8 @@ func (s *Store) createInboxRaw(ctx context.Context, create *api.InboxCreate) (*ireturn inbox, nil}-// findInboxRaw retrieves a list of inboxes based on find.-func (s *Store) findInboxRaw(ctx context.Context, find *api.InboxFind) ([]*inboxRaw, error) {+// FindInbox finds a list of Inbox instances.+func (s *Store) FindInbox(ctx context.Context, find *FindInboxMessage) ([]*InboxMessage, error) {tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})if err != nil {return nil, err@@ -151,51 +82,65 @@ func (s *Store) findInboxRaw(ctx context.Context, find *api.InboxFind) ([]*inboxreturn list, nil}-// getInboxRawByID retrieves a single inbox based on find.-// Returns ECONFLICT if finding more than 1 matching records.-func (s *Store) getInboxRawByID(ctx context.Context, find *api.InboxFind) (*inboxRaw, error) {- tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})+// PatchInbox patches an instance of Inbox.+// Returns ENOTFOUND if inbox does not exist.+func (s *Store) PatchInbox(ctx context.Context, patch *UpdateInboxMessage) (*InboxMessage, error) {+ tx, err := s.db.BeginTx(ctx, nil)if err != nil {return nil, err}defer tx.Rollback()- list, err := findInboxImpl(ctx, tx, find)+ inbox, err := patchInboxImpl(ctx, tx, patch)if err != nil {return nil, err}- if len(list) == 0 {- return nil, nil- } else if len(list) > 1 {- return nil, &common.Error{Code: common.Conflict, Err: errors.Errorf("found %d inboxes with filter %+v, expect 1", len(list), find)}+ if err := tx.Commit(); err != nil {+ return nil, err}- return list[0], nil++ return inbox, nil}-// patchInboxRaw updates an existing inbox by ID.-// Returns ENOTFOUND if inbox does not exist.-func (s *Store) patchInboxRaw(ctx context.Context, patch *api.InboxPatch) (*inboxRaw, error) {- tx, err := s.db.BeginTx(ctx, nil)+// FindInboxSummary returns the inbox summary for a particular principal.+func (s *Store) FindInboxSummary(ctx context.Context, principalID int) (*InboxSummaryMessage, error) {+ tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})if err != nil {return nil, err}defer tx.Rollback()- inbox, err := patchInboxImpl(ctx, tx, patch)- if err != nil {+ query := `SELECT EXISTS (SELECT 1 FROM inbox WHERE receiver_id = $1 AND status = 'UNREAD')`+ var inboxSummary InboxSummaryMessage+ if err := tx.QueryRowContext(ctx, query, principalID).Scan(&inboxSummary.HasUnread); err != nil {+ if err == sql.ErrNoRows {+ return nil, common.FormatDBErrorEmptyRowWithQuery(query)+ }return nil, err}- if err := tx.Commit(); err != nil {- return nil, err+ if inboxSummary.HasUnread {+ query2 := `SELECT EXISTS (SELECT 1 FROM inbox, activity WHERE inbox.receiver_id = $1 AND inbox.status = 'UNREAD' AND inbox.activity_id = activity.id AND activity.level = 'ERROR')`+ if err := tx.QueryRowContext(ctx, query2, principalID).Scan(&inboxSummary.HasUnreadError); err != nil {+ if err == sql.ErrNoRows {+ return nil, common.FormatDBErrorEmptyRowWithQuery(query2)+ }+ return nil, err+ }+ } else {+ inboxSummary.HasUnreadError = false}- return inbox, nil+ return &inboxSummary, nil}+//+// private function+//+// createInboxImpl creates a new inbox.-func createInboxImpl(ctx context.Context, tx *Tx, create *api.InboxCreate) (*inboxRaw, error) {+func createInboxImpl(ctx context.Context, tx *Tx, create *InboxMessage) (*InboxMessage, error) {// Insert row into database.query := `INSERT INTO inbox (@@ -206,31 +151,28 @@ func createInboxImpl(ctx context.Context, tx *Tx, create *api.InboxCreate) (*inbVALUES ($1, $2, 'UNREAD')RETURNING id, receiver_id, activity_id, status`- var inboxRaw inboxRaw+ var response InboxMessageif err := tx.QueryRowContext(ctx, query,- create.ReceiverID,- create.ActivityID,+ create.ReceiverUID,+ create.ActivityUID,).Scan(- &inboxRaw.ID,- &inboxRaw.ReceiverID,- &inboxRaw.ActivityID,- &inboxRaw.Status,+ &response.UID,+ &response.ReceiverUID,+ &response.ActivityUID,+ &response.Status,); err != nil {if err == sql.ErrNoRows {return nil, common.FormatDBErrorEmptyRowWithQuery(query)}return nil, err}- return &inboxRaw, nil+ return &response, nil}-func findInboxImpl(ctx context.Context, tx *Tx, find *api.InboxFind) ([]*inboxRaw, error) {+func findInboxImpl(ctx context.Context, tx *Tx, find *FindInboxMessage) ([]*InboxMessage, error) {// Build WHERE clause.where, args := []string{"TRUE"}, []any{}- if v := find.ID; v != nil {- where, args = append(where, fmt.Sprintf("inbox.id = $%d", len(args)+1)), append(args, *v)- }- if v := find.ReceiverID; v != nil {+ if v := find.ReceiverUID; v != nil {where, args = append(where, fmt.Sprintf("receiver_id = $%d", len(args)+1)), append(args, *v)}if v := find.ReadCreatedAfterTs; v != nil {@@ -254,34 +196,34 @@ func findInboxImpl(ctx context.Context, tx *Tx, find *api.InboxFind) ([]*inboxRa}defer rows.Close()- // Iterate over result set and deserialize rows into inboxRawList.- var inboxRawList []*inboxRaw+ // Iterate over result set and deserialize rows into inboxList.+ var inboxList []*InboxMessagefor rows.Next() {- var inboxRaw inboxRaw+ var inbox InboxMessageif err := rows.Scan(- &inboxRaw.ID,- &inboxRaw.ReceiverID,- &inboxRaw.ActivityID,- &inboxRaw.Status,+ &inbox.UID,+ &inbox.ReceiverUID,+ &inbox.ActivityUID,+ &inbox.Status,); err != nil {return nil, err}- inboxRawList = append(inboxRawList, &inboxRaw)+ inboxList = append(inboxList, &inbox)}if err := rows.Err(); err != nil {return nil, err}- return inboxRawList, nil+ return inboxList, nil}// patchInboxImpl updates a inbox by ID. Returns the new state of the inbox after update.-func patchInboxImpl(ctx context.Context, tx *Tx, patch *api.InboxPatch) (*inboxRaw, error) {+func patchInboxImpl(ctx context.Context, tx *Tx, patch *UpdateInboxMessage) (*InboxMessage, error) {// Build UPDATE clause.set, args := []string{"status = $1"}, []any{patch.Status}- args = append(args, patch.ID)+ args = append(args, patch.UID)- var inboxRaw inboxRaw+ var response InboxMessage// Execute update query with RETURNING.if err := tx.QueryRowContext(ctx, `UPDATE inbox@@ -291,15 +233,15 @@ func patchInboxImpl(ctx context.Context, tx *Tx, patch *api.InboxPatch) (*inboxR`,args...,).Scan(- &inboxRaw.ID,- &inboxRaw.ReceiverID,- &inboxRaw.ActivityID,- &inboxRaw.Status,+ &response.UID,+ &response.ReceiverUID,+ &response.ActivityUID,+ &response.Status,); err != nil {if err == sql.ErrNoRows {- return nil, &common.Error{Code: common.NotFound, Err: errors.Errorf("inbox ID not found: %d", patch.ID)}+ return nil, &common.Error{Code: common.NotFound, Err: errors.Errorf("inbox ID not found: %d", patch.UID)}}return nil, err}- return &inboxRaw, nil+ return &response, nil}diff --git a/frontend/src/components/InboxList.vue b/frontend/src/components/InboxList.vueindex 0470a0663c..5727ad63cd 100644--- a/frontend/src/components/InboxList.vue+++ b/frontend/src/components/InboxList.vue@@ -69,14 +69,14 @@ import {ActivityTaskStatusUpdatePayload,ActivityTaskStatementUpdatePayload,ActivityTaskEarliestAllowedTimeUpdatePayload,- Inbox,+ ComposedInbox,} from "../types";import { useRouter } from "vue-router";import { isEmpty } from "lodash-es";import { issueActivityActionSentence } from "../utils";import { useI18n } from "vue-i18n";import dayjs from "dayjs";-import { useCurrentUser, useInboxStore, useActivityV1Store } from "@/store";+import { useInboxV1Store, useActivityV1Store } from "@/store";import {LogEntity,LogEntity_Action,@@ -84,25 +84,20 @@ import {} from "@/types/proto/v1/logging_service";import { extractUserResourceName, extractUserUID } from "@/utils";import { useUserStore } from "@/store";--interface LocalInbox extends Inbox {- activity: LogEntity;-}+import { InboxMessage_Status } from "@/types/proto/v1/inbox_service";defineProps({inboxList: {required: true,- type: Object as PropType<LocalInbox[]>,+ type: Object as PropType<ComposedInbox[]>,},});const { t } = useI18n();-const inboxStore = useInboxStore();+const inboxV1Store = useInboxV1Store();const activityV1Store = useActivityV1Store();const router = useRouter();-const currentUser = useCurrentUser();-const getUser = (activity: LogEntity) => {const email = extractUserResourceName(activity.creator);return useUserStore().getUserByEmail(email);@@ -235,18 +230,12 @@ const actionSentence = (activity: LogEntity): string => {return "";};-const clickInbox = (inbox: LocalInbox) => {- if (inbox.status == "UNREAD") {- inboxStore- .patchInbox({- inboxId: inbox.id,- inboxPatch: {- status: "READ",- },- })- .then(() => {- inboxStore.fetchInboxSummaryByUser(currentUser.value.id);- });+const clickInbox = (inbox: ComposedInbox) => {+ if (inbox.status == InboxMessage_Status.STATUS_UNREAD) {+ inbox.status = InboxMessage_Status.STATUS_READ;+ inboxV1Store.patchInbox(inbox).then(() => {+ inboxV1Store.fetchInboxSummary();+ });}const link = actionLink(inbox.activity);if (!isEmpty(link)) {diff --git a/frontend/src/grpcweb/index.ts b/frontend/src/grpcweb/index.tsindex 48cecb1ecd..f53844204e 100644--- a/frontend/src/grpcweb/index.ts+++ b/frontend/src/grpcweb/index.ts@@ -27,6 +27,7 @@ import { ActuatorServiceDefinition } from "@/types/proto/v1/actuator_service";import { ExternalVersionControlServiceDefinition } from "@/types/proto/v1/externalvs_service";import { LoggingServiceDefinition } from "@/types/proto/v1/logging_service";import { BookmarkServiceDefinition } from "@/types/proto/v1/bookmark_service";+import { InboxServiceDefinition } from "@/types/proto/v1/inbox_service";// Create each grpc service client.// Reference: https://github.com/deeplay-io/nice-grpc/blob/master/packages/nice-grpc-web/README.md@@ -154,6 +155,11 @@ export const bookmarkServiceClient = clientFactory.create(channel);+export const inboxServiceClient = clientFactory.create(+ InboxServiceDefinition,+ channel+);+// e.g. How to use `authServiceClient`?//// await authServiceClient.login({diff --git a/frontend/src/plugins/demo/index.ts b/frontend/src/plugins/demo/index.tsindex 1b5d66a34d..55183c15c2 100644--- a/frontend/src/plugins/demo/index.ts+++ b/frontend/src/plugins/demo/index.ts@@ -1,4 +1,3 @@-import axios from "axios";import { isNull } from "lodash-es";import { createApp } from "vue";import { isDev } from "@/utils";@@ -10,6 +9,7 @@ import DemoWrapper from "./components/DemoWrapper.vue";import { removeHint } from "./hint";import { removeGuideDialog } from "./guide";import { waitBodyLoaded } from "./utils";+import { actuatorServiceClient } from "@/grpcweb";const initDemo = async (demoName: string) => {await waitBodyLoaded();@@ -40,12 +40,7 @@ const initDemo = async (demoName: string) => {};const mountDemoApp = async () => {- const serverInfo = (- await axios.get<{- demoName: string;- version: string;- }>(`/v1/actuator/info`)- ).data;+ const serverInfo = await actuatorServiceClient.getActuatorInfo({});// only show feature demo if it's not the default demo.if (serverInfo.demoName && serverInfo.demoName != "default") {diff --git a/frontend/src/store/modules/activity.ts b/frontend/src/store/modules/activity.tsindex f797d544f5..e3c43da7c0 100644--- a/frontend/src/store/modules/activity.ts+++ b/frontend/src/store/modules/activity.ts@@ -1,7 +1,7 @@import { defineStore } from "pinia";import axios from "axios";import { cloneDeep } from "lodash-es";-import { ActivityCreate, ActivityId, ActivityPatch, IssueId } from "@/types";+import { ActivityCreate, IdType, ActivityPatch, IssueId } from "@/types";import { useActivityV1Store } from "./v1";export const useActivityLegacyStore = defineStore("activity", {@@ -31,7 +31,7 @@ export const useActivityLegacyStore = defineStore("activity", {issueId,updatedComment,}: {- activityId: ActivityId;+ activityId: IdType;issueId: IssueId;updatedComment: string;}) {diff --git a/frontend/src/store/modules/inbox.ts b/frontend/src/store/modules/inbox.tsdeleted file mode 100644index 1e7768c48e..0000000000--- a/frontend/src/store/modules/inbox.ts+++ /dev/null@@ -1,127 +0,0 @@-import { defineStore } from "pinia";-import axios from "axios";-import {- Inbox,- InboxId,- InboxPatch,- InboxState,- InboxSummary,- PrincipalId,- ResourceObject,-} from "@/types";-import { useActivityV1Store } from "./v1";--async function convert(raw: ResourceObject): Promise<Inbox> {- const inbox: Inbox = {- ...(raw.attributes as Omit<Inbox, "id">),- id: parseInt(raw.id),- };-- try {- const activity = await useActivityV1Store().fetchActivityByUID(- inbox.activityId- );- inbox.activity = activity;- } catch {- // nothing, we will skip inbox with undefined activity.- }- return inbox;-}--export const useInboxStore = defineStore("inbox", {- state: (): InboxState => ({- inboxListByUser: new Map(),- inboxSummaryByUser: new Map(),- }),- actions: {- getInboxListByUser(userId: PrincipalId): Inbox[] {- return this.inboxListByUser.get(userId) || [];- },- getInboxSummaryByUser(userId: PrincipalId): InboxSummary {- return (- this.inboxSummaryByUser.get(userId) || {- hasUnread: false,- hasUnreadError: false,- }- );- },- setInboxListByUser({- userId,- inboxList,- }: {- userId: PrincipalId;- inboxList: Inbox[];- }) {- this.inboxListByUser.set(userId, inboxList);- },- setInboxSummaryByUser({- userId,- inboxSummary,- }: {- userId: PrincipalId;- inboxSummary: InboxSummary;- }) {- this.inboxSummaryByUser.set(userId, inboxSummary);- },- updateInboxById({ inboxId, inbox }: { inboxId: InboxId; inbox: Inbox }) {- for (const [_, inboxList] of this.inboxListByUser) {- const i = inboxList.findIndex((item: Inbox) => item.id == inboxId);- if (i >= 0) {- inboxList[i] = inbox;- }- }- },- async fetchInboxListByUser({- userId,- readCreatedAfterTs,- }: {- userId: PrincipalId;- readCreatedAfterTs?: number;- }) {- let url = `/api/inbox/user/${userId}`;- if (readCreatedAfterTs) {- url += `?created=${readCreatedAfterTs}`;- }- const { data } = (await axios.get(url)).data;- const inboxList = await Promise.all(- (data as ResourceObject[]).map((inbox: ResourceObject) => {- return convert(inbox);- })- );-- this.setInboxListByUser({- userId,- inboxList,- });- return inboxList;- },- async fetchInboxSummaryByUser(userId: PrincipalId) {- const inboxSummary = (- await axios.get(`/api/inbox/user/${userId}/summary`)- ).data;-- this.setInboxSummaryByUser({ userId, inboxSummary });- return inboxSummary;- },- async patchInbox({- inboxId,- inboxPatch,- }: {- inboxId: InboxId;- inboxPatch: InboxPatch;- }) {- const data = (- await axios.patch(`/api/inbox/${inboxId}`, {- data: {- type: "inboxPatch",- attributes: inboxPatch,- },- })- ).data;- const updatedInbox = await convert(data.data);- this.updateInboxById({ inboxId, inbox: updatedInbox });-- return updatedInbox;- },- },-});diff --git a/frontend/src/store/modules/index.ts b/frontend/src/store/modules/index.tsindex 0dfb2e6fc3..cdd1b7d447 100644--- a/frontend/src/store/modules/index.ts+++ b/frontend/src/store/modules/index.ts@@ -8,7 +8,6 @@ export * from "./environment";export * from "./help";export * from "./issue";export * from "./issueSubscriber";-export * from "./inbox";export * from "./instance";export * from "./notification";export * from "./oauth";diff --git a/frontend/src/store/modules/v1/inbox.ts b/frontend/src/store/modules/v1/inbox.tsnew file mode 100644index 0000000000..e03d146113--- /dev/null+++ b/frontend/src/store/modules/v1/inbox.ts@@ -0,0 +1,91 @@+import { defineStore } from "pinia";+import dayjs from "dayjs";+import utc from "dayjs/plugin/utc";+import { reactive } from "vue";+import { InboxMessage, InboxSummary } from "@/types/proto/v1/inbox_service";+import { inboxServiceClient } from "@/grpcweb";+import { useActivityV1Store } from "./activity";+import { ComposedInbox } from "@/types";++dayjs.extend(utc);++export const useInboxV1Store = defineStore("inbox_v1", () => {+ const inboxMessageList = reactive<ComposedInbox[]>([]);+ const inboxSummary = reactive<InboxSummary>({+ hasUnread: false,+ hasUnreadError: false,+ });++ const composeActivity = async (+ inboxMessage: InboxMessage+ ): Promise<ComposedInbox | undefined> => {+ try {+ const activity = await useActivityV1Store().fetchActivityByUID(+ inboxMessage.activityUid+ );+ if (!activity) {+ return;+ }+ return {+ ...inboxMessage,+ activity,+ };+ } catch {+ // nothing, we will skip inbox with undefined activity.+ }+ return;+ };++ const fetchInboxList = async (readCreatedAfterTs: number) => {+ const resp = await inboxServiceClient.listInbox({+ filter: `create_time >= ${dayjs(readCreatedAfterTs).utc().format()}`,+ });++ const list = await Promise.all(resp.inboxMessages.map(composeActivity));+ inboxMessageList.splice(0, inboxMessageList.length);+ for (const inbox of list) {+ if (inbox) {+ inboxMessageList.push(inbox);+ }+ }++ return inboxMessageList;+ };++ const fetchInboxSummary = async () => {+ const summary = await inboxServiceClient.getInboxSummary({});+ inboxSummary.hasUnread = summary.hasUnread;+ inboxSummary.hasUnreadError = summary.hasUnreadError;+ return inboxSummary;+ };++ const patchInbox = async (inboxMessage: Partial<InboxMessage>) => {+ const index = inboxMessageList.findIndex(+ (i) => i.name === inboxMessage.name+ );+ if (index < 0) {+ return;+ }+ const existed = inboxMessageList[index];++ const inbox = await inboxServiceClient.updateInbox({+ inboxMessage,+ updateMask: ["status"],+ });++ inboxMessageList[index] = {+ ...inbox,+ activity: existed.activity,+ };++ return inboxMessageList[index];+ };++ return {+ inboxSummary,+ inboxMessageList,+ fetchInboxList,+ fetchInboxSummary,+ patchInbox,+ };+});diff --git a/frontend/src/store/modules/v1/index.ts b/frontend/src/store/modules/v1/index.tsindex 73a78e38ab..734c67290b 100644--- a/frontend/src/store/modules/v1/index.ts+++ b/frontend/src/store/modules/v1/index.ts@@ -19,3 +19,4 @@ export * from "./changeHistory";export * from "./dbSchema";export * from "./activity";export * from "./bookmark";+export * from "./inbox";diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.tsindex 88d8d17095..d949ac925d 100644--- a/frontend/src/types/common.ts+++ b/frontend/src/types/common.ts@@ -5,7 +5,6 @@ import { Database } from "./database";import { DataSource } from "./dataSource";import { Environment } from "./environment";import { CommandId, CommandRegisterId, PrincipalId } from "./id";-import { Inbox } from "./inbox";import { Instance } from "./instance";import { Issue } from "./issue";import { Pipeline, Stage, Task, TaskProgress } from "./pipeline";@@ -115,7 +114,6 @@ interface ResourceMaker {(type: "STAGE"): Stage;(type: "TASK_PROGRESS"): TaskProgress;(type: "TASK"): Task;- (type: "INBOX"): Inbox;(type: "VCS"): VCS;(type: "ANOMALY"): Anomaly;(type: "SQL_REVIEW"): SQLReviewPolicy;@@ -289,12 +287,6 @@ const makeUnknown = (type: ResourceType) => {progress: { ...UNKNOWN_TASK_PROGRESS },};- const UNKNOWN_INBOX: Inbox = {- id: UNKNOWN_ID,- activityId: UNKNOWN_ID,- status: "READ",- };-const UNKNOWN_VCS: VCS = {id: UNKNOWN_ID,name: "",@@ -352,8 +344,6 @@ const makeUnknown = (type: ResourceType) => {return UNKNOWN_TASK_PROGRESS;case "TASK":return UNKNOWN_TASK;- case "INBOX":- return UNKNOWN_INBOX;case "VCS":return UNKNOWN_VCS;case "ANOMALY":@@ -531,12 +521,6 @@ const makeEmpty = (type: ResourceType) => {progress: { ...EMPTY_TASK_PROGRESS },};- const EMPTY_INBOX: Inbox = {- id: EMPTY_ID,- activityId: EMPTY_ID,- status: "READ",- };-const EMPTY_VCS: VCS = {id: EMPTY_ID,name: "",@@ -594,8 +578,6 @@ const makeEmpty = (type: ResourceType) => {return EMPTY_TASK_PROGRESS;case "TASK":return EMPTY_TASK;- case "INBOX":- return EMPTY_INBOX;case "VCS":return EMPTY_VCS;case "ANOMALY":diff --git a/frontend/src/types/id.ts b/frontend/src/types/id.tsindex 8c950aba1d..60befd8577 100644--- a/frontend/src/types/id.ts+++ b/frontend/src/types/id.ts@@ -30,10 +30,6 @@ export type TaskRunId = IdType;export type TaskCheckRunId = IdType;-export type ActivityId = IdType;--export type InboxId = IdType;-export type EnvironmentId = IdType;export type InstanceId = IdType;diff --git a/frontend/src/types/inbox.ts b/frontend/src/types/inbox.tsindex 7f7f625e5a..ef19aaaf5b 100644--- a/frontend/src/types/inbox.ts+++ b/frontend/src/types/inbox.ts@@ -1,22 +1,6 @@-import { IdType, InboxId } from "./id";import { LogEntity } from "@/types/proto/v1/logging_service";+import { InboxMessage } from "@/types/proto/v1/inbox_service";-export type InboxStatus = "UNREAD" | "READ";--export type Inbox = {- id: InboxId;-- // Domain specific fields- activityId: IdType;- activity?: LogEntity;- status: InboxStatus;-};--export type InboxPatch = {- status: InboxStatus;-};--export type InboxSummary = {- hasUnread: boolean;- hasUnreadError: boolean;-};+export interface ComposedInbox extends InboxMessage {+ activity: LogEntity;+}diff --git a/frontend/src/types/proto/v1/inbox_service.ts b/frontend/src/types/proto/v1/inbox_service.tsnew file mode 100644index 0000000000..c58e3f33e7--- /dev/null+++ b/frontend/src/types/proto/v1/inbox_service.ts@@ -0,0 +1,691 @@+/* eslint-disable */+import type { CallContext, CallOptions } from "nice-grpc-common";+import * as _m0 from "protobufjs/minimal";+import { FieldMask } from "../google/protobuf/field_mask";++export const protobufPackage = "bytebase.v1";++export interface ListInboxRequest {+ /**+ * filter is the filter to apply on the list inbox request,+ * follow the [ebnf](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form) syntax.+ * The field only support in filter:+ * - "create_time" with ">=" operator, example:+ * - create_time >= "2022-01-01T12:00:00.000Z"+ */+ filter: string;+ /**+ * Not used. The maximum number of inbox to return.+ * The service may return fewer than this value.+ * If unspecified, at most 100 log entries will be returned.+ * The maximum value is 1000; values above 1000 will be coerced to 1000.+ */+ pageSize: number;+ /**+ * Not used. A page token, received from a previous `ListInbox` call.+ * Provide this to retrieve the subsequent page.+ */+ pageToken: string;+}++export interface ListInboxResponse {+ /** The list of inbox messages. */+ inboxMessages: InboxMessage[];+ /**+ * A token to retrieve next page of inbox.+ * Pass this value in the page_token field in the subsequent call to `ListLogs` method+ * to retrieve the next page of log entities.+ */+ nextPageToken: string;+}++export interface GetInboxSummaryRequest {+}++export interface UpdateInboxRequest {+ /** The inbox message to update. */+ inboxMessage?: InboxMessage;+ /** The list of fields to update. */+ updateMask?: string[];+}++export interface InboxMessage {+ /** The message name in inbox/{uid} format. */+ name: string;+ activityUid: string;+ status: InboxMessage_Status;+}++export enum InboxMessage_Status {+ STATUS_UNSPECIFIED = 0,+ STATUS_UNREAD = 1,+ STATUS_READ = 2,+ UNRECOGNIZED = -1,+}++export function inboxMessage_StatusFromJSON(object: any): InboxMessage_Status {+ switch (object) {+ case 0:+ case "STATUS_UNSPECIFIED":+ return InboxMessage_Status.STATUS_UNSPECIFIED;+ case 1:+ case "STATUS_UNREAD":+ return InboxMessage_Status.STATUS_UNREAD;+ case 2:+ case "STATUS_READ":+ return InboxMessage_Status.STATUS_READ;+ case -1:+ case "UNRECOGNIZED":+ default:+ return InboxMessage_Status.UNRECOGNIZED;+ }+}++export function inboxMessage_StatusToJSON(object: InboxMessage_Status): string {+ switch (object) {+ case InboxMessage_Status.STATUS_UNSPECIFIED:+ return "STATUS_UNSPECIFIED";+ case InboxMessage_Status.STATUS_UNREAD:+ return "STATUS_UNREAD";+ case InboxMessage_Status.STATUS_READ:+ return "STATUS_READ";+ case InboxMessage_Status.UNRECOGNIZED:+ default:+ return "UNRECOGNIZED";+ }+}++export interface InboxSummary {+ hasUnread: boolean;+ hasUnreadError: boolean;+}++function createBaseListInboxRequest(): ListInboxRequest {+ return { filter: "", pageSize: 0, pageToken: "" };+}++export const ListInboxRequest = {+ encode(message: ListInboxRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ if (message.filter !== "") {+ writer.uint32(10).string(message.filter);+ }+ if (message.pageSize !== 0) {+ writer.uint32(16).int32(message.pageSize);+ }+ if (message.pageToken !== "") {+ writer.uint32(26).string(message.pageToken);+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): ListInboxRequest {+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseListInboxRequest();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ if (tag !== 10) {+ break;+ }++ message.filter = reader.string();+ continue;+ case 2:+ if (tag !== 16) {+ break;+ }++ message.pageSize = reader.int32();+ continue;+ case 3:+ if (tag !== 26) {+ break;+ }++ message.pageToken = reader.string();+ continue;+ }+ if ((tag & 7) === 4 || tag === 0) {+ break;+ }+ reader.skipType(tag & 7);+ }+ return message;+ },++ fromJSON(object: any): ListInboxRequest {+ return {+ filter: isSet(object.filter) ? String(object.filter) : "",+ pageSize: isSet(object.pageSize) ? Number(object.pageSize) : 0,+ pageToken: isSet(object.pageToken) ? String(object.pageToken) : "",+ };+ },++ toJSON(message: ListInboxRequest): unknown {+ const obj: any = {};+ message.filter !== undefined && (obj.filter = message.filter);+ message.pageSize !== undefined && (obj.pageSize = Math.round(message.pageSize));+ message.pageToken !== undefined && (obj.pageToken = message.pageToken);+ return obj;+ },++ create(base?: DeepPartial<ListInboxRequest>): ListInboxRequest {+ return ListInboxRequest.fromPartial(base ?? {});+ },++ fromPartial(object: DeepPartial<ListInboxRequest>): ListInboxRequest {+ const message = createBaseListInboxRequest();+ message.filter = object.filter ?? "";+ message.pageSize = object.pageSize ?? 0;+ message.pageToken = object.pageToken ?? "";+ return message;+ },+};++function createBaseListInboxResponse(): ListInboxResponse {+ return { inboxMessages: [], nextPageToken: "" };+}++export const ListInboxResponse = {+ encode(message: ListInboxResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ for (const v of message.inboxMessages) {+ InboxMessage.encode(v!, writer.uint32(10).fork()).ldelim();+ }+ if (message.nextPageToken !== "") {+ writer.uint32(18).string(message.nextPageToken);+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): ListInboxResponse {+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseListInboxResponse();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ if (tag !== 10) {+ break;+ }++ message.inboxMessages.push(InboxMessage.decode(reader, reader.uint32()));+ continue;+ case 2:+ if (tag !== 18) {+ break;+ }++ message.nextPageToken = reader.string();+ continue;+ }+ if ((tag & 7) === 4 || tag === 0) {+ break;+ }+ reader.skipType(tag & 7);+ }+ return message;+ },++ fromJSON(object: any): ListInboxResponse {+ return {+ inboxMessages: Array.isArray(object?.inboxMessages)+ ? object.inboxMessages.map((e: any) => InboxMessage.fromJSON(e))+ : [],+ nextPageToken: isSet(object.nextPageToken) ? String(object.nextPageToken) : "",+ };+ },++ toJSON(message: ListInboxResponse): unknown {+ const obj: any = {};+ if (message.inboxMessages) {+ obj.inboxMessages = message.inboxMessages.map((e) => e ? InboxMessage.toJSON(e) : undefined);+ } else {+ obj.inboxMessages = [];+ }+ message.nextPageToken !== undefined && (obj.nextPageToken = message.nextPageToken);+ return obj;+ },++ create(base?: DeepPartial<ListInboxResponse>): ListInboxResponse {+ return ListInboxResponse.fromPartial(base ?? {});+ },++ fromPartial(object: DeepPartial<ListInboxResponse>): ListInboxResponse {+ const message = createBaseListInboxResponse();+ message.inboxMessages = object.inboxMessages?.map((e) => InboxMessage.fromPartial(e)) || [];+ message.nextPageToken = object.nextPageToken ?? "";+ return message;+ },+};++function createBaseGetInboxSummaryRequest(): GetInboxSummaryRequest {+ return {};+}++export const GetInboxSummaryRequest = {+ encode(_: GetInboxSummaryRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): GetInboxSummaryRequest {+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseGetInboxSummaryRequest();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ }+ if ((tag & 7) === 4 || tag === 0) {+ break;+ }+ reader.skipType(tag & 7);+ }+ return message;+ },++ fromJSON(_: any): GetInboxSummaryRequest {+ return {};+ },++ toJSON(_: GetInboxSummaryRequest): unknown {+ const obj: any = {};+ return obj;+ },++ create(base?: DeepPartial<GetInboxSummaryRequest>): GetInboxSummaryRequest {+ return GetInboxSummaryRequest.fromPartial(base ?? {});+ },++ fromPartial(_: DeepPartial<GetInboxSummaryRequest>): GetInboxSummaryRequest {+ const message = createBaseGetInboxSummaryRequest();+ return message;+ },+};++function createBaseUpdateInboxRequest(): UpdateInboxRequest {+ return { inboxMessage: undefined, updateMask: undefined };+}++export const UpdateInboxRequest = {+ encode(message: UpdateInboxRequest, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ if (message.inboxMessage !== undefined) {+ InboxMessage.encode(message.inboxMessage, writer.uint32(10).fork()).ldelim();+ }+ if (message.updateMask !== undefined) {+ FieldMask.encode(FieldMask.wrap(message.updateMask), writer.uint32(18).fork()).ldelim();+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): UpdateInboxRequest {+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseUpdateInboxRequest();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ if (tag !== 10) {+ break;+ }++ message.inboxMessage = InboxMessage.decode(reader, reader.uint32());+ continue;+ case 2:+ if (tag !== 18) {+ break;+ }++ message.updateMask = FieldMask.unwrap(FieldMask.decode(reader, reader.uint32()));+ continue;+ }+ if ((tag & 7) === 4 || tag === 0) {+ break;+ }+ reader.skipType(tag & 7);+ }+ return message;+ },++ fromJSON(object: any): UpdateInboxRequest {+ return {+ inboxMessage: isSet(object.inboxMessage) ? InboxMessage.fromJSON(object.inboxMessage) : undefined,+ updateMask: isSet(object.updateMask) ? FieldMask.unwrap(FieldMask.fromJSON(object.updateMask)) : undefined,+ };+ },++ toJSON(message: UpdateInboxRequest): unknown {+ const obj: any = {};+ message.inboxMessage !== undefined &&+ (obj.inboxMessage = message.inboxMessage ? InboxMessage.toJSON(message.inboxMessage) : undefined);+ message.updateMask !== undefined && (obj.updateMask = FieldMask.toJSON(FieldMask.wrap(message.updateMask)));+ return obj;+ },++ create(base?: DeepPartial<UpdateInboxRequest>): UpdateInboxRequest {+ return UpdateInboxRequest.fromPartial(base ?? {});+ },++ fromPartial(object: DeepPartial<UpdateInboxRequest>): UpdateInboxRequest {+ const message = createBaseUpdateInboxRequest();+ message.inboxMessage = (object.inboxMessage !== undefined && object.inboxMessage !== null)+ ? InboxMessage.fromPartial(object.inboxMessage)+ : undefined;+ message.updateMask = object.updateMask ?? undefined;+ return message;+ },+};++function createBaseInboxMessage(): InboxMessage {+ return { name: "", activityUid: "", status: 0 };+}++export const InboxMessage = {+ encode(message: InboxMessage, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ if (message.name !== "") {+ writer.uint32(10).string(message.name);+ }+ if (message.activityUid !== "") {+ writer.uint32(18).string(message.activityUid);+ }+ if (message.status !== 0) {+ writer.uint32(24).int32(message.status);+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): InboxMessage {+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseInboxMessage();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ if (tag !== 10) {+ break;+ }++ message.name = reader.string();+ continue;+ case 2:+ if (tag !== 18) {+ break;+ }++ message.activityUid = reader.string();+ continue;+ case 3:+ if (tag !== 24) {+ break;+ }++ message.status = reader.int32() as any;+ continue;+ }+ if ((tag & 7) === 4 || tag === 0) {+ break;+ }+ reader.skipType(tag & 7);+ }+ return message;+ },++ fromJSON(object: any): InboxMessage {+ return {+ name: isSet(object.name) ? String(object.name) : "",+ activityUid: isSet(object.activityUid) ? String(object.activityUid) : "",+ status: isSet(object.status) ? inboxMessage_StatusFromJSON(object.status) : 0,+ };+ },++ toJSON(message: InboxMessage): unknown {+ const obj: any = {};+ message.name !== undefined && (obj.name = message.name);+ message.activityUid !== undefined && (obj.activityUid = message.activityUid);+ message.status !== undefined && (obj.status = inboxMessage_StatusToJSON(message.status));+ return obj;+ },++ create(base?: DeepPartial<InboxMessage>): InboxMessage {+ return InboxMessage.fromPartial(base ?? {});+ },++ fromPartial(object: DeepPartial<InboxMessage>): InboxMessage {+ const message = createBaseInboxMessage();+ message.name = object.name ?? "";+ message.activityUid = object.activityUid ?? "";+ message.status = object.status ?? 0;+ return message;+ },+};++function createBaseInboxSummary(): InboxSummary {+ return { hasUnread: false, hasUnreadError: false };+}++export const InboxSummary = {+ encode(message: InboxSummary, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ if (message.hasUnread === true) {+ writer.uint32(8).bool(message.hasUnread);+ }+ if (message.hasUnreadError === true) {+ writer.uint32(16).bool(message.hasUnreadError);+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): InboxSummary {+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseInboxSummary();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ if (tag !== 8) {+ break;+ }++ message.hasUnread = reader.bool();+ continue;+ case 2:+ if (tag !== 16) {+ break;+ }++ message.hasUnreadError = reader.bool();+ continue;+ }+ if ((tag & 7) === 4 || tag === 0) {+ break;+ }+ reader.skipType(tag & 7);+ }+ return message;+ },++ fromJSON(object: any): InboxSummary {+ return {+ hasUnread: isSet(object.hasUnread) ? Boolean(object.hasUnread) : false,+ hasUnreadError: isSet(object.hasUnreadError) ? Boolean(object.hasUnreadError) : false,+ };+ },++ toJSON(message: InboxSummary): unknown {+ const obj: any = {};+ message.hasUnread !== undefined && (obj.hasUnread = message.hasUnread);+ message.hasUnreadError !== undefined && (obj.hasUnreadError = message.hasUnreadError);+ return obj;+ },++ create(base?: DeepPartial<InboxSummary>): InboxSummary {+ return InboxSummary.fromPartial(base ?? {});+ },++ fromPartial(object: DeepPartial<InboxSummary>): InboxSummary {+ const message = createBaseInboxSummary();+ message.hasUnread = object.hasUnread ?? false;+ message.hasUnreadError = object.hasUnreadError ?? false;+ return message;+ },+};++export type InboxServiceDefinition = typeof InboxServiceDefinition;+export const InboxServiceDefinition = {+ name: "InboxService",+ fullName: "bytebase.v1.InboxService",+ methods: {+ listInbox: {+ name: "ListInbox",+ requestType: ListInboxRequest,+ requestStream: false,+ responseType: ListInboxResponse,+ responseStream: false,+ options: {+ _unknownFields: { 578365826: [new Uint8Array([11, 18, 9, 47, 118, 49, 47, 105, 110, 98, 111, 120])] },+ },+ },+ getInboxSummary: {+ name: "GetInboxSummary",+ requestType: GetInboxSummaryRequest,+ requestStream: false,+ responseType: InboxSummary,+ responseStream: false,+ options: {+ _unknownFields: {+ 578365826: [+ new Uint8Array([19, 18, 17, 47, 118, 49, 47, 105, 110, 98, 111, 120, 58, 115, 117, 109, 109, 97, 114, 121]),+ ],+ },+ },+ },+ updateInbox: {+ name: "UpdateInbox",+ requestType: UpdateInboxRequest,+ requestStream: false,+ responseType: InboxMessage,+ responseStream: false,+ options: {+ _unknownFields: {+ 8410: [+ new Uint8Array([+ 25,+ 105,+ 110,+ 98,+ 111,+ 120,+ 95,+ 109,+ 101,+ 115,+ 115,+ 97,+ 103,+ 101,+ 44,+ 117,+ 112,+ 100,+ 97,+ 116,+ 101,+ 95,+ 109,+ 97,+ 115,+ 107,+ ]),+ ],+ 578365826: [+ new Uint8Array([+ 49,+ 58,+ 13,+ 105,+ 110,+ 98,+ 111,+ 120,+ 95,+ 109,+ 101,+ 115,+ 115,+ 97,+ 103,+ 101,+ 50,+ 32,+ 47,+ 118,+ 49,+ 47,+ 123,+ 105,+ 110,+ 98,+ 111,+ 120,+ 95,+ 109,+ 101,+ 115,+ 115,+ 97,+ 103,+ 101,+ 46,+ 110,+ 97,+ 109,+ 101,+ 61,+ 105,+ 110,+ 98,+ 111,+ 120,+ 47,+ 42,+ 125,+ ]),+ ],+ },+ },+ },+ },+} as const;++export interface InboxServiceImplementation<CallContextExt = {}> {+ listInbox(request: ListInboxRequest, context: CallContext & CallContextExt): Promise<DeepPartial<ListInboxResponse>>;+ getInboxSummary(+ request: GetInboxSummaryRequest,+ context: CallContext & CallContextExt,+ ): Promise<DeepPartial<InboxSummary>>;+ updateInbox(request: UpdateInboxRequest, context: CallContext & CallContextExt): Promise<DeepPartial<InboxMessage>>;+}++export interface InboxServiceClient<CallOptionsExt = {}> {+ listInbox(request: DeepPartial<ListInboxRequest>, options?: CallOptions & CallOptionsExt): Promise<ListInboxResponse>;+ getInboxSummary(+ request: DeepPartial<GetInboxSummaryRequest>,+ options?: CallOptions & CallOptionsExt,+ ): Promise<InboxSummary>;+ updateInbox(request: DeepPartial<UpdateInboxRequest>, options?: CallOptions & CallOptionsExt): Promise<InboxMessage>;+}++type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;++export type DeepPartial<T> = T extends Builtin ? T+ : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>+ : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }+ : Partial<T>;++function isSet(value: any): boolean {+ return value !== null && value !== undefined;+}diff --git a/frontend/src/types/store.ts b/frontend/src/types/store.tsindex 8b4f857349..64170b748d 100644--- a/frontend/src/types/store.ts+++ b/frontend/src/types/store.ts@@ -9,11 +9,9 @@ import {DataSourceId,InstanceId,IssueId,- PrincipalId,ProjectId,VCSId,} from "./id";-import { Inbox, InboxSummary } from "./inbox";import { Instance, MigrationHistory } from "./instance";import { InstanceUser } from "./InstanceUser";import { Issue } from "./issue";@@ -29,11 +27,6 @@ export interface PrincipalState {principalList: Principal[];}-export interface InboxState {- inboxListByUser: Map<PrincipalId, Inbox[]>;- inboxSummaryByUser: Map<PrincipalId, InboxSummary>;-}-export interface IssueState {issueById: Map<IssueId, Issue>;isCreatingIssue: boolean;diff --git a/frontend/src/views/DashboardHeader.vue b/frontend/src/views/DashboardHeader.vueindex 7e4cb0fdb7..35326c74d5 100644--- a/frontend/src/views/DashboardHeader.vue+++ b/frontend/src/views/DashboardHeader.vue@@ -215,7 +215,7 @@ import {useCurrentUser,useActuatorV1Store,useSubscriptionV1Store,- useInboxStore,+ useInboxV1Store,useCurrentUserV1,} from "@/store";import { storeToRefs } from "pinia";@@ -236,7 +236,7 @@ export default defineComponent({setup() {const { t, availableLocales } = useI18n();const actuatorV1Store = useActuatorV1Store();- const inboxStore = useInboxStore();+ const inboxV1Store = useInboxV1Store();const subscriptionStore = useSubscriptionV1Store();const router = useRouter();const route = useRoute();@@ -283,14 +283,14 @@ export default defineComponent({const prepareInboxSummary = () => {// It will also be called when user logoutif (currentUser.value.id != UNKNOWN_ID) {- inboxStore.fetchInboxSummaryByUser(currentUser.value.id);+ inboxV1Store.fetchInboxSummary();}};watchEffect(prepareInboxSummary);const inboxSummary = computed(() => {- return inboxStore.getInboxSummaryByUser(currentUser.value.id);+ return inboxV1Store.inboxSummary;});const kbarActions = computed(() => [diff --git a/frontend/src/views/Inbox.vue b/frontend/src/views/Inbox.vueindex d89f60ed55..1405509327 100644--- a/frontend/src/views/Inbox.vue+++ b/frontend/src/views/Inbox.vue@@ -36,17 +36,18 @@<script lang="ts">import { reactive, watchEffect } from "vue";import InboxList from "../components/InboxList.vue";-import { Inbox, UNKNOWN_ID } from "../types";+import { ComposedInbox, UNKNOWN_ID } from "@/types";import { useRouter } from "vue-router";-import { useCurrentUser, useInboxStore } from "@/store";+import { useCurrentUser, useInboxV1Store } from "@/store";+import { InboxMessage_Status } from "@/types/proto/v1/inbox_service";// We alway fetch all "UNREAD" items. But for "READ" items, by default, we only fetch the most recent 7 days.// And each time clicking "View older" will extend 7 days further.const READ_INBOX_DURATION_STEP = 3600 * 24 * 7;interface LocalState {- readList: Inbox[];- unreadList: Inbox[];+ readList: ComposedInbox[];+ unreadList: ComposedInbox[];readCreatedAfterTs: number;}@@ -54,7 +55,7 @@ export default {name: "Inbox",components: { InboxList },setup() {- const inboxStore = useInboxStore();+ const inboxV1Store = useInboxV1Store();const router = useRouter();const state = reactive<LocalState>({@@ -70,26 +71,21 @@ export default {const prepareInboxList = () => {// It will also be called when user logoutif (currentUser.value.id != UNKNOWN_ID) {- inboxStore- .fetchInboxListByUser({- userId: currentUser.value.id,- readCreatedAfterTs: state.readCreatedAfterTs,- })- .then((list: Inbox[]) => {- state.readList = [];- state.unreadList = [];+ inboxV1Store.fetchInboxList(state.readCreatedAfterTs).then((list) => {+ state.readList = [];+ state.unreadList = [];- for (const item of list) {- if (!item.activity) {- continue;- }- if (item.status == "READ") {- state.readList.push(item);- } else if (item.status == "UNREAD") {- state.unreadList.push(item);- }+ for (const item of list) {+ if (!item.activity) {+ continue;}- });+ if (item.status == InboxMessage_Status.STATUS_READ) {+ state.readList.push(item);+ } else if (item.status == InboxMessage_Status.STATUS_UNREAD) {+ state.unreadList.push(item);+ }+ }+ });}};@@ -99,27 +95,21 @@ export default {let count = state.unreadList.length;const inboxList = state.unreadList.map((item) => item);- inboxList.forEach((item: Inbox) => {- inboxStore- .patchInbox({- inboxId: item.id,- inboxPatch: {- status: "READ",- },- })- .then(() => {- const i = state.unreadList.findIndex(- (unreadItem) => unreadItem.id == item.id- );- if (i >= 0) {- state.unreadList.splice(i, 1);- }- count--;- if (count == 0) {- inboxStore.fetchInboxSummaryByUser(currentUser.value.id);- }- state.readList.push(item);- });+ inboxList.forEach((item) => {+ item.status = InboxMessage_Status.STATUS_READ;+ inboxV1Store.patchInbox(item).then(() => {+ const i = state.unreadList.findIndex(+ (unreadItem) => unreadItem.name == item.name+ );+ if (i >= 0) {+ state.unreadList.splice(i, 1);+ }+ count--;+ if (count == 0) {+ inboxV1Store.fetchInboxSummary();+ }+ state.readList.push(item);+ });});};diff --git a/frontend/src/views/sql-editor/EditorHeader.vue b/frontend/src/views/sql-editor/EditorHeader.vueindex cb98f20c0f..5e6e978bfb 100644--- a/frontend/src/views/sql-editor/EditorHeader.vue+++ b/frontend/src/views/sql-editor/EditorHeader.vue@@ -96,7 +96,7 @@ import BytebaseLogo from "@/components/BytebaseLogo.vue";import ProfileBrandingLogo from "@/components/ProfileBrandingLogo.vue";import ProfileDropdown from "@/components/ProfileDropdown.vue";import { UNKNOWN_ID } from "@/types";-import { useCurrentUser, useCurrentUserV1, useInboxStore } from "@/store";+import { useCurrentUser, useCurrentUserV1, useInboxV1Store } from "@/store";import { hasWorkspacePermissionV1 } from "@/utils";import { useSettingV1Store } from "@/store/modules/v1/setting";import { LogEntity_Action } from "@/types/proto/v1/logging_service";@@ -110,7 +110,7 @@ export default defineComponent({components: { BytebaseLogo, ProfileBrandingLogo, ProfileDropdown },setup() {const { t, availableLocales, locale } = useI18n();- const inboxStore = useInboxStore();+ const inboxV1Store = useInboxV1Store();const settingV1Store = useSettingV1Store();const router = useRouter();@@ -135,14 +135,14 @@ export default defineComponent({const prepareInboxSummary = () => {// It will also be called when user logoutif (currentUser.value.id != UNKNOWN_ID) {- inboxStore.fetchInboxSummaryByUser(currentUser.value.id);+ inboxV1Store.fetchInboxSummary();}};watchEffect(prepareInboxSummary);const inboxSummary = computed(() => {- return inboxStore.getInboxSummaryByUser(currentUser.value.id);+ return inboxV1Store.inboxSummary;});const kbarActions = computed(() => [diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex c6dd38d9a3..89dac9993a 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -197,6 +197,18 @@- [IdentityProviderService](#bytebase-v1-IdentityProviderService)+- [v1/inbox_service.proto](#v1_inbox_service-proto)+ - [GetInboxSummaryRequest](#bytebase-v1-GetInboxSummaryRequest)+ - [InboxMessage](#bytebase-v1-InboxMessage)+ - [InboxSummary](#bytebase-v1-InboxSummary)+ - [ListInboxRequest](#bytebase-v1-ListInboxRequest)+ - [ListInboxResponse](#bytebase-v1-ListInboxResponse)+ - [UpdateInboxRequest](#bytebase-v1-UpdateInboxRequest)++ - [InboxMessage.Status](#bytebase-v1-InboxMessage-Status)++ - [InboxService](#bytebase-v1-InboxService)+- [v1/instance_role_service.proto](#v1_instance_role_service-proto)- [CreateInstanceRoleRequest](#bytebase-v1-CreateInstanceRoleRequest)- [DeleteInstanceRoleRequest](#bytebase-v1-DeleteInstanceRoleRequest)@@ -3329,6 +3341,139 @@ The identity provider's `name` field is used to identify the identity provid+<a name="v1_inbox_service-proto"></a>+<p align="right"><a href="#top">Top</a></p>++## v1/inbox_service.proto++++<a name="bytebase-v1-GetInboxSummaryRequest"></a>++### GetInboxSummaryRequest++++++++<a name="bytebase-v1-InboxMessage"></a>++### InboxMessage++++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| name | [string](#string) | | The message name in inbox/{uid} format. |+| activity_uid | [string](#string) | | |+| status | [InboxMessage.Status](#bytebase-v1-InboxMessage-Status) | | |+++++++<a name="bytebase-v1-InboxSummary"></a>++### InboxSummary++++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| has_unread | [bool](#bool) | | |+| has_unread_error | [bool](#bool) | | |+++++++<a name="bytebase-v1-ListInboxRequest"></a>++### ListInboxRequest++++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| filter | [string](#string) | | filter is the filter to apply on the list inbox request, follow the [ebnf](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form) syntax. The field only support in filter: - "create_time" with ">=" operator, example: - create_time >= "2022-01-01T12:00:00.000Z" |+| page_size | [int32](#int32) | | Not used. The maximum number of inbox to return. The service may return fewer than this value. If unspecified, at most 100 log entries will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000. |+| page_token | [string](#string) | | Not used. A page token, received from a previous `ListInbox` call. Provide this to retrieve the subsequent page. |+++++++<a name="bytebase-v1-ListInboxResponse"></a>++### ListInboxResponse++++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| inbox_messages | [InboxMessage](#bytebase-v1-InboxMessage) | repeated | The list of inbox messages. |+| next_page_token | [string](#string) | | A token to retrieve next page of inbox. Pass this value in the page_token field in the subsequent call to `ListLogs` method to retrieve the next page of log entities. |+++++++<a name="bytebase-v1-UpdateInboxRequest"></a>++### UpdateInboxRequest++++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| inbox_message | [InboxMessage](#bytebase-v1-InboxMessage) | | The inbox message to update. |+| update_mask | [google.protobuf.FieldMask](#google-protobuf-FieldMask) | | The list of fields to update. |+++++++++<a name="bytebase-v1-InboxMessage-Status"></a>++### InboxMessage.Status+++| Name | Number | Description |+| ---- | ------ | ----------- |+| STATUS_UNSPECIFIED | 0 | |+| STATUS_UNREAD | 1 | |+| STATUS_READ | 2 | |++++++++<a name="bytebase-v1-InboxService"></a>++### InboxService+++| Method Name | Request Type | Response Type | Description |+| ----------- | ------------ | ------------- | ------------|+| ListInbox | [ListInboxRequest](#bytebase-v1-ListInboxRequest) | [ListInboxResponse](#bytebase-v1-ListInboxResponse) | |+| GetInboxSummary | [GetInboxSummaryRequest](#bytebase-v1-GetInboxSummaryRequest) | [InboxSummary](#bytebase-v1-InboxSummary) | |+| UpdateInbox | [UpdateInboxRequest](#bytebase-v1-UpdateInboxRequest) | [InboxMessage](#bytebase-v1-InboxMessage) | |+++++<a name="v1_instance_role_service-proto"></a><p align="right"><a href="#top">Top</a></p>diff --git a/proto/generated-go/v1/inbox_service.pb.go b/proto/generated-go/v1/inbox_service.pb.gonew file mode 100644index 0000000000..3f0fdab50d--- /dev/null+++ b/proto/generated-go/v1/inbox_service.pb.go@@ -0,0 +1,646 @@+// Code generated by protoc-gen-go. DO NOT EDIT.+// versions:+// protoc-gen-go v1.30.0+// protoc (unknown)+// source: v1/inbox_service.proto++package v1++import (+ _ "google.golang.org/genproto/googleapis/api/annotations"+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"+ fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"+ reflect "reflect"+ sync "sync"+)++const (+ // Verify that this generated code is sufficiently up-to-date.+ _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)+ // Verify that runtime/protoimpl is sufficiently up-to-date.+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)+)++type InboxMessage_Status int32++const (+ InboxMessage_STATUS_UNSPECIFIED InboxMessage_Status = 0+ InboxMessage_STATUS_UNREAD InboxMessage_Status = 1+ InboxMessage_STATUS_READ InboxMessage_Status = 2+)++// Enum value maps for InboxMessage_Status.+var (+ InboxMessage_Status_name = map[int32]string{+ 0: "STATUS_UNSPECIFIED",+ 1: "STATUS_UNREAD",+ 2: "STATUS_READ",+ }+ InboxMessage_Status_value = map[string]int32{+ "STATUS_UNSPECIFIED": 0,+ "STATUS_UNREAD": 1,+ "STATUS_READ": 2,+ }+)++func (x InboxMessage_Status) Enum() *InboxMessage_Status {+ p := new(InboxMessage_Status)+ *p = x+ return p+}++func (x InboxMessage_Status) String() string {+ return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))+}++func (InboxMessage_Status) Descriptor() protoreflect.EnumDescriptor {+ return file_v1_inbox_service_proto_enumTypes[0].Descriptor()+}++func (InboxMessage_Status) Type() protoreflect.EnumType {+ return &file_v1_inbox_service_proto_enumTypes[0]+}++func (x InboxMessage_Status) Number() protoreflect.EnumNumber {+ return protoreflect.EnumNumber(x)+}++// Deprecated: Use InboxMessage_Status.Descriptor instead.+func (InboxMessage_Status) EnumDescriptor() ([]byte, []int) {+ return file_v1_inbox_service_proto_rawDescGZIP(), []int{4, 0}+}++type ListInboxRequest struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // filter is the filter to apply on the list inbox request,+ // follow the [ebnf](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form) syntax.+ // The field only support in filter:+ // - "create_time" with ">=" operator, example:+ // - create_time >= "2022-01-01T12:00:00.000Z"+ Filter string `protobuf:"bytes,1,opt,name=filter,proto3" json:"filter,omitempty"`+ // Not used. The maximum number of inbox to return.+ // The service may return fewer than this value.+ // If unspecified, at most 100 log entries will be returned.+ // The maximum value is 1000; values above 1000 will be coerced to 1000.+ PageSize int32 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"`+ // Not used. A page token, received from a previous `ListInbox` call.+ // Provide this to retrieve the subsequent page.+ PageToken string `protobuf:"bytes,3,opt,name=page_token,json=pageToken,proto3" json:"page_token,omitempty"`+}++func (x *ListInboxRequest) Reset() {+ *x = ListInboxRequest{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_inbox_service_proto_msgTypes[0]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *ListInboxRequest) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*ListInboxRequest) ProtoMessage() {}++func (x *ListInboxRequest) ProtoReflect() protoreflect.Message {+ mi := &file_v1_inbox_service_proto_msgTypes[0]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use ListInboxRequest.ProtoReflect.Descriptor instead.+func (*ListInboxRequest) Descriptor() ([]byte, []int) {+ return file_v1_inbox_service_proto_rawDescGZIP(), []int{0}+}++func (x *ListInboxRequest) GetFilter() string {+ if x != nil {+ return x.Filter+ }+ return ""+}++func (x *ListInboxRequest) GetPageSize() int32 {+ if x != nil {+ return x.PageSize+ }+ return 0+}++func (x *ListInboxRequest) GetPageToken() string {+ if x != nil {+ return x.PageToken+ }+ return ""+}++type ListInboxResponse struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // The list of inbox messages.+ InboxMessages []*InboxMessage `protobuf:"bytes,1,rep,name=inbox_messages,json=inboxMessages,proto3" json:"inbox_messages,omitempty"`+ // A token to retrieve next page of inbox.+ // Pass this value in the page_token field in the subsequent call to `ListLogs` method+ // to retrieve the next page of log entities.+ NextPageToken string `protobuf:"bytes,2,opt,name=next_page_token,json=nextPageToken,proto3" json:"next_page_token,omitempty"`+}++func (x *ListInboxResponse) Reset() {+ *x = ListInboxResponse{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_inbox_service_proto_msgTypes[1]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *ListInboxResponse) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*ListInboxResponse) ProtoMessage() {}++func (x *ListInboxResponse) ProtoReflect() protoreflect.Message {+ mi := &file_v1_inbox_service_proto_msgTypes[1]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use ListInboxResponse.ProtoReflect.Descriptor instead.+func (*ListInboxResponse) Descriptor() ([]byte, []int) {+ return file_v1_inbox_service_proto_rawDescGZIP(), []int{1}+}++func (x *ListInboxResponse) GetInboxMessages() []*InboxMessage {+ if x != nil {+ return x.InboxMessages+ }+ return nil+}++func (x *ListInboxResponse) GetNextPageToken() string {+ if x != nil {+ return x.NextPageToken+ }+ return ""+}++type GetInboxSummaryRequest struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields+}++func (x *GetInboxSummaryRequest) Reset() {+ *x = GetInboxSummaryRequest{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_inbox_service_proto_msgTypes[2]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *GetInboxSummaryRequest) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*GetInboxSummaryRequest) ProtoMessage() {}++func (x *GetInboxSummaryRequest) ProtoReflect() protoreflect.Message {+ mi := &file_v1_inbox_service_proto_msgTypes[2]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use GetInboxSummaryRequest.ProtoReflect.Descriptor instead.+func (*GetInboxSummaryRequest) Descriptor() ([]byte, []int) {+ return file_v1_inbox_service_proto_rawDescGZIP(), []int{2}+}++type UpdateInboxRequest struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // The inbox message to update.+ InboxMessage *InboxMessage `protobuf:"bytes,1,opt,name=inbox_message,json=inboxMessage,proto3" json:"inbox_message,omitempty"`+ // The list of fields to update.+ UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"`+}++func (x *UpdateInboxRequest) Reset() {+ *x = UpdateInboxRequest{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_inbox_service_proto_msgTypes[3]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *UpdateInboxRequest) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*UpdateInboxRequest) ProtoMessage() {}++func (x *UpdateInboxRequest) ProtoReflect() protoreflect.Message {+ mi := &file_v1_inbox_service_proto_msgTypes[3]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use UpdateInboxRequest.ProtoReflect.Descriptor instead.+func (*UpdateInboxRequest) Descriptor() ([]byte, []int) {+ return file_v1_inbox_service_proto_rawDescGZIP(), []int{3}+}++func (x *UpdateInboxRequest) GetInboxMessage() *InboxMessage {+ if x != nil {+ return x.InboxMessage+ }+ return nil+}++func (x *UpdateInboxRequest) GetUpdateMask() *fieldmaskpb.FieldMask {+ if x != nil {+ return x.UpdateMask+ }+ return nil+}++type InboxMessage struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // The message name in inbox/{uid} format.+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`+ ActivityUid string `protobuf:"bytes,2,opt,name=activity_uid,json=activityUid,proto3" json:"activity_uid,omitempty"`+ Status InboxMessage_Status `protobuf:"varint,3,opt,name=status,proto3,enum=bytebase.v1.InboxMessage_Status" json:"status,omitempty"`+}++func (x *InboxMessage) Reset() {+ *x = InboxMessage{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_inbox_service_proto_msgTypes[4]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *InboxMessage) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*InboxMessage) ProtoMessage() {}++func (x *InboxMessage) ProtoReflect() protoreflect.Message {+ mi := &file_v1_inbox_service_proto_msgTypes[4]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use InboxMessage.ProtoReflect.Descriptor instead.+func (*InboxMessage) Descriptor() ([]byte, []int) {+ return file_v1_inbox_service_proto_rawDescGZIP(), []int{4}+}++func (x *InboxMessage) GetName() string {+ if x != nil {+ return x.Name+ }+ return ""+}++func (x *InboxMessage) GetActivityUid() string {+ if x != nil {+ return x.ActivityUid+ }+ return ""+}++func (x *InboxMessage) GetStatus() InboxMessage_Status {+ if x != nil {+ return x.Status+ }+ return InboxMessage_STATUS_UNSPECIFIED+}++type InboxSummary struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ HasUnread bool `protobuf:"varint,1,opt,name=has_unread,json=hasUnread,proto3" json:"has_unread,omitempty"`+ HasUnreadError bool `protobuf:"varint,2,opt,name=has_unread_error,json=hasUnreadError,proto3" json:"has_unread_error,omitempty"`+}++func (x *InboxSummary) Reset() {+ *x = InboxSummary{}+ if protoimpl.UnsafeEnabled {+ mi := &file_v1_inbox_service_proto_msgTypes[5]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *InboxSummary) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*InboxSummary) ProtoMessage() {}++func (x *InboxSummary) ProtoReflect() protoreflect.Message {+ mi := &file_v1_inbox_service_proto_msgTypes[5]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use InboxSummary.ProtoReflect.Descriptor instead.+func (*InboxSummary) Descriptor() ([]byte, []int) {+ return file_v1_inbox_service_proto_rawDescGZIP(), []int{5}+}++func (x *InboxSummary) GetHasUnread() bool {+ if x != nil {+ return x.HasUnread+ }+ return false+}++func (x *InboxSummary) GetHasUnreadError() bool {+ if x != nil {+ return x.HasUnreadError+ }+ return false+}++var File_v1_inbox_service_proto protoreflect.FileDescriptor++var file_v1_inbox_service_proto_rawDesc = []byte{+ 0x0a, 0x16, 0x76, 0x31, 0x2f, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69,+ 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,+ 0x73, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70,+ 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72,+ 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f,+ 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f,+ 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62,+ 0x65, 0x68, 0x61, 0x76, 0x69, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67,+ 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66,+ 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,+ 0x66, 0x0a, 0x10, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x71, 0x75,+ 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x18, 0x01, 0x20,+ 0x01, 0x28, 0x09, 0x52, 0x06, 0x66, 0x69, 0x6c, 0x74, 0x65, 0x72, 0x12, 0x1b, 0x0a, 0x09, 0x70,+ 0x61, 0x67, 0x65, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08,+ 0x70, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65,+ 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x70, 0x61,+ 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x82, 0x01, 0x0a, 0x11, 0x4c, 0x69, 0x73, 0x74,+ 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x45, 0x0a,+ 0x0e, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x18,+ 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,+ 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,+ 0x42, 0x03, 0xe0, 0x41, 0x03, 0x52, 0x0d, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x4d, 0x65, 0x73, 0x73,+ 0x61, 0x67, 0x65, 0x73, 0x12, 0x26, 0x0a, 0x0f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x70, 0x61, 0x67,+ 0x65, 0x5f, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x6e,+ 0x65, 0x78, 0x74, 0x50, 0x61, 0x67, 0x65, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x18, 0x0a, 0x16,+ 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x52,+ 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x96, 0x01, 0x0a, 0x12, 0x55, 0x70, 0x64, 0x61, 0x74,+ 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x43, 0x0a,+ 0x0d, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01,+ 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e,+ 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x42,+ 0x03, 0xe0, 0x41, 0x02, 0x52, 0x0c, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x4d, 0x65, 0x73, 0x73, 0x61,+ 0x67, 0x65, 0x12, 0x3b, 0x0a, 0x0b, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73,+ 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65,+ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x65, 0x6c, 0x64, 0x4d,+ 0x61, 0x73, 0x6b, 0x52, 0x0a, 0x75, 0x70, 0x64, 0x61, 0x74, 0x65, 0x4d, 0x61, 0x73, 0x6b, 0x22,+ 0xc5, 0x01, 0x0a, 0x0c, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,+ 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,+ 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79,+ 0x5f, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x63, 0x74, 0x69,+ 0x76, 0x69, 0x74, 0x79, 0x55, 0x69, 0x64, 0x12, 0x38, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75,+ 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,+ 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x4d, 0x65, 0x73, 0x73, 0x61,+ 0x67, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75,+ 0x73, 0x22, 0x44, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x16, 0x0a, 0x12, 0x53,+ 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45,+ 0x44, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53, 0x5f, 0x55, 0x4e,+ 0x52, 0x45, 0x41, 0x44, 0x10, 0x01, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x54, 0x41, 0x54, 0x55, 0x53,+ 0x5f, 0x52, 0x45, 0x41, 0x44, 0x10, 0x02, 0x22, 0x57, 0x0a, 0x0c, 0x49, 0x6e, 0x62, 0x6f, 0x78,+ 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x1d, 0x0a, 0x0a, 0x68, 0x61, 0x73, 0x5f, 0x75,+ 0x6e, 0x72, 0x65, 0x61, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x68, 0x61, 0x73,+ 0x55, 0x6e, 0x72, 0x65, 0x61, 0x64, 0x12, 0x28, 0x0a, 0x10, 0x68, 0x61, 0x73, 0x5f, 0x75, 0x6e,+ 0x72, 0x65, 0x61, 0x64, 0x5f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08,+ 0x52, 0x0e, 0x68, 0x61, 0x73, 0x55, 0x6e, 0x72, 0x65, 0x61, 0x64, 0x45, 0x72, 0x72, 0x6f, 0x72,+ 0x32, 0xfc, 0x02, 0x0a, 0x0c, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,+ 0x65, 0x12, 0x5d, 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x12, 0x1d,+ 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73,+ 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1e, 0x2e,+ 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74,+ 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x82,+ 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x12, 0x09, 0x2f, 0x76, 0x31, 0x2f, 0x69, 0x6e, 0x62, 0x6f, 0x78,+ 0x12, 0x6c, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x53, 0x75, 0x6d, 0x6d,+ 0x61, 0x72, 0x79, 0x12, 0x23, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76,+ 0x31, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72,+ 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62,+ 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x53, 0x75, 0x6d, 0x6d,+ 0x61, 0x72, 0x79, 0x22, 0x19, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x12, 0x11, 0x2f, 0x76, 0x31,+ 0x2f, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x3a, 0x73, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x9e,+ 0x01, 0x0a, 0x0b, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x12, 0x1f,+ 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x55, 0x70, 0x64,+ 0x61, 0x74, 0x65, 0x49, 0x6e, 0x62, 0x6f, 0x78, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,+ 0x19, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e,+ 0x62, 0x6f, 0x78, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x53, 0xda, 0x41, 0x19, 0x69,+ 0x6e, 0x62, 0x6f, 0x78, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2c, 0x75, 0x70, 0x64,+ 0x61, 0x74, 0x65, 0x5f, 0x6d, 0x61, 0x73, 0x6b, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x31, 0x3a, 0x0d,+ 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x20, 0x2f,+ 0x76, 0x31, 0x2f, 0x7b, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,+ 0x65, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x69, 0x6e, 0x62, 0x6f, 0x78, 0x2f, 0x2a, 0x7d, 0x42,+ 0x11, 0x5a, 0x0f, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f,+ 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,+}++var (+ file_v1_inbox_service_proto_rawDescOnce sync.Once+ file_v1_inbox_service_proto_rawDescData = file_v1_inbox_service_proto_rawDesc+)++func file_v1_inbox_service_proto_rawDescGZIP() []byte {+ file_v1_inbox_service_proto_rawDescOnce.Do(func() {+ file_v1_inbox_service_proto_rawDescData = protoimpl.X.CompressGZIP(file_v1_inbox_service_proto_rawDescData)+ })+ return file_v1_inbox_service_proto_rawDescData+}++var file_v1_inbox_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)+var file_v1_inbox_service_proto_msgTypes = make([]protoimpl.MessageInfo, 6)+var file_v1_inbox_service_proto_goTypes = []interface{}{+ (InboxMessage_Status)(0), // 0: bytebase.v1.InboxMessage.Status+ (*ListInboxRequest)(nil), // 1: bytebase.v1.ListInboxRequest+ (*ListInboxResponse)(nil), // 2: bytebase.v1.ListInboxResponse+ (*GetInboxSummaryRequest)(nil), // 3: bytebase.v1.GetInboxSummaryRequest+ (*UpdateInboxRequest)(nil), // 4: bytebase.v1.UpdateInboxRequest+ (*InboxMessage)(nil), // 5: bytebase.v1.InboxMessage+ (*InboxSummary)(nil), // 6: bytebase.v1.InboxSummary+ (*fieldmaskpb.FieldMask)(nil), // 7: google.protobuf.FieldMask+}+var file_v1_inbox_service_proto_depIdxs = []int32{+ 5, // 0: bytebase.v1.ListInboxResponse.inbox_messages:type_name -> bytebase.v1.InboxMessage+ 5, // 1: bytebase.v1.UpdateInboxRequest.inbox_message:type_name -> bytebase.v1.InboxMessage+ 7, // 2: bytebase.v1.UpdateInboxRequest.update_mask:type_name -> google.protobuf.FieldMask+ 0, // 3: bytebase.v1.InboxMessage.status:type_name -> bytebase.v1.InboxMessage.Status+ 1, // 4: bytebase.v1.InboxService.ListInbox:input_type -> bytebase.v1.ListInboxRequest+ 3, // 5: bytebase.v1.InboxService.GetInboxSummary:input_type -> bytebase.v1.GetInboxSummaryRequest+ 4, // 6: bytebase.v1.InboxService.UpdateInbox:input_type -> bytebase.v1.UpdateInboxRequest+ 2, // 7: bytebase.v1.InboxService.ListInbox:output_type -> bytebase.v1.ListInboxResponse+ 6, // 8: bytebase.v1.InboxService.GetInboxSummary:output_type -> bytebase.v1.InboxSummary+ 5, // 9: bytebase.v1.InboxService.UpdateInbox:output_type -> bytebase.v1.InboxMessage+ 7, // [7:10] is the sub-list for method output_type+ 4, // [4:7] is the sub-list for method input_type+ 4, // [4:4] is the sub-list for extension type_name+ 4, // [4:4] is the sub-list for extension extendee+ 0, // [0:4] is the sub-list for field type_name+}++func init() { file_v1_inbox_service_proto_init() }+func file_v1_inbox_service_proto_init() {+ if File_v1_inbox_service_proto != nil {+ return+ }+ if !protoimpl.UnsafeEnabled {+ file_v1_inbox_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*ListInboxRequest); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_inbox_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*ListInboxResponse); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_inbox_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*GetInboxSummaryRequest); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_inbox_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*UpdateInboxRequest); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_inbox_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*InboxMessage); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ file_v1_inbox_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*InboxSummary); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }+ }+ type x struct{}+ out := protoimpl.TypeBuilder{+ File: protoimpl.DescBuilder{+ GoPackagePath: reflect.TypeOf(x{}).PkgPath(),+ RawDescriptor: file_v1_inbox_service_proto_rawDesc,+ NumEnums: 1,+ NumMessages: 6,+ NumExtensions: 0,+ NumServices: 1,+ },+ GoTypes: file_v1_inbox_service_proto_goTypes,+ DependencyIndexes: file_v1_inbox_service_proto_depIdxs,+ EnumInfos: file_v1_inbox_service_proto_enumTypes,+ MessageInfos: file_v1_inbox_service_proto_msgTypes,+ }.Build()+ File_v1_inbox_service_proto = out.File+ file_v1_inbox_service_proto_rawDesc = nil+ file_v1_inbox_service_proto_goTypes = nil+ file_v1_inbox_service_proto_depIdxs = nil+}diff --git a/proto/generated-go/v1/inbox_service.pb.gw.go b/proto/generated-go/v1/inbox_service.pb.gw.gonew file mode 100644index 0000000000..0e7770dce5--- /dev/null+++ b/proto/generated-go/v1/inbox_service.pb.gw.go@@ -0,0 +1,393 @@+// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.+// source: v1/inbox_service.proto++/*+Package v1 is a reverse proxy.++It translates gRPC into RESTful JSON APIs.+*/+package v1++import (+ "context"+ "io"+ "net/http"++ "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"+ "github.com/grpc-ecosystem/grpc-gateway/v2/utilities"+ "google.golang.org/grpc"+ "google.golang.org/grpc/codes"+ "google.golang.org/grpc/grpclog"+ "google.golang.org/grpc/metadata"+ "google.golang.org/grpc/status"+ "google.golang.org/protobuf/proto"+)++// Suppress "imported and not used" errors+var _ codes.Code+var _ io.Reader+var _ status.Status+var _ = runtime.String+var _ = utilities.NewDoubleArray+var _ = metadata.Join++var (+ filter_InboxService_ListInbox_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}+)++func request_InboxService_ListInbox_0(ctx context.Context, marshaler runtime.Marshaler, client InboxServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq ListInboxRequest+ var metadata runtime.ServerMetadata++ if err := req.ParseForm(); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }+ if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_InboxService_ListInbox_0); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ msg, err := client.ListInbox(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))+ return msg, metadata, err++}++func local_request_InboxService_ListInbox_0(ctx context.Context, marshaler runtime.Marshaler, server InboxServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq ListInboxRequest+ var metadata runtime.ServerMetadata++ if err := req.ParseForm(); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }+ if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_InboxService_ListInbox_0); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ msg, err := server.ListInbox(ctx, &protoReq)+ return msg, metadata, err++}++func request_InboxService_GetInboxSummary_0(ctx context.Context, marshaler runtime.Marshaler, client InboxServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq GetInboxSummaryRequest+ var metadata runtime.ServerMetadata++ msg, err := client.GetInboxSummary(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))+ return msg, metadata, err++}++func local_request_InboxService_GetInboxSummary_0(ctx context.Context, marshaler runtime.Marshaler, server InboxServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq GetInboxSummaryRequest+ var metadata runtime.ServerMetadata++ msg, err := server.GetInboxSummary(ctx, &protoReq)+ return msg, metadata, err++}++var (+ filter_InboxService_UpdateInbox_0 = &utilities.DoubleArray{Encoding: map[string]int{"inbox_message": 0, "inboxMessage": 1, "name": 2}, Base: []int{1, 3, 4, 5, 2, 0, 0, 0, 0}, Check: []int{0, 1, 1, 1, 2, 5, 2, 3, 4}}+)++func request_InboxService_UpdateInbox_0(ctx context.Context, marshaler runtime.Marshaler, client InboxServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq UpdateInboxRequest+ var metadata runtime.ServerMetadata++ newReader, berr := utilities.IOReaderFactory(req.Body)+ if berr != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)+ }+ if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.InboxMessage); err != nil && err != io.EOF {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }+ if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {+ if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.InboxMessage); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ } else {+ protoReq.UpdateMask = fieldMask+ }+ }++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["inbox_message.name"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "inbox_message.name")+ }++ err = runtime.PopulateFieldFromPath(&protoReq, "inbox_message.name", val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "inbox_message.name", err)+ }++ if err := req.ParseForm(); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }+ if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_InboxService_UpdateInbox_0); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ msg, err := client.UpdateInbox(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))+ return msg, metadata, err++}++func local_request_InboxService_UpdateInbox_0(ctx context.Context, marshaler runtime.Marshaler, server InboxServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {+ var protoReq UpdateInboxRequest+ var metadata runtime.ServerMetadata++ newReader, berr := utilities.IOReaderFactory(req.Body)+ if berr != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)+ }+ if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.InboxMessage); err != nil && err != io.EOF {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }+ if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {+ if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.InboxMessage); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ } else {+ protoReq.UpdateMask = fieldMask+ }+ }++ var (+ val string+ ok bool+ err error+ _ = err+ )++ val, ok = pathParams["inbox_message.name"]+ if !ok {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "inbox_message.name")+ }++ err = runtime.PopulateFieldFromPath(&protoReq, "inbox_message.name", val)+ if err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "inbox_message.name", err)+ }++ if err := req.ParseForm(); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }+ if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_InboxService_UpdateInbox_0); err != nil {+ return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)+ }++ msg, err := server.UpdateInbox(ctx, &protoReq)+ return msg, metadata, err++}++// RegisterInboxServiceHandlerServer registers the http handlers for service InboxService to "mux".+// UnaryRPC :call InboxServiceServer directly.+// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.+// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterInboxServiceHandlerFromEndpoint instead.+func RegisterInboxServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server InboxServiceServer) error {++ mux.Handle("GET", pattern_InboxService_ListInbox_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ var stream runtime.ServerTransportStream+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.InboxService/ListInbox", runtime.WithHTTPPathPattern("/v1/inbox"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := local_request_InboxService_ListInbox_0(annotatedContext, inboundMarshaler, server, req, pathParams)+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InboxService_ListInbox_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ mux.Handle("GET", pattern_InboxService_GetInboxSummary_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ var stream runtime.ServerTransportStream+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.InboxService/GetInboxSummary", runtime.WithHTTPPathPattern("/v1/inbox:summary"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := local_request_InboxService_GetInboxSummary_0(annotatedContext, inboundMarshaler, server, req, pathParams)+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InboxService_GetInboxSummary_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ mux.Handle("PATCH", pattern_InboxService_UpdateInbox_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ var stream runtime.ServerTransportStream+ ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/bytebase.v1.InboxService/UpdateInbox", runtime.WithHTTPPathPattern("/v1/{inbox_message.name=inbox/*}"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := local_request_InboxService_UpdateInbox_0(annotatedContext, inboundMarshaler, server, req, pathParams)+ md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InboxService_UpdateInbox_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ return nil+}++// RegisterInboxServiceHandlerFromEndpoint is same as RegisterInboxServiceHandler but+// automatically dials to "endpoint" and closes the connection when "ctx" gets done.+func RegisterInboxServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {+ conn, err := grpc.DialContext(ctx, endpoint, opts...)+ if err != nil {+ return err+ }+ defer func() {+ if err != nil {+ if cerr := conn.Close(); cerr != nil {+ grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)+ }+ return+ }+ go func() {+ <-ctx.Done()+ if cerr := conn.Close(); cerr != nil {+ grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)+ }+ }()+ }()++ return RegisterInboxServiceHandler(ctx, mux, conn)+}++// RegisterInboxServiceHandler registers the http handlers for service InboxService to "mux".+// The handlers forward requests to the grpc endpoint over "conn".+func RegisterInboxServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {+ return RegisterInboxServiceHandlerClient(ctx, mux, NewInboxServiceClient(conn))+}++// RegisterInboxServiceHandlerClient registers the http handlers for service InboxService+// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "InboxServiceClient".+// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "InboxServiceClient"+// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in+// "InboxServiceClient" to call the correct interceptors.+func RegisterInboxServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client InboxServiceClient) error {++ mux.Handle("GET", pattern_InboxService_ListInbox_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.InboxService/ListInbox", runtime.WithHTTPPathPattern("/v1/inbox"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := request_InboxService_ListInbox_0(annotatedContext, inboundMarshaler, client, req, pathParams)+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InboxService_ListInbox_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ mux.Handle("GET", pattern_InboxService_GetInboxSummary_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.InboxService/GetInboxSummary", runtime.WithHTTPPathPattern("/v1/inbox:summary"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := request_InboxService_GetInboxSummary_0(annotatedContext, inboundMarshaler, client, req, pathParams)+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InboxService_GetInboxSummary_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ mux.Handle("PATCH", pattern_InboxService_UpdateInbox_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {+ ctx, cancel := context.WithCancel(req.Context())+ defer cancel()+ inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)+ var err error+ var annotatedContext context.Context+ annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/bytebase.v1.InboxService/UpdateInbox", runtime.WithHTTPPathPattern("/v1/{inbox_message.name=inbox/*}"))+ if err != nil {+ runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)+ return+ }+ resp, md, err := request_InboxService_UpdateInbox_0(annotatedContext, inboundMarshaler, client, req, pathParams)+ annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)+ if err != nil {+ runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)+ return+ }++ forward_InboxService_UpdateInbox_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)++ })++ return nil+}++var (+ pattern_InboxService_ListInbox_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "inbox"}, ""))++ pattern_InboxService_GetInboxSummary_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "inbox"}, "summary"))++ pattern_InboxService_UpdateInbox_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 2, 5, 2}, []string{"v1", "inbox", "inbox_message.name"}, ""))+)++var (+ forward_InboxService_ListInbox_0 = runtime.ForwardResponseMessage++ forward_InboxService_GetInboxSummary_0 = runtime.ForwardResponseMessage++ forward_InboxService_UpdateInbox_0 = runtime.ForwardResponseMessage+)diff --git a/proto/generated-go/v1/inbox_service_grpc.pb.go b/proto/generated-go/v1/inbox_service_grpc.pb.gonew file mode 100644index 0000000000..3df30fe134--- /dev/null+++ b/proto/generated-go/v1/inbox_service_grpc.pb.go@@ -0,0 +1,183 @@+// Code generated by protoc-gen-go-grpc. DO NOT EDIT.+// versions:+// - protoc-gen-go-grpc v1.3.0+// - protoc (unknown)+// source: v1/inbox_service.proto++package v1++import (+ context "context"+ grpc "google.golang.org/grpc"+ codes "google.golang.org/grpc/codes"+ status "google.golang.org/grpc/status"+)++// This is a compile-time assertion to ensure that this generated file+// is compatible with the grpc package it is being compiled against.+// Requires gRPC-Go v1.32.0 or later.+const _ = grpc.SupportPackageIsVersion7++const (+ InboxService_ListInbox_FullMethodName = "/bytebase.v1.InboxService/ListInbox"+ InboxService_GetInboxSummary_FullMethodName = "/bytebase.v1.InboxService/GetInboxSummary"+ InboxService_UpdateInbox_FullMethodName = "/bytebase.v1.InboxService/UpdateInbox"+)++// InboxServiceClient is the client API for InboxService service.+//+// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.+type InboxServiceClient interface {+ ListInbox(ctx context.Context, in *ListInboxRequest, opts ...grpc.CallOption) (*ListInboxResponse, error)+ GetInboxSummary(ctx context.Context, in *GetInboxSummaryRequest, opts ...grpc.CallOption) (*InboxSummary, error)+ UpdateInbox(ctx context.Context, in *UpdateInboxRequest, opts ...grpc.CallOption) (*InboxMessage, error)+}++type inboxServiceClient struct {+ cc grpc.ClientConnInterface+}++func NewInboxServiceClient(cc grpc.ClientConnInterface) InboxServiceClient {+ return &inboxServiceClient{cc}+}++func (c *inboxServiceClient) ListInbox(ctx context.Context, in *ListInboxRequest, opts ...grpc.CallOption) (*ListInboxResponse, error) {+ out := new(ListInboxResponse)+ err := c.cc.Invoke(ctx, InboxService_ListInbox_FullMethodName, in, out, opts...)+ if err != nil {+ return nil, err+ }+ return out, nil+}++func (c *inboxServiceClient) GetInboxSummary(ctx context.Context, in *GetInboxSummaryRequest, opts ...grpc.CallOption) (*InboxSummary, error) {+ out := new(InboxSummary)+ err := c.cc.Invoke(ctx, InboxService_GetInboxSummary_FullMethodName, in, out, opts...)+ if err != nil {+ return nil, err+ }+ return out, nil+}++func (c *inboxServiceClient) UpdateInbox(ctx context.Context, in *UpdateInboxRequest, opts ...grpc.CallOption) (*InboxMessage, error) {+ out := new(InboxMessage)+ err := c.cc.Invoke(ctx, InboxService_UpdateInbox_FullMethodName, in, out, opts...)+ if err != nil {+ return nil, err+ }+ return out, nil+}++// InboxServiceServer is the server API for InboxService service.+// All implementations must embed UnimplementedInboxServiceServer+// for forward compatibility+type InboxServiceServer interface {+ ListInbox(context.Context, *ListInboxRequest) (*ListInboxResponse, error)+ GetInboxSummary(context.Context, *GetInboxSummaryRequest) (*InboxSummary, error)+ UpdateInbox(context.Context, *UpdateInboxRequest) (*InboxMessage, error)+ mustEmbedUnimplementedInboxServiceServer()+}++// UnimplementedInboxServiceServer must be embedded to have forward compatible implementations.+type UnimplementedInboxServiceServer struct {+}++func (UnimplementedInboxServiceServer) ListInbox(context.Context, *ListInboxRequest) (*ListInboxResponse, error) {+ return nil, status.Errorf(codes.Unimplemented, "method ListInbox not implemented")+}+func (UnimplementedInboxServiceServer) GetInboxSummary(context.Context, *GetInboxSummaryRequest) (*InboxSummary, error) {+ return nil, status.Errorf(codes.Unimplemented, "method GetInboxSummary not implemented")+}+func (UnimplementedInboxServiceServer) UpdateInbox(context.Context, *UpdateInboxRequest) (*InboxMessage, error) {+ return nil, status.Errorf(codes.Unimplemented, "method UpdateInbox not implemented")+}+func (UnimplementedInboxServiceServer) mustEmbedUnimplementedInboxServiceServer() {}++// UnsafeInboxServiceServer may be embedded to opt out of forward compatibility for this service.+// Use of this interface is not recommended, as added methods to InboxServiceServer will+// result in compilation errors.+type UnsafeInboxServiceServer interface {+ mustEmbedUnimplementedInboxServiceServer()+}++func RegisterInboxServiceServer(s grpc.ServiceRegistrar, srv InboxServiceServer) {+ s.RegisterService(&InboxService_ServiceDesc, srv)+}++func _InboxService_ListInbox_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {+ in := new(ListInboxRequest)+ if err := dec(in); err != nil {+ return nil, err+ }+ if interceptor == nil {+ return srv.(InboxServiceServer).ListInbox(ctx, in)+ }+ info := &grpc.UnaryServerInfo{+ Server: srv,+ FullMethod: InboxService_ListInbox_FullMethodName,+ }+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {+ return srv.(InboxServiceServer).ListInbox(ctx, req.(*ListInboxRequest))+ }+ return interceptor(ctx, in, info, handler)+}++func _InboxService_GetInboxSummary_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {+ in := new(GetInboxSummaryRequest)+ if err := dec(in); err != nil {+ return nil, err+ }+ if interceptor == nil {+ return srv.(InboxServiceServer).GetInboxSummary(ctx, in)+ }+ info := &grpc.UnaryServerInfo{+ Server: srv,+ FullMethod: InboxService_GetInboxSummary_FullMethodName,+ }+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {+ return srv.(InboxServiceServer).GetInboxSummary(ctx, req.(*GetInboxSummaryRequest))+ }+ return interceptor(ctx, in, info, handler)+}++func _InboxService_UpdateInbox_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {+ in := new(UpdateInboxRequest)+ if err := dec(in); err != nil {+ return nil, err+ }+ if interceptor == nil {+ return srv.(InboxServiceServer).UpdateInbox(ctx, in)+ }+ info := &grpc.UnaryServerInfo{+ Server: srv,+ FullMethod: InboxService_UpdateInbox_FullMethodName,+ }+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {+ return srv.(InboxServiceServer).UpdateInbox(ctx, req.(*UpdateInboxRequest))+ }+ return interceptor(ctx, in, info, handler)+}++// InboxService_ServiceDesc is the grpc.ServiceDesc for InboxService service.+// It's only intended for direct use with grpc.RegisterService,+// and not to be introspected or modified (even as a copy)+var InboxService_ServiceDesc = grpc.ServiceDesc{+ ServiceName: "bytebase.v1.InboxService",+ HandlerType: (*InboxServiceServer)(nil),+ Methods: []grpc.MethodDesc{+ {+ MethodName: "ListInbox",+ Handler: _InboxService_ListInbox_Handler,+ },+ {+ MethodName: "GetInboxSummary",+ Handler: _InboxService_GetInboxSummary_Handler,+ },+ {+ MethodName: "UpdateInbox",+ Handler: _InboxService_UpdateInbox_Handler,+ },+ },+ Streams: []grpc.StreamDesc{},+ Metadata: "v1/inbox_service.proto",+}diff --git a/proto/v1/inbox_service.proto b/proto/v1/inbox_service.protonew file mode 100644index 0000000000..1007bd23a3--- /dev/null+++ b/proto/v1/inbox_service.proto@@ -0,0 +1,87 @@+syntax = "proto3";++package bytebase.v1;++import "google/api/annotations.proto";+import "google/api/client.proto";+import "google/api/field_behavior.proto";+import "google/protobuf/field_mask.proto";++option go_package = "generated-go/v1";++service InboxService {+ rpc ListInbox(ListInboxRequest) returns (ListInboxResponse) {+ option (google.api.http) = {get: "/v1/inbox"};+ }++ rpc GetInboxSummary(GetInboxSummaryRequest) returns (InboxSummary) {+ option (google.api.http) = {get: "/v1/inbox:summary"};+ }++ rpc UpdateInbox(UpdateInboxRequest) returns (InboxMessage) {+ option (google.api.http) = {+ patch: "/v1/{inbox_message.name=inbox/*}"+ body: "inbox_message"+ };+ option (google.api.method_signature) = "inbox_message,update_mask";+ }+}++message ListInboxRequest {+ // filter is the filter to apply on the list inbox request,+ // follow the [ebnf](https://en.wikipedia.org/wiki/Extended_Backus%E2%80%93Naur_form) syntax.+ // The field only support in filter:+ // - "create_time" with ">=" operator, example:+ // - create_time >= "2022-01-01T12:00:00.000Z"+ string filter = 1;++ // Not used. The maximum number of inbox to return.+ // The service may return fewer than this value.+ // If unspecified, at most 100 log entries will be returned.+ // The maximum value is 1000; values above 1000 will be coerced to 1000.+ int32 page_size = 2;++ // Not used. A page token, received from a previous `ListInbox` call.+ // Provide this to retrieve the subsequent page.+ string page_token = 3;+}++message ListInboxResponse {+ // The list of inbox messages.+ repeated InboxMessage inbox_messages = 1 [(google.api.field_behavior) = OUTPUT_ONLY];++ // A token to retrieve next page of inbox.+ // Pass this value in the page_token field in the subsequent call to `ListLogs` method+ // to retrieve the next page of log entities.+ string next_page_token = 2;+}++message GetInboxSummaryRequest {}++message UpdateInboxRequest {+ // The inbox message to update.+ InboxMessage inbox_message = 1 [(google.api.field_behavior) = REQUIRED];++ // The list of fields to update.+ google.protobuf.FieldMask update_mask = 2;+}++message InboxMessage {+ // The message name in inbox/{uid} format.+ string name = 1;++ string activity_uid = 2;++ enum Status {+ STATUS_UNSPECIFIED = 0;+ STATUS_UNREAD = 1;+ STATUS_READ = 2;+ }+ Status status = 3;+}++message InboxSummary {+ bool has_unread = 1;++ bool has_unread_error = 2;+}