Commit 63989ab3 authored by Steven's avatar Steven

feat: add location to memo payload

parent 92c41458
......@@ -188,6 +188,9 @@ message Memo {
// The snippet of the memo content. Plain text only.
string snippet = 19;
// The location of the memo.
optional Location location = 20;
}
message MemoProperty {
......@@ -198,6 +201,12 @@ message MemoProperty {
bool has_incomplete_tasks = 5;
}
message Location {
string placeholder = 1;
double latitude = 2;
double longitude = 3;
}
message CreateMemoRequest {
string content = 1;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -872,6 +872,9 @@ paths:
snippet:
type: string
description: The snippet of the memo content. Plain text only.
location:
$ref: '#/definitions/apiv1Location'
description: The location of the memo.
tags:
- MemoService
/api/v1/{name_1}:
......@@ -2000,6 +2003,17 @@ definitions:
- TYPE_UNSPECIFIED
- OAUTH2
default: TYPE_UNSPECIFIED
apiv1Location:
type: object
properties:
placeholder:
type: string
latitude:
type: number
format: double
longitude:
type: number
format: double
apiv1OAuth2Config:
type: object
properties:
......@@ -2697,6 +2711,9 @@ definitions:
snippet:
type: string
description: The snippet of the memo content. Plain text only.
location:
$ref: '#/definitions/apiv1Location'
description: The location of the memo.
v1MemoProperty:
type: object
properties:
......
This diff is collapsed.
......@@ -5,9 +5,10 @@ package memos.store;
option go_package = "gen/store";
message MemoPayload {
// property is the memo's property.
Property property = 1;
Location location = 2;
message Property {
repeated string tags = 1;
bool has_link = 2;
......@@ -15,4 +16,10 @@ message MemoPayload {
bool has_code = 4;
bool has_incomplete_tasks = 5;
}
message Location {
string placeholder = 1;
double latitude = 2;
double longitude = 3;
}
}
......@@ -327,6 +327,9 @@ func (s *APIV1Service) UpdateMemo(ctx context.Context, request *v1pb.UpdateMemoR
if err != nil {
return nil, errors.Wrap(err, "failed to set memo relations")
}
} else if path == "location" {
memo.Payload.Location = convertLocationToStore(request.Memo.Location)
update.Payload = memo.Payload
}
}
......@@ -810,6 +813,7 @@ func (s *APIV1Service) convertMemoFromStore(ctx context.Context, memo *store.Mem
}
if memo.Payload != nil {
memoMessage.Property = convertMemoPropertyFromStore(memo.Payload.Property)
memoMessage.Location = convertLocationFromStore(memo.Payload.Location)
}
if memo.ParentID != nil {
parent := fmt.Sprintf("%s%d", MemoNamePrefix, *memo.ParentID)
......@@ -831,6 +835,28 @@ func convertMemoPropertyFromStore(property *storepb.MemoPayload_Property) *v1pb.
}
}
func convertLocationFromStore(location *storepb.MemoPayload_Location) *v1pb.Location {
if location == nil {
return nil
}
return &v1pb.Location{
Placeholder: location.Placeholder,
Latitude: location.Latitude,
Longitude: location.Longitude,
}
}
func convertLocationToStore(location *v1pb.Location) *storepb.MemoPayload_Location {
if location == nil {
return nil
}
return &storepb.MemoPayload_Location{
Placeholder: location.Placeholder,
Latitude: location.Latitude,
Longitude: location.Longitude,
}
}
func convertVisibilityFromStore(visibility store.Visibility) v1pb.Visibility {
switch visibility {
case store.Private:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment