Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
36b4ba33
Commit
36b4ba33
authored
Oct 27, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: remove outdated activity definition
parent
625ebbea
Changes
18
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
538 additions
and
536 deletions
+538
-536
activity.go
api/v1/activity.go
+0
-136
auth.go
api/v1/auth.go
+0
-53
memo.go
api/v1/memo.go
+12
-47
memo_relation.go
api/v1/memo_relation.go
+2
-2
resource.go
api/v1/resource.go
+0
-28
tag.go
api/v1/tag.go
+0
-25
user.go
api/v1/user.go
+0
-26
inbox_service .go
api/v2/inbox_service .go
+21
-7
inbox_service.proto
proto/api/v2/inbox_service.proto
+6
-4
README.md
proto/gen/api/v2/README.md
+15
-3
inbox_service.pb.go
proto/gen/api/v2/inbox_service.pb.go
+153
-106
README.md
proto/gen/store/README.md
+49
-3
activity.pb.go
proto/gen/store/activity.pb.go
+179
-20
inbox.pb.go
proto/gen/store/inbox.pb.go
+83
-47
activity.proto
proto/store/activity.proto
+9
-0
inbox.proto
proto/store/inbox.proto
+6
-4
server.go
server/server.go
+0
-25
grpcweb.ts
web/src/grpcweb.ts
+3
-0
No files found.
api/v1/activity.go
deleted
100644 → 0
View file @
625ebbea
package
v1
import
"github.com/usememos/memos/server/profile"
// ActivityType is the type for an activity.
type
ActivityType
string
const
(
// User related.
// ActivityUserCreate is the type for creating users.
ActivityUserCreate
ActivityType
=
"user.create"
// ActivityUserUpdate is the type for updating users.
ActivityUserUpdate
ActivityType
=
"user.update"
// ActivityUserDelete is the type for deleting users.
ActivityUserDelete
ActivityType
=
"user.delete"
// ActivityUserAuthSignIn is the type for user signin.
ActivityUserAuthSignIn
ActivityType
=
"user.auth.signin"
// ActivityUserAuthSignUp is the type for user signup.
ActivityUserAuthSignUp
ActivityType
=
"user.auth.signup"
// ActivityUserSettingUpdate is the type for updating user settings.
ActivityUserSettingUpdate
ActivityType
=
"user.setting.update"
// Memo related.
// ActivityMemoCreate is the type for creating memos.
ActivityMemoCreate
ActivityType
=
"memo.create"
// ActivityMemoView is the type for viewing memos.
ActivityMemoView
ActivityType
=
"memo.view"
// ActivityMemoUpdate is the type for updating memos.
ActivityMemoUpdate
ActivityType
=
"memo.update"
// ActivityMemoDelete is the type for deleting memos.
ActivityMemoDelete
ActivityType
=
"memo.delete"
// Resource related.
// ActivityResourceCreate is the type for creating resources.
ActivityResourceCreate
ActivityType
=
"resource.create"
// ActivityResourceDelete is the type for deleting resources.
ActivityResourceDelete
ActivityType
=
"resource.delete"
// Tag related.
// ActivityTagCreate is the type for creating tags.
ActivityTagCreate
ActivityType
=
"tag.create"
// ActivityTagDelete is the type for deleting tags.
ActivityTagDelete
ActivityType
=
"tag.delete"
// Server related.
// ActivityServerStart is the type for starting server.
ActivityServerStart
ActivityType
=
"server.start"
)
func
(
t
ActivityType
)
String
()
string
{
return
string
(
t
)
}
// ActivityLevel is the level of activities.
type
ActivityLevel
string
const
(
// ActivityInfo is the INFO level of activities.
ActivityInfo
ActivityLevel
=
"INFO"
// ActivityWarn is the WARN level of activities.
ActivityWarn
ActivityLevel
=
"WARN"
// ActivityError is the ERROR level of activities.
ActivityError
ActivityLevel
=
"ERROR"
)
func
(
l
ActivityLevel
)
String
()
string
{
return
string
(
l
)
}
type
ActivityUserCreatePayload
struct
{
UserID
int32
`json:"userId"`
Username
string
`json:"username"`
Role
Role
`json:"role"`
}
type
ActivityUserAuthSignInPayload
struct
{
UserID
int32
`json:"userId"`
IP
string
`json:"ip"`
}
type
ActivityUserAuthSignUpPayload
struct
{
Username
string
`json:"username"`
IP
string
`json:"ip"`
}
type
ActivityMemoCreatePayload
struct
{
MemoID
int32
`json:"memoId"`
}
type
ActivityMemoViewPayload
struct
{
MemoID
int32
`json:"memoId"`
}
type
ActivityResourceCreatePayload
struct
{
Filename
string
`json:"filename"`
Type
string
`json:"type"`
Size
int64
`json:"size"`
}
type
ActivityTagCreatePayload
struct
{
TagName
string
`json:"tagName"`
}
type
ActivityServerStartPayload
struct
{
ServerID
string
`json:"serverId"`
Profile
*
profile
.
Profile
`json:"profile"`
}
type
Activity
struct
{
ID
int32
`json:"id"`
// Standard fields
CreatorID
int32
`json:"creatorId"`
CreatedTs
int64
`json:"createdTs"`
// Domain specific fields
Type
ActivityType
`json:"type"`
Level
ActivityLevel
`json:"level"`
Payload
string
`json:"payload"`
}
// ActivityCreate is the API message for creating an activity.
type
ActivityCreate
struct
{
// Standard fields
CreatorID
int32
// Domain specific fields
Type
ActivityType
`json:"type"`
Level
ActivityLevel
Payload
string
`json:"payload"`
}
api/v1/auth.go
View file @
36b4ba33
...
...
@@ -117,9 +117,6 @@ func (s *APIV1Service) SignIn(c echo.Context) error {
if
err
:=
s
.
UpsertAccessTokenToStore
(
ctx
,
user
,
accessToken
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
fmt
.
Sprintf
(
"failed to upsert access token, err: %s"
,
err
))
.
SetInternal
(
err
)
}
if
err
:=
s
.
createAuthSignInActivity
(
c
,
user
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create activity"
)
.
SetInternal
(
err
)
}
cookieExp
:=
time
.
Now
()
.
Add
(
auth
.
CookieExpDuration
)
setTokenCookie
(
c
,
auth
.
AccessTokenCookieName
,
accessToken
,
cookieExp
)
userMessage
:=
convertUserFromStore
(
user
)
...
...
@@ -241,9 +238,6 @@ func (s *APIV1Service) SignInSSO(c echo.Context) error {
if
err
:=
s
.
UpsertAccessTokenToStore
(
ctx
,
user
,
accessToken
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
fmt
.
Sprintf
(
"failed to upsert access token, err: %s"
,
err
))
.
SetInternal
(
err
)
}
if
err
:=
s
.
createAuthSignInActivity
(
c
,
user
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create activity"
)
.
SetInternal
(
err
)
}
cookieExp
:=
time
.
Now
()
.
Add
(
auth
.
CookieExpDuration
)
setTokenCookie
(
c
,
auth
.
AccessTokenCookieName
,
accessToken
,
cookieExp
)
userMessage
:=
convertUserFromStore
(
user
)
...
...
@@ -366,9 +360,6 @@ func (s *APIV1Service) SignUp(c echo.Context) error {
if
err
:=
s
.
UpsertAccessTokenToStore
(
ctx
,
user
,
accessToken
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
fmt
.
Sprintf
(
"failed to upsert access token, err: %s"
,
err
))
.
SetInternal
(
err
)
}
if
err
:=
s
.
createAuthSignUpActivity
(
c
,
user
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create activity"
)
.
SetInternal
(
err
)
}
cookieExp
:=
time
.
Now
()
.
Add
(
auth
.
CookieExpDuration
)
setTokenCookie
(
c
,
auth
.
AccessTokenCookieName
,
accessToken
,
cookieExp
)
userMessage
:=
convertUserFromStore
(
user
)
...
...
@@ -399,50 +390,6 @@ func (s *APIV1Service) UpsertAccessTokenToStore(ctx context.Context, user *store
return
nil
}
func
(
s
*
APIV1Service
)
createAuthSignInActivity
(
c
echo
.
Context
,
user
*
store
.
User
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
payload
:=
ActivityUserAuthSignInPayload
{
UserID
:
user
.
ID
,
IP
:
echo
.
ExtractIPFromRealIPHeader
()(
c
.
Request
()),
}
payloadBytes
,
err
:=
json
.
Marshal
(
payload
)
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to marshal activity payload"
)
}
activity
,
err
:=
s
.
Store
.
CreateActivity
(
ctx
,
&
store
.
Activity
{
CreatorID
:
user
.
ID
,
Type
:
string
(
ActivityUserAuthSignIn
),
Level
:
string
(
ActivityInfo
),
Payload
:
string
(
payloadBytes
),
})
if
err
!=
nil
||
activity
==
nil
{
return
errors
.
Wrap
(
err
,
"failed to create activity"
)
}
return
err
}
func
(
s
*
APIV1Service
)
createAuthSignUpActivity
(
c
echo
.
Context
,
user
*
store
.
User
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
payload
:=
ActivityUserAuthSignUpPayload
{
Username
:
user
.
Username
,
IP
:
echo
.
ExtractIPFromRealIPHeader
()(
c
.
Request
()),
}
payloadBytes
,
err
:=
json
.
Marshal
(
payload
)
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to marshal activity payload"
)
}
activity
,
err
:=
s
.
Store
.
CreateActivity
(
ctx
,
&
store
.
Activity
{
CreatorID
:
user
.
ID
,
Type
:
string
(
ActivityUserAuthSignUp
),
Level
:
string
(
ActivityInfo
),
Payload
:
string
(
payloadBytes
),
})
if
err
!=
nil
||
activity
==
nil
{
return
errors
.
Wrap
(
err
,
"failed to create activity"
)
}
return
err
}
// removeAccessTokenAndCookies removes the jwt token from the cookies.
func
removeAccessTokenAndCookies
(
c
echo
.
Context
)
{
cookieExp
:=
time
.
Now
()
.
Add
(
-
1
*
time
.
Hour
)
...
...
api/v1/memo.go
View file @
36b4ba33
...
...
@@ -319,9 +319,6 @@ func (s *APIV1Service) CreateMemo(c echo.Context) error {
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create memo"
)
.
SetInternal
(
err
)
}
if
err
:=
s
.
createMemoCreateActivity
(
ctx
,
memo
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create activity"
)
.
SetInternal
(
err
)
}
for
_
,
resourceID
:=
range
createMemoRequest
.
ResourceIDList
{
if
_
,
err
:=
s
.
Store
.
UpdateResource
(
ctx
,
&
store
.
UpdateResource
{
...
...
@@ -340,6 +337,18 @@ func (s *APIV1Service) CreateMemo(c echo.Context) error {
});
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to upsert memo relation"
)
.
SetInternal
(
err
)
}
if
memoRelationUpsert
.
Type
==
MemoRelationComment
{
relatedMemo
,
err
:=
s
.
Store
.
GetMemo
(
ctx
,
&
store
.
FindMemo
{
ID
:
&
memoRelationUpsert
.
RelatedMemoID
,
})
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to get related memo"
)
.
SetInternal
(
err
)
}
// nolint
if
relatedMemo
.
CreatorID
!=
memo
.
CreatorID
{
// TODO: When a memo is commented by others, send notification to the memo creator.
}
}
}
composedMemo
,
err
:=
s
.
Store
.
GetMemo
(
ctx
,
&
store
.
FindMemo
{
...
...
@@ -567,9 +576,6 @@ func (s *APIV1Service) GetMemo(c echo.Context) error {
return
echo
.
NewHTTPError
(
http
.
StatusForbidden
,
"this memo is protected, missing user in session"
)
}
}
if
err
:=
s
.
createMemoViewActivity
(
c
,
memo
,
userID
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create activity"
)
.
SetInternal
(
err
)
}
memoResponse
,
err
:=
s
.
convertMemoFromStore
(
ctx
,
memo
)
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to compose memo response"
)
.
SetInternal
(
err
)
...
...
@@ -766,47 +772,6 @@ func (s *APIV1Service) UpdateMemo(c echo.Context) error {
return
c
.
JSON
(
http
.
StatusOK
,
memoResponse
)
}
func
(
s
*
APIV1Service
)
createMemoCreateActivity
(
ctx
context
.
Context
,
memo
*
store
.
Memo
)
error
{
payload
:=
ActivityMemoCreatePayload
{
MemoID
:
memo
.
ID
,
}
payloadBytes
,
err
:=
json
.
Marshal
(
payload
)
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to marshal activity payload"
)
}
activity
,
err
:=
s
.
Store
.
CreateActivity
(
ctx
,
&
store
.
Activity
{
CreatorID
:
memo
.
CreatorID
,
Type
:
ActivityMemoCreate
.
String
(),
Level
:
ActivityInfo
.
String
(),
Payload
:
string
(
payloadBytes
),
})
if
err
!=
nil
||
activity
==
nil
{
return
errors
.
Wrap
(
err
,
"failed to create activity"
)
}
return
err
}
func
(
s
*
APIV1Service
)
createMemoViewActivity
(
c
echo
.
Context
,
memo
*
store
.
Memo
,
userID
int32
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
payload
:=
ActivityMemoViewPayload
{
MemoID
:
memo
.
ID
,
}
payloadBytes
,
err
:=
json
.
Marshal
(
payload
)
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to marshal activity payload"
)
}
activity
,
err
:=
s
.
Store
.
CreateActivity
(
ctx
,
&
store
.
Activity
{
CreatorID
:
userID
,
Type
:
string
(
ActivityMemoView
),
Level
:
string
(
ActivityInfo
),
Payload
:
string
(
payloadBytes
),
})
if
err
!=
nil
||
activity
==
nil
{
return
errors
.
Wrap
(
err
,
"failed to create activity"
)
}
return
err
}
func
(
s
*
APIV1Service
)
convertMemoFromStore
(
ctx
context
.
Context
,
memo
*
store
.
Memo
)
(
*
Memo
,
error
)
{
memoResponse
:=
&
Memo
{
ID
:
memo
.
ID
,
...
...
api/v1/memo_relation.go
View file @
36b4ba33
...
...
@@ -14,8 +14,8 @@ import (
type
MemoRelationType
string
const
(
MemoRelationReference
MemoRelationType
=
"REFERENCE"
MemoRelation
Additional
MemoRelationType
=
"ADDITIONAL
"
MemoRelationReference
MemoRelationType
=
"REFERENCE"
MemoRelation
Comment
MemoRelationType
=
"COMMENT
"
)
type
MemoRelation
struct
{
...
...
api/v1/resource.go
View file @
36b4ba33
...
...
@@ -161,9 +161,6 @@ func (s *APIV1Service) CreateResource(c echo.Context) error {
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create resource"
)
.
SetInternal
(
err
)
}
if
err
:=
s
.
createResourceCreateActivity
(
ctx
,
resource
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create activity"
)
.
SetInternal
(
err
)
}
return
c
.
JSON
(
http
.
StatusOK
,
convertResourceFromStore
(
resource
))
}
...
...
@@ -233,9 +230,6 @@ func (s *APIV1Service) UploadResource(c echo.Context) error {
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create resource"
)
.
SetInternal
(
err
)
}
if
err
:=
s
.
createResourceCreateActivity
(
ctx
,
resource
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create activity"
)
.
SetInternal
(
err
)
}
return
c
.
JSON
(
http
.
StatusOK
,
convertResourceFromStore
(
resource
))
}
...
...
@@ -353,28 +347,6 @@ func (s *APIV1Service) UpdateResource(c echo.Context) error {
return
c
.
JSON
(
http
.
StatusOK
,
convertResourceFromStore
(
resource
))
}
func
(
s
*
APIV1Service
)
createResourceCreateActivity
(
ctx
context
.
Context
,
resource
*
store
.
Resource
)
error
{
payload
:=
ActivityResourceCreatePayload
{
Filename
:
resource
.
Filename
,
Type
:
resource
.
Type
,
Size
:
resource
.
Size
,
}
payloadBytes
,
err
:=
json
.
Marshal
(
payload
)
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to marshal activity payload"
)
}
activity
,
err
:=
s
.
Store
.
CreateActivity
(
ctx
,
&
store
.
Activity
{
CreatorID
:
resource
.
CreatorID
,
Type
:
ActivityResourceCreate
.
String
(),
Level
:
ActivityInfo
.
String
(),
Payload
:
string
(
payloadBytes
),
})
if
err
!=
nil
||
activity
==
nil
{
return
errors
.
Wrap
(
err
,
"failed to create activity"
)
}
return
err
}
func
replacePathTemplate
(
path
,
filename
string
)
string
{
t
:=
time
.
Now
()
path
=
fileKeyPattern
.
ReplaceAllStringFunc
(
path
,
func
(
s
string
)
string
{
...
...
api/v1/tag.go
View file @
36b4ba33
...
...
@@ -8,7 +8,6 @@ import (
"sort"
"github.com/labstack/echo/v4"
"github.com/pkg/errors"
"golang.org/x/exp/slices"
"github.com/usememos/memos/store"
...
...
@@ -99,9 +98,6 @@ func (s *APIV1Service) CreateTag(c echo.Context) error {
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to upsert tag"
)
.
SetInternal
(
err
)
}
tagMessage
:=
convertTagFromStore
(
tag
)
if
err
:=
s
.
createTagCreateActivity
(
c
,
tagMessage
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create activity"
)
.
SetInternal
(
err
)
}
return
c
.
JSON
(
http
.
StatusOK
,
tagMessage
.
Name
)
}
...
...
@@ -196,27 +192,6 @@ func (s *APIV1Service) GetTagSuggestion(c echo.Context) error {
return
c
.
JSON
(
http
.
StatusOK
,
tagList
)
}
func
(
s
*
APIV1Service
)
createTagCreateActivity
(
c
echo
.
Context
,
tag
*
Tag
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
payload
:=
ActivityTagCreatePayload
{
TagName
:
tag
.
Name
,
}
payloadBytes
,
err
:=
json
.
Marshal
(
payload
)
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to marshal activity payload"
)
}
activity
,
err
:=
s
.
Store
.
CreateActivity
(
ctx
,
&
store
.
Activity
{
CreatorID
:
tag
.
CreatorID
,
Type
:
ActivityTagCreate
.
String
(),
Level
:
ActivityInfo
.
String
(),
Payload
:
string
(
payloadBytes
),
})
if
err
!=
nil
||
activity
==
nil
{
return
errors
.
Wrap
(
err
,
"failed to create activity"
)
}
return
err
}
func
convertTagFromStore
(
tag
*
store
.
Tag
)
*
Tag
{
return
&
Tag
{
Name
:
tag
.
Name
,
...
...
api/v1/user.go
View file @
36b4ba33
...
...
@@ -167,9 +167,6 @@ func (s *APIV1Service) CreateUser(c echo.Context) error {
}
userMessage
:=
convertUserFromStore
(
user
)
if
err
:=
s
.
createUserCreateActivity
(
c
,
userMessage
);
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to create activity"
)
.
SetInternal
(
err
)
}
metric
.
Enqueue
(
"user create"
)
return
c
.
JSON
(
http
.
StatusOK
,
userMessage
)
}
...
...
@@ -473,29 +470,6 @@ func (update UpdateUserRequest) Validate() error {
return
nil
}
func
(
s
*
APIV1Service
)
createUserCreateActivity
(
c
echo
.
Context
,
user
*
User
)
error
{
ctx
:=
c
.
Request
()
.
Context
()
payload
:=
ActivityUserCreatePayload
{
UserID
:
user
.
ID
,
Username
:
user
.
Username
,
Role
:
user
.
Role
,
}
payloadBytes
,
err
:=
json
.
Marshal
(
payload
)
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to marshal activity payload"
)
}
activity
,
err
:=
s
.
Store
.
CreateActivity
(
ctx
,
&
store
.
Activity
{
CreatorID
:
user
.
ID
,
Type
:
ActivityUserCreate
.
String
(),
Level
:
ActivityInfo
.
String
(),
Payload
:
string
(
payloadBytes
),
})
if
err
!=
nil
||
activity
==
nil
{
return
errors
.
Wrap
(
err
,
"failed to create activity"
)
}
return
err
}
func
convertUserFromStore
(
user
*
store
.
User
)
*
User
{
return
&
User
{
ID
:
user
.
ID
,
...
...
api/v2/inbox_service .go
View file @
36b4ba33
...
...
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"github.com/pkg/errors"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
...
...
@@ -87,14 +88,27 @@ func (s *APIV2Service) DeleteInbox(ctx context.Context, request *apiv2pb.DeleteI
return
&
apiv2pb
.
DeleteInboxResponse
{},
nil
}
func
(
*
APIV2Service
)
convertInboxFromStore
(
_
context
.
Context
,
inbox
*
store
.
Inbox
)
(
*
apiv2pb
.
Inbox
,
error
)
{
// TODO: convert sender and receiver.
func
(
s
*
APIV2Service
)
convertInboxFromStore
(
ctx
context
.
Context
,
inbox
*
store
.
Inbox
)
(
*
apiv2pb
.
Inbox
,
error
)
{
sender
,
err
:=
s
.
Store
.
GetUser
(
ctx
,
&
store
.
FindUser
{
ID
:
&
inbox
.
SenderID
,
})
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"failed to get sender"
)
}
receiver
,
err
:=
s
.
Store
.
GetUser
(
ctx
,
&
store
.
FindUser
{
ID
:
&
inbox
.
ReceiverID
,
})
if
err
!=
nil
{
return
nil
,
errors
.
Wrap
(
err
,
"failed to get receiver"
)
}
return
&
apiv2pb
.
Inbox
{
Name
:
fmt
.
Sprintf
(
"inbox/%d"
,
inbox
.
ID
),
Status
:
convertInboxStatusFromStore
(
inbox
.
Status
),
Title
:
inbox
.
Message
.
Title
,
Content
:
inbox
.
Message
.
Content
,
Link
:
inbox
.
Message
.
Link
,
Name
:
fmt
.
Sprintf
(
"inbox/%d"
,
inbox
.
ID
),
Sender
:
fmt
.
Sprintf
(
"users/%s"
,
sender
.
Username
),
Receiver
:
fmt
.
Sprintf
(
"users/%s"
,
receiver
.
Username
),
Status
:
convertInboxStatusFromStore
(
inbox
.
Status
),
Type
:
apiv2pb
.
Inbox_Type
(
inbox
.
Message
.
Type
),
ActivityId
:
inbox
.
Message
.
ActivityId
,
},
nil
}
...
...
proto/api/v2/inbox_service.proto
View file @
36b4ba33
...
...
@@ -44,11 +44,13 @@ message Inbox {
}
Status
status
=
4
;
string
title
=
5
;
string
content
=
6
;
enum
Type
{
TYPE_UNSPECIFIED
=
0
;
TYPE_MEMO_COMMENT
=
1
;
}
Type
type
=
5
;
string
link
=
7
;
optional
int32
activity_id
=
6
;
}
message
ListInboxRequest
{
...
...
proto/gen/api/v2/README.md
View file @
36b4ba33
...
...
@@ -16,6 +16,7 @@
-
[
UpdateInboxResponse
](
#memos-api-v2-UpdateInboxResponse
)
-
[
Inbox.Status
](
#memos-api-v2-Inbox-Status
)
-
[
Inbox.Type
](
#memos-api-v2-Inbox-Type
)
-
[
InboxService
](
#memos-api-v2-InboxService
)
...
...
@@ -166,9 +167,8 @@
| sender |
[
string
](
#string
)
| | Format: users/{username} |
| receiver |
[
string
](
#string
)
| | Format: users/{username} |
| status |
[
Inbox.Status
](
#memos-api-v2-Inbox-Status
)
| | |
| title |
[
string
](
#string
)
| | |
| content |
[
string
](
#string
)
| | |
| link |
[
string
](
#string
)
| | |
| type |
[
Inbox.Type
](
#memos-api-v2-Inbox-Type
)
| | |
| activity_id |
[
int32
](
#int32
)
| optional | |
...
...
@@ -251,6 +251,18 @@
| ARCHIVED | 3 | |
<a
name=
"memos-api-v2-Inbox-Type"
></a>
### Inbox.Type
| Name | Number | Description |
| ---- | ------ | ----------- |
| TYPE_UNSPECIFIED | 0 | |
| TYPE_MEMO_COMMENT | 1 | |
...
...
proto/gen/api/v2/inbox_service.pb.go
View file @
36b4ba33
This diff is collapsed.
Click to expand it.
proto/gen/store/README.md
View file @
36b4ba33
...
...
@@ -4,10 +4,15 @@
## Table of Contents
-
[
store/activity.proto
](
#store_activity-proto
)
-
[
ActivityMemoCommentPayload
](
#memos-store-ActivityMemoCommentPayload
)
-
[
ActivityPayload
](
#memos-store-ActivityPayload
)
-
[
store/common.proto
](
#store_common-proto
)
-
[
store/inbox.proto
](
#store_inbox-proto
)
-
[
InboxMessage
](
#memos-store-InboxMessage
)
-
[
InboxMessage.Type
](
#memos-store-InboxMessage-Type
)
-
[
store/system_setting.proto
](
#store_system_setting-proto
)
-
[
BackupConfig
](
#memos-store-BackupConfig
)
...
...
@@ -30,6 +35,37 @@
## store/activity.proto
<a
name=
"memos-store-ActivityMemoCommentPayload"
></a>
### ActivityMemoCommentPayload
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| memo_id |
[
int32
](
#int32
)
| | |
| related_memo_id |
[
int32
](
#int32
)
| | |
<a
name=
"memos-store-ActivityPayload"
></a>
### ActivityPayload
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| memo_comment |
[
ActivityMemoCommentPayload
](
#memos-store-ActivityMemoCommentPayload
)
| | |
...
...
@@ -71,9 +107,7 @@
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| title |
[
string
](
#string
)
| | |
| content |
[
string
](
#string
)
| | |
| link |
[
string
](
#string
)
| | |
| type |
[
InboxMessage.Type
](
#memos-store-InboxMessage-Type
)
| | |
| activity_id |
[
int32
](
#int32
)
| optional | |
...
...
@@ -82,6 +116,18 @@
<a
name=
"memos-store-InboxMessage-Type"
></a>
### InboxMessage.Type
| Name | Number | Description |
| ---- | ------ | ----------- |
| TYPE_UNSPECIFIED | 0 | |
| TYPE_MEMO_COMMENT | 1 | |
...
...
proto/gen/store/activity.pb.go
View file @
36b4ba33
...
...
@@ -10,6 +10,7 @@ import (
protoreflect
"google.golang.org/protobuf/reflect/protoreflect"
protoimpl
"google.golang.org/protobuf/runtime/protoimpl"
reflect
"reflect"
sync
"sync"
)
const
(
...
...
@@ -19,31 +20,162 @@ const (
_
=
protoimpl
.
EnforceVersion
(
protoimpl
.
MaxVersion
-
20
)
)
type
ActivityMemoCommentPayload
struct
{
state
protoimpl
.
MessageState
sizeCache
protoimpl
.
SizeCache
unknownFields
protoimpl
.
UnknownFields
MemoId
int32
`protobuf:"varint,1,opt,name=memo_id,json=memoId,proto3" json:"memo_id,omitempty"`
RelatedMemoId
int32
`protobuf:"varint,2,opt,name=related_memo_id,json=relatedMemoId,proto3" json:"related_memo_id,omitempty"`
}
func
(
x
*
ActivityMemoCommentPayload
)
Reset
()
{
*
x
=
ActivityMemoCommentPayload
{}
if
protoimpl
.
UnsafeEnabled
{
mi
:=
&
file_store_activity_proto_msgTypes
[
0
]
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
ms
.
StoreMessageInfo
(
mi
)
}
}
func
(
x
*
ActivityMemoCommentPayload
)
String
()
string
{
return
protoimpl
.
X
.
MessageStringOf
(
x
)
}
func
(
*
ActivityMemoCommentPayload
)
ProtoMessage
()
{}
func
(
x
*
ActivityMemoCommentPayload
)
ProtoReflect
()
protoreflect
.
Message
{
mi
:=
&
file_store_activity_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 ActivityMemoCommentPayload.ProtoReflect.Descriptor instead.
func
(
*
ActivityMemoCommentPayload
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
file_store_activity_proto_rawDescGZIP
(),
[]
int
{
0
}
}
func
(
x
*
ActivityMemoCommentPayload
)
GetMemoId
()
int32
{
if
x
!=
nil
{
return
x
.
MemoId
}
return
0
}
func
(
x
*
ActivityMemoCommentPayload
)
GetRelatedMemoId
()
int32
{
if
x
!=
nil
{
return
x
.
RelatedMemoId
}
return
0
}
type
ActivityPayload
struct
{
state
protoimpl
.
MessageState
sizeCache
protoimpl
.
SizeCache
unknownFields
protoimpl
.
UnknownFields
MemoComment
*
ActivityMemoCommentPayload
`protobuf:"bytes,1,opt,name=memo_comment,json=memoComment,proto3" json:"memo_comment,omitempty"`
}
func
(
x
*
ActivityPayload
)
Reset
()
{
*
x
=
ActivityPayload
{}
if
protoimpl
.
UnsafeEnabled
{
mi
:=
&
file_store_activity_proto_msgTypes
[
1
]
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
ms
.
StoreMessageInfo
(
mi
)
}
}
func
(
x
*
ActivityPayload
)
String
()
string
{
return
protoimpl
.
X
.
MessageStringOf
(
x
)
}
func
(
*
ActivityPayload
)
ProtoMessage
()
{}
func
(
x
*
ActivityPayload
)
ProtoReflect
()
protoreflect
.
Message
{
mi
:=
&
file_store_activity_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 ActivityPayload.ProtoReflect.Descriptor instead.
func
(
*
ActivityPayload
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
file_store_activity_proto_rawDescGZIP
(),
[]
int
{
1
}
}
func
(
x
*
ActivityPayload
)
GetMemoComment
()
*
ActivityMemoCommentPayload
{
if
x
!=
nil
{
return
x
.
MemoComment
}
return
nil
}
var
File_store_activity_proto
protoreflect
.
FileDescriptor
var
file_store_activity_proto_rawDesc
=
[]
byte
{
0x0a
,
0x14
,
0x73
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x2f
,
0x61
,
0x63
,
0x74
,
0x69
,
0x76
,
0x69
,
0x74
,
0x79
,
0x2e
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x12
,
0x0b
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x73
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x42
,
0x98
,
0x01
,
0x0a
,
0x0f
,
0x63
,
0x6f
,
0x6d
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x73
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x42
,
0x0d
,
0x41
,
0x63
,
0x74
,
0x69
,
0x76
,
0x69
,
0x74
,
0x79
,
0x50
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x50
,
0x01
,
0x5a
,
0x29
,
0x67
,
0x69
,
0x74
,
0x68
,
0x75
,
0x62
,
0x2e
,
0x63
,
0x6f
,
0x6d
,
0x2f
,
0x75
,
0x73
,
0x65
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2f
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2f
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x2f
,
0x67
,
0x65
,
0x6e
,
0x2f
,
0x73
,
0x74
,
0x6f
,
0x72
,
0x65
,
0xa2
,
0x02
,
0x03
,
0x4d
,
0x53
,
0x58
,
0xaa
,
0x02
,
0x0b
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0xca
,
0x02
,
0x0b
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0xe2
,
0x02
,
0x17
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x5c
,
0x47
,
0x50
,
0x42
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0xea
,
0x02
,
0x0c
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x3a
,
0x3a
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x62
,
0x06
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x33
,
}
var
file_store_activity_proto_goTypes
=
[]
interface
{}{}
0x6f
,
0x72
,
0x65
,
0x22
,
0x5d
,
0x0a
,
0x1a
,
0x41
,
0x63
,
0x74
,
0x69
,
0x76
,
0x69
,
0x74
,
0x79
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x43
,
0x6f
,
0x6d
,
0x6d
,
0x65
,
0x6e
,
0x74
,
0x50
,
0x61
,
0x79
,
0x6c
,
0x6f
,
0x61
,
0x64
,
0x12
,
0x17
,
0x0a
,
0x07
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x5f
,
0x69
,
0x64
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x05
,
0x52
,
0x06
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x49
,
0x64
,
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
0x69
,
0x76
,
0x69
,
0x74
,
0x79
,
0x50
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x50
,
0x01
,
0x5a
,
0x29
,
0x67
,
0x69
,
0x74
,
0x68
,
0x75
,
0x62
,
0x2e
,
0x63
,
0x6f
,
0x6d
,
0x2f
,
0x75
,
0x73
,
0x65
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2f
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2f
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x2f
,
0x67
,
0x65
,
0x6e
,
0x2f
,
0x73
,
0x74
,
0x6f
,
0x72
,
0x65
,
0xa2
,
0x02
,
0x03
,
0x4d
,
0x53
,
0x58
,
0xaa
,
0x02
,
0x0b
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0xca
,
0x02
,
0x0b
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0xe2
,
0x02
,
0x17
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x5c
,
0x47
,
0x50
,
0x42
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0xea
,
0x02
,
0x0c
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x3a
,
0x3a
,
0x53
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x62
,
0x06
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x33
,
}
var
(
file_store_activity_proto_rawDescOnce
sync
.
Once
file_store_activity_proto_rawDescData
=
file_store_activity_proto_rawDesc
)
func
file_store_activity_proto_rawDescGZIP
()
[]
byte
{
file_store_activity_proto_rawDescOnce
.
Do
(
func
()
{
file_store_activity_proto_rawDescData
=
protoimpl
.
X
.
CompressGZIP
(
file_store_activity_proto_rawDescData
)
})
return
file_store_activity_proto_rawDescData
}
var
file_store_activity_proto_msgTypes
=
make
([]
protoimpl
.
MessageInfo
,
2
)
var
file_store_activity_proto_goTypes
=
[]
interface
{}{
(
*
ActivityMemoCommentPayload
)(
nil
),
// 0: memos.store.ActivityMemoCommentPayload
(
*
ActivityPayload
)(
nil
),
// 1: memos.store.ActivityPayload
}
var
file_store_activity_proto_depIdxs
=
[]
int32
{
0
,
// [0:0] is the sub-list for method output_type
0
,
// [0:0] is the sub-list for method input_type
0
,
// [0:0] is the sub-list for extension type_name
0
,
// [0:0] is the sub-list for extension extendee
0
,
// [0:0] is the sub-list for field type_name
0
,
// 0: memos.store.ActivityPayload.memo_comment:type_name -> memos.store.ActivityMemoCommentPayload
1
,
// [1:1] is the sub-list for method output_type
1
,
// [1:1] is the sub-list for method input_type
1
,
// [1:1] is the sub-list for extension type_name
1
,
// [1:1] is the sub-list for extension extendee
0
,
// [0:1] is the sub-list for field type_name
}
func
init
()
{
file_store_activity_proto_init
()
}
...
...
@@ -51,18 +183,45 @@ func file_store_activity_proto_init() {
if
File_store_activity_proto
!=
nil
{
return
}
if
!
protoimpl
.
UnsafeEnabled
{
file_store_activity_proto_msgTypes
[
0
]
.
Exporter
=
func
(
v
interface
{},
i
int
)
interface
{}
{
switch
v
:=
v
.
(
*
ActivityMemoCommentPayload
);
i
{
case
0
:
return
&
v
.
state
case
1
:
return
&
v
.
sizeCache
case
2
:
return
&
v
.
unknownFields
default
:
return
nil
}
}
file_store_activity_proto_msgTypes
[
1
]
.
Exporter
=
func
(
v
interface
{},
i
int
)
interface
{}
{
switch
v
:=
v
.
(
*
ActivityPayload
);
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_store_activity_proto_rawDesc
,
NumEnums
:
0
,
NumMessages
:
0
,
NumMessages
:
2
,
NumExtensions
:
0
,
NumServices
:
0
,
},
GoTypes
:
file_store_activity_proto_goTypes
,
DependencyIndexes
:
file_store_activity_proto_depIdxs
,
MessageInfos
:
file_store_activity_proto_msgTypes
,
}
.
Build
()
File_store_activity_proto
=
out
.
File
file_store_activity_proto_rawDesc
=
nil
...
...
proto/gen/store/inbox.pb.go
View file @
36b4ba33
...
...
@@ -20,15 +20,59 @@ const (
_
=
protoimpl
.
EnforceVersion
(
protoimpl
.
MaxVersion
-
20
)
)
type
InboxMessage_Type
int32
const
(
InboxMessage_TYPE_UNSPECIFIED
InboxMessage_Type
=
0
InboxMessage_TYPE_MEMO_COMMENT
InboxMessage_Type
=
1
)
// Enum value maps for InboxMessage_Type.
var
(
InboxMessage_Type_name
=
map
[
int32
]
string
{
0
:
"TYPE_UNSPECIFIED"
,
1
:
"TYPE_MEMO_COMMENT"
,
}
InboxMessage_Type_value
=
map
[
string
]
int32
{
"TYPE_UNSPECIFIED"
:
0
,
"TYPE_MEMO_COMMENT"
:
1
,
}
)
func
(
x
InboxMessage_Type
)
Enum
()
*
InboxMessage_Type
{
p
:=
new
(
InboxMessage_Type
)
*
p
=
x
return
p
}
func
(
x
InboxMessage_Type
)
String
()
string
{
return
protoimpl
.
X
.
EnumStringOf
(
x
.
Descriptor
(),
protoreflect
.
EnumNumber
(
x
))
}
func
(
InboxMessage_Type
)
Descriptor
()
protoreflect
.
EnumDescriptor
{
return
file_store_inbox_proto_enumTypes
[
0
]
.
Descriptor
()
}
func
(
InboxMessage_Type
)
Type
()
protoreflect
.
EnumType
{
return
&
file_store_inbox_proto_enumTypes
[
0
]
}
func
(
x
InboxMessage_Type
)
Number
()
protoreflect
.
EnumNumber
{
return
protoreflect
.
EnumNumber
(
x
)
}
// Deprecated: Use InboxMessage_Type.Descriptor instead.
func
(
InboxMessage_Type
)
EnumDescriptor
()
([]
byte
,
[]
int
)
{
return
file_store_inbox_proto_rawDescGZIP
(),
[]
int
{
0
,
0
}
}
type
InboxMessage
struct
{
state
protoimpl
.
MessageState
sizeCache
protoimpl
.
SizeCache
unknownFields
protoimpl
.
UnknownFields
Title
string
`protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
Content
string
`protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
Link
string
`protobuf:"bytes,3,opt,name=link,proto3" json:"link,omitempty"`
ActivityId
*
int32
`protobuf:"varint,4,opt,name=activity_id,json=activityId,proto3,oneof" json:"activity_id,omitempty"`
Type
InboxMessage_Type
`protobuf:"varint,1,opt,name=type,proto3,enum=memos.store.InboxMessage_Type" json:"type,omitempty"`
ActivityId
*
int32
`protobuf:"varint,2,opt,name=activity_id,json=activityId,proto3,oneof" json:"activity_id,omitempty"`
}
func
(
x
*
InboxMessage
)
Reset
()
{
...
...
@@ -63,25 +107,11 @@ func (*InboxMessage) Descriptor() ([]byte, []int) {
return
file_store_inbox_proto_rawDescGZIP
(),
[]
int
{
0
}
}
func
(
x
*
InboxMessage
)
GetTitle
()
string
{
if
x
!=
nil
{
return
x
.
Title
}
return
""
}
func
(
x
*
InboxMessage
)
GetContent
()
string
{
if
x
!=
nil
{
return
x
.
Content
}
return
""
}
func
(
x
*
InboxMessage
)
GetLink
()
string
{
func
(
x
*
InboxMessage
)
GetType
()
InboxMessage_Type
{
if
x
!=
nil
{
return
x
.
Link
return
x
.
Type
}
return
""
return
InboxMessage_TYPE_UNSPECIFIED
}
func
(
x
*
InboxMessage
)
GetActivityId
()
int32
{
...
...
@@ -96,25 +126,27 @@ var File_store_inbox_proto protoreflect.FileDescriptor
var
file_store_inbox_proto_rawDesc
=
[]
byte
{
0x0a
,
0x11
,
0x73
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x2f
,
0x69
,
0x6e
,
0x62
,
0x6f
,
0x78
,
0x2e
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x12
,
0x0b
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x73
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x22
,
0x88
,
0x01
,
0x0a
,
0x0c
,
0x49
,
0x6e
,
0x62
,
0x6f
,
0x78
,
0x4d
,
0x65
,
0x73
,
0x73
,
0x61
,
0x67
,
0x65
,
0x12
,
0x14
,
0x0a
,
0x05
,
0x74
,
0x69
,
0x74
,
0x6c
,
0x65
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x05
,
0x74
,
0x69
,
0x74
,
0x6c
,
0x65
,
0x12
,
0x18
,
0x0a
,
0x07
,
0x63
,
0x6f
,
0x6e
,
0x74
,
0x65
,
0x6e
,
0x74
,
0x18
,
0x02
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x07
,
0x63
,
0x6f
,
0x6e
,
0x74
,
0x65
,
0x6e
,
0x74
,
0x12
,
0x12
,
0x0a
,
0x04
,
0x6c
,
0x69
,
0x6e
,
0x6b
,
0x18
,
0x03
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x04
,
0x6c
,
0x69
,
0x6e
,
0x6b
,
0x12
,
0x24
,
0x0a
,
0x0b
,
0x61
,
0x63
,
0x74
,
0x69
,
0x76
,
0x69
,
0x74
,
0x79
,
0x5f
,
0x69
,
0x64
,
0x18
,
0x04
,
0x20
,
0x01
,
0x28
,
0x05
,
0x48
,
0x00
,
0x52
,
0x0a
,
0x61
,
0x63
,
0x74
,
0x69
,
0x76
,
0x69
,
0x74
,
0x79
,
0x49
,
0x64
,
0x88
,
0x01
,
0x01
,
0x42
,
0x0e
,
0x0a
,
0x0c
,
0x5f
,
0x61
,
0x63
,
0x74
,
0x69
,
0x76
,
0x69
,
0x74
,
0x79
,
0x5f
,
0x69
,
0x64
,
0x42
,
0x95
,
0x01
,
0x0a
,
0x0f
,
0x63
,
0x6f
,
0x6d
,
0x2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6f
,
0x78
,
0x4d
,
0x65
,
0x73
,
0x73
,
0x61
,
0x67
,
0x65
,
0x12
,
0x32
,
0x0a
,
0x04
,
0x74
,
0x79
,
0x70
,
0x65
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x0e
,
0x32
,
0x1e
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x73
,
0x74
,
0x6f
,
0x72
,
0x65
,
0x2e
,
0x49
,
0x6e
,
0x62
,
0x6f
,
0x78
,
0x4d
,
0x65
,
0x73
,
0x73
,
0x61
,
0x67
,
0x65
,
0x2e
,
0x54
,
0x79
,
0x70
,
0x65
,
0x52
,
0x04
,
0x74
,
0x79
,
0x70
,
0x65
,
0x12
,
0x24
,
0x0a
,
0x0b
,
0x61
,
0x63
,
0x74
,
0x69
,
0x76
,
0x69
,
0x74
,
0x79
,
0x5f
,
0x69
,
0x64
,
0x18
,
0x02
,
0x20
,
0x01
,
0x28
,
0x05
,
0x48
,
0x00
,
0x52
,
0x0a
,
0x61
,
0x63
,
0x74
,
0x69
,
0x76
,
0x69
,
0x74
,
0x79
,
0x49
,
0x64
,
0x88
,
0x01
,
0x01
,
0x22
,
0x33
,
0x0a
,
0x04
,
0x54
,
0x79
,
0x70
,
0x65
,
0x12
,
0x14
,
0x0a
,
0x10
,
0x54
,
0x59
,
0x50
,
0x45
,
0x5f
,
0x55
,
0x4e
,
0x53
,
0x50
,
0x45
,
0x43
,
0x49
,
0x46
,
0x49
,
0x45
,
0x44
,
0x10
,
0x00
,
0x12
,
0x15
,
0x0a
,
0x11
,
0x54
,
0x59
,
0x50
,
0x45
,
0x5f
,
0x4d
,
0x45
,
0x4d
,
0x4f
,
0x5f
,
0x43
,
0x4f
,
0x4d
,
0x4d
,
0x45
,
0x4e
,
0x54
,
0x10
,
0x01
,
0x42
,
0x0e
,
0x0a
,
0x0c
,
0x5f
,
0x61
,
0x63
,
0x74
,
0x69
,
0x76
,
0x69
,
0x74
,
0x79
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f
,
0x74
,
0x6f
,
0x33
,
}
var
(
...
...
@@ -129,16 +161,19 @@ func file_store_inbox_proto_rawDescGZIP() []byte {
return
file_store_inbox_proto_rawDescData
}
var
file_store_inbox_proto_enumTypes
=
make
([]
protoimpl
.
EnumInfo
,
1
)
var
file_store_inbox_proto_msgTypes
=
make
([]
protoimpl
.
MessageInfo
,
1
)
var
file_store_inbox_proto_goTypes
=
[]
interface
{}{
(
*
InboxMessage
)(
nil
),
// 0: memos.store.InboxMessage
(
InboxMessage_Type
)(
0
),
// 0: memos.store.InboxMessage.Type
(
*
InboxMessage
)(
nil
),
// 1: memos.store.InboxMessage
}
var
file_store_inbox_proto_depIdxs
=
[]
int32
{
0
,
// [0:0] is the sub-list for method output_type
0
,
// [0:0] is the sub-list for method input_type
0
,
// [0:0] is the sub-list for extension type_name
0
,
// [0:0] is the sub-list for extension extendee
0
,
// [0:0] is the sub-list for field type_name
0
,
// 0: memos.store.InboxMessage.type:type_name -> memos.store.InboxMessage.Type
1
,
// [1:1] is the sub-list for method output_type
1
,
// [1:1] is the sub-list for method input_type
1
,
// [1:1] is the sub-list for extension type_name
1
,
// [1:1] is the sub-list for extension extendee
0
,
// [0:1] is the sub-list for field type_name
}
func
init
()
{
file_store_inbox_proto_init
()
}
...
...
@@ -166,13 +201,14 @@ func file_store_inbox_proto_init() {
File
:
protoimpl
.
DescBuilder
{
GoPackagePath
:
reflect
.
TypeOf
(
x
{})
.
PkgPath
(),
RawDescriptor
:
file_store_inbox_proto_rawDesc
,
NumEnums
:
0
,
NumEnums
:
1
,
NumMessages
:
1
,
NumExtensions
:
0
,
NumServices
:
0
,
},
GoTypes
:
file_store_inbox_proto_goTypes
,
DependencyIndexes
:
file_store_inbox_proto_depIdxs
,
EnumInfos
:
file_store_inbox_proto_enumTypes
,
MessageInfos
:
file_store_inbox_proto_msgTypes
,
}
.
Build
()
File_store_inbox_proto
=
out
.
File
...
...
proto/store/activity.proto
View file @
36b4ba33
...
...
@@ -3,3 +3,12 @@ syntax = "proto3";
package
memos
.
store
;
option
go_package
=
"gen/store"
;
message
ActivityMemoCommentPayload
{
int32
memo_id
=
1
;
int32
related_memo_id
=
2
;
}
message
ActivityPayload
{
ActivityMemoCommentPayload
memo_comment
=
1
;
}
proto/store/inbox.proto
View file @
36b4ba33
...
...
@@ -5,8 +5,10 @@ package memos.store;
option
go_package
=
"gen/store"
;
message
InboxMessage
{
string
title
=
1
;
string
content
=
2
;
string
link
=
3
;
optional
int32
activity_id
=
4
;
enum
Type
{
TYPE_UNSPECIFIED
=
0
;
TYPE_MEMO_COMMENT
=
1
;
}
Type
type
=
1
;
optional
int32
activity_id
=
2
;
}
server/server.go
View file @
36b4ba33
...
...
@@ -2,7 +2,6 @@ package server
import
(
"context"
"encoding/json"
"fmt"
"net/http"
"strings"
...
...
@@ -112,10 +111,6 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
}
func
(
s
*
Server
)
Start
(
ctx
context
.
Context
)
error
{
if
err
:=
s
.
createServerStartActivity
(
ctx
);
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to create activity"
)
}
go
s
.
telegramBot
.
Start
(
ctx
)
go
s
.
backupRunner
.
Run
(
ctx
)
...
...
@@ -182,26 +177,6 @@ func (s *Server) getSystemSecretSessionName(ctx context.Context) (string, error)
return
secretSessionNameValue
.
Value
,
nil
}
func
(
s
*
Server
)
createServerStartActivity
(
ctx
context
.
Context
)
error
{
payload
:=
apiv1
.
ActivityServerStartPayload
{
ServerID
:
s
.
ID
,
Profile
:
s
.
Profile
,
}
payloadBytes
,
err
:=
json
.
Marshal
(
payload
)
if
err
!=
nil
{
return
errors
.
Wrap
(
err
,
"failed to marshal activity payload"
)
}
activity
,
err
:=
s
.
Store
.
CreateActivity
(
ctx
,
&
store
.
Activity
{
Type
:
apiv1
.
ActivityServerStart
.
String
(),
Level
:
apiv1
.
ActivityInfo
.
String
(),
Payload
:
string
(
payloadBytes
),
})
if
err
!=
nil
||
activity
==
nil
{
return
errors
.
Wrap
(
err
,
"failed to create activity"
)
}
return
err
}
func
grpcRequestSkipper
(
c
echo
.
Context
)
bool
{
return
strings
.
HasPrefix
(
c
.
Request
()
.
URL
.
Path
,
"/memos.api.v2."
)
}
web/src/grpcweb.ts
View file @
36b4ba33
import
{
createChannel
,
createClientFactory
,
FetchTransport
}
from
"nice-grpc-web"
;
import
{
InboxServiceDefinition
}
from
"./types/proto/api/v2/inbox_service"
;
import
{
MemoServiceDefinition
}
from
"./types/proto/api/v2/memo_service"
;
import
{
ResourceServiceDefinition
}
from
"./types/proto/api/v2/resource_service"
;
import
{
SystemServiceDefinition
}
from
"./types/proto/api/v2/system_service"
;
...
...
@@ -23,3 +24,5 @@ export const resourceServiceClient = clientFactory.create(ResourceServiceDefinit
export
const
systemServiceClient
=
clientFactory
.
create
(
SystemServiceDefinition
,
channel
);
export
const
tagServiceClient
=
clientFactory
.
create
(
TagServiceDefinition
,
channel
);
export
const
inboxServiceClient
=
clientFactory
.
create
(
InboxServiceDefinition
,
channel
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment