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
7549c807
Commit
7549c807
authored
Oct 01, 2023
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: update memo view activity
parent
de5eccf9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
11 deletions
+35
-11
activity.go
api/v1/activity.go
+7
-2
common.go
api/v1/common.go
+0
-3
memo.go
api/v1/memo.go
+25
-2
server.go
server/server.go
+3
-4
No files found.
api/v1/activity.go
View file @
7549c807
...
@@ -25,6 +25,8 @@ const (
...
@@ -25,6 +25,8 @@ const (
// ActivityMemoCreate is the type for creating memos.
// ActivityMemoCreate is the type for creating memos.
ActivityMemoCreate
ActivityType
=
"memo.create"
ActivityMemoCreate
ActivityType
=
"memo.create"
// ActivityMemoView is the type for viewing memos.
ActivityMemoView
ActivityType
=
"memo.view"
// ActivityMemoUpdate is the type for updating memos.
// ActivityMemoUpdate is the type for updating memos.
ActivityMemoUpdate
ActivityType
=
"memo.update"
ActivityMemoUpdate
ActivityType
=
"memo.update"
// ActivityMemoDelete is the type for deleting memos.
// ActivityMemoDelete is the type for deleting memos.
...
@@ -87,8 +89,11 @@ type ActivityUserAuthSignUpPayload struct {
...
@@ -87,8 +89,11 @@ type ActivityUserAuthSignUpPayload struct {
}
}
type
ActivityMemoCreatePayload
struct
{
type
ActivityMemoCreatePayload
struct
{
Content
string
`json:"content"`
MemoID
int32
`json:"memoId"`
Visibility
string
`json:"visibility"`
}
type
ActivityMemoViewPayload
struct
{
MemoID
int32
`json:"memoId"`
}
}
type
ActivityResourceCreatePayload
struct
{
type
ActivityResourceCreatePayload
struct
{
...
...
api/v1/common.go
View file @
7549c807
package
v1
package
v1
// UnknownID is the ID for unknowns.
const
UnknownID
=
-
1
// RowStatus is the status for a row.
// RowStatus is the status for a row.
type
RowStatus
string
type
RowStatus
string
...
...
api/v1/memo.go
View file @
7549c807
...
@@ -555,6 +555,9 @@ func (s *APIV1Service) GetMemo(c echo.Context) error {
...
@@ -555,6 +555,9 @@ func (s *APIV1Service) GetMemo(c echo.Context) error {
return
echo
.
NewHTTPError
(
http
.
StatusForbidden
,
"this memo is protected, missing user in session"
)
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
)
memoResponse
,
err
:=
s
.
convertMemoFromStore
(
ctx
,
memo
)
if
err
!=
nil
{
if
err
!=
nil
{
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to compose memo response"
)
.
SetInternal
(
err
)
return
echo
.
NewHTTPError
(
http
.
StatusInternalServerError
,
"Failed to compose memo response"
)
.
SetInternal
(
err
)
...
@@ -753,8 +756,7 @@ func (s *APIV1Service) UpdateMemo(c echo.Context) error {
...
@@ -753,8 +756,7 @@ func (s *APIV1Service) UpdateMemo(c echo.Context) error {
func
(
s
*
APIV1Service
)
createMemoCreateActivity
(
ctx
context
.
Context
,
memo
*
store
.
Memo
)
error
{
func
(
s
*
APIV1Service
)
createMemoCreateActivity
(
ctx
context
.
Context
,
memo
*
store
.
Memo
)
error
{
payload
:=
ActivityMemoCreatePayload
{
payload
:=
ActivityMemoCreatePayload
{
Content
:
memo
.
Content
,
MemoID
:
memo
.
ID
,
Visibility
:
memo
.
Visibility
.
String
(),
}
}
payloadBytes
,
err
:=
json
.
Marshal
(
payload
)
payloadBytes
,
err
:=
json
.
Marshal
(
payload
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -772,6 +774,27 @@ func (s *APIV1Service) createMemoCreateActivity(ctx context.Context, memo *store
...
@@ -772,6 +774,27 @@ func (s *APIV1Service) createMemoCreateActivity(ctx context.Context, memo *store
return
err
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
)
{
func
(
s
*
APIV1Service
)
convertMemoFromStore
(
ctx
context
.
Context
,
memo
*
store
.
Memo
)
(
*
Memo
,
error
)
{
memoResponse
:=
&
Memo
{
memoResponse
:=
&
Memo
{
ID
:
memo
.
ID
,
ID
:
memo
.
ID
,
...
...
server/server.go
View file @
7549c807
...
@@ -221,7 +221,6 @@ func (s *Server) createServerStartActivity(ctx context.Context) error {
...
@@ -221,7 +221,6 @@ func (s *Server) createServerStartActivity(ctx context.Context) error {
return
errors
.
Wrap
(
err
,
"failed to marshal activity payload"
)
return
errors
.
Wrap
(
err
,
"failed to marshal activity payload"
)
}
}
activity
,
err
:=
s
.
Store
.
CreateActivity
(
ctx
,
&
store
.
Activity
{
activity
,
err
:=
s
.
Store
.
CreateActivity
(
ctx
,
&
store
.
Activity
{
CreatorID
:
apiv1
.
UnknownID
,
Type
:
apiv1
.
ActivityServerStart
.
String
(),
Type
:
apiv1
.
ActivityServerStart
.
String
(),
Level
:
apiv1
.
ActivityInfo
.
String
(),
Level
:
apiv1
.
ActivityInfo
.
String
(),
Payload
:
string
(
payloadBytes
),
Payload
:
string
(
payloadBytes
),
...
...
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