From 5d740c3813b665ee5a6a1991e74eeab37343f6b7 Mon Sep 17 00:00:00 2001 From: Steven Date: Wed, 13 Mar 2024 20:25:27 +0800 Subject: [PATCH] chore: update link service --- proto/api/v2/link_service.proto | 7 +- proto/gen/api/v2/README.md | 12 +- proto/gen/api/v2/link_service.pb.go | 106 ++++++++--------- server/route/api/v2/apidocs.swagger.yaml | 144 ++++++++++++++++------- server/route/api/v2/link_service.go | 8 +- 5 files changed, 167 insertions(+), 110 deletions(-) diff --git a/proto/api/v2/link_service.proto b/proto/api/v2/link_service.proto index c1d7643a..47b80a82 100644 --- a/proto/api/v2/link_service.proto +++ b/proto/api/v2/link_service.proto @@ -12,17 +12,16 @@ service LinkService { } } -// Metadata message -message Metadata { +message LinkMetadata { string title = 1; string description = 2; string image = 3; } message GetLinkMetadataRequest { - string url = 1; + string link = 1; } message GetLinkMetadataResponse { - Metadata metadata = 1; + LinkMetadata metadata = 1; } diff --git a/proto/gen/api/v2/README.md b/proto/gen/api/v2/README.md index 464a43cc..ae9bb542 100644 --- a/proto/gen/api/v2/README.md +++ b/proto/gen/api/v2/README.md @@ -78,7 +78,7 @@ - [api/v2/link_service.proto](#api_v2_link_service-proto) - [GetLinkMetadataRequest](#memos-api-v2-GetLinkMetadataRequest) - [GetLinkMetadataResponse](#memos-api-v2-GetLinkMetadataResponse) - - [Metadata](#memos-api-v2-Metadata) + - [LinkMetadata](#memos-api-v2-LinkMetadata) - [LinkService](#memos-api-v2-LinkService) @@ -1119,7 +1119,7 @@ Used internally for obfuscating the page token. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| url | [string](#string) | | | +| link | [string](#string) | | | @@ -1134,17 +1134,17 @@ Used internally for obfuscating the page token. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| metadata | [Metadata](#memos-api-v2-Metadata) | | | +| metadata | [LinkMetadata](#memos-api-v2-LinkMetadata) | | | + + - +### LinkMetadata -### Metadata -Metadata message | Field | Type | Label | Description | diff --git a/proto/gen/api/v2/link_service.pb.go b/proto/gen/api/v2/link_service.pb.go index f8d0c9e5..f339c82c 100644 --- a/proto/gen/api/v2/link_service.pb.go +++ b/proto/gen/api/v2/link_service.pb.go @@ -21,8 +21,7 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// Metadata message -type Metadata struct { +type LinkMetadata struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields @@ -32,8 +31,8 @@ type Metadata struct { Image string `protobuf:"bytes,3,opt,name=image,proto3" json:"image,omitempty"` } -func (x *Metadata) Reset() { - *x = Metadata{} +func (x *LinkMetadata) Reset() { + *x = LinkMetadata{} if protoimpl.UnsafeEnabled { mi := &file_api_v2_link_service_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -41,13 +40,13 @@ func (x *Metadata) Reset() { } } -func (x *Metadata) String() string { +func (x *LinkMetadata) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Metadata) ProtoMessage() {} +func (*LinkMetadata) ProtoMessage() {} -func (x *Metadata) ProtoReflect() protoreflect.Message { +func (x *LinkMetadata) ProtoReflect() protoreflect.Message { mi := &file_api_v2_link_service_proto_msgTypes[0] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) @@ -59,26 +58,26 @@ func (x *Metadata) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Metadata.ProtoReflect.Descriptor instead. -func (*Metadata) Descriptor() ([]byte, []int) { +// Deprecated: Use LinkMetadata.ProtoReflect.Descriptor instead. +func (*LinkMetadata) Descriptor() ([]byte, []int) { return file_api_v2_link_service_proto_rawDescGZIP(), []int{0} } -func (x *Metadata) GetTitle() string { +func (x *LinkMetadata) GetTitle() string { if x != nil { return x.Title } return "" } -func (x *Metadata) GetDescription() string { +func (x *LinkMetadata) GetDescription() string { if x != nil { return x.Description } return "" } -func (x *Metadata) GetImage() string { +func (x *LinkMetadata) GetImage() string { if x != nil { return x.Image } @@ -90,7 +89,7 @@ type GetLinkMetadataRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` + Link string `protobuf:"bytes,1,opt,name=link,proto3" json:"link,omitempty"` } func (x *GetLinkMetadataRequest) Reset() { @@ -125,9 +124,9 @@ func (*GetLinkMetadataRequest) Descriptor() ([]byte, []int) { return file_api_v2_link_service_proto_rawDescGZIP(), []int{1} } -func (x *GetLinkMetadataRequest) GetUrl() string { +func (x *GetLinkMetadataRequest) GetLink() string { if x != nil { - return x.Url + return x.Link } return "" } @@ -137,7 +136,7 @@ type GetLinkMetadataResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Metadata *Metadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` + Metadata *LinkMetadata `protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"` } func (x *GetLinkMetadataResponse) Reset() { @@ -172,7 +171,7 @@ func (*GetLinkMetadataResponse) Descriptor() ([]byte, []int) { return file_api_v2_link_service_proto_rawDescGZIP(), []int{2} } -func (x *GetLinkMetadataResponse) GetMetadata() *Metadata { +func (x *GetLinkMetadataResponse) GetMetadata() *LinkMetadata { if x != nil { return x.Metadata } @@ -186,40 +185,41 @@ var file_api_v2_link_service_proto_rawDesc = []byte{ 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 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, 0x22, 0x58, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, - 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x64, 0x65, 0x73, - 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, - 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x69, - 0x6d, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x69, 0x6d, 0x61, 0x67, - 0x65, 0x22, 0x2a, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x4d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x75, - 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x22, 0x4d, 0x0a, - 0x17, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x32, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x6d, 0x65, 0x6d, - 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, - 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x32, 0x87, 0x01, 0x0a, - 0x0b, 0x4c, 0x69, 0x6e, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x78, 0x0a, 0x0f, - 0x47, 0x65, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, - 0x24, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x47, + 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x5c, 0x0a, 0x0c, 0x4c, 0x69, 0x6e, 0x6b, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x20, 0x0a, + 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x14, 0x0a, 0x05, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x69, 0x6d, 0x61, 0x67, 0x65, 0x22, 0x2c, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x6e, 0x6b, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x12, 0x0a, 0x04, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6c, + 0x69, 0x6e, 0x6b, 0x22, 0x51, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x4d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, + 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1a, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, + 0x4c, 0x69, 0x6e, 0x6b, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x08, 0x6d, 0x65, + 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x32, 0x87, 0x01, 0x0a, 0x0b, 0x4c, 0x69, 0x6e, 0x6b, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x78, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x6e, + 0x6b, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x24, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, + 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x6e, 0x6b, + 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x25, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, - 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x4d, 0x65, 0x74, 0x61, - 0x64, 0x61, 0x74, 0x61, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x18, 0x82, 0xd3, - 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x6d, 0x65, - 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x42, 0xa8, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, - 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x42, 0x10, 0x4c, 0x69, 0x6e, - 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, - 0x30, 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, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x3b, 0x61, 0x70, 0x69, 0x76, - 0x32, 0xa2, 0x02, 0x03, 0x4d, 0x41, 0x58, 0xaa, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, - 0x41, 0x70, 0x69, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, - 0x70, 0x69, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x18, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, - 0x69, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, - 0xea, 0x02, 0x0e, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, - 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x12, 0x12, 0x10, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x32, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, + 0x42, 0xa8, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x6d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x32, 0x42, 0x10, 0x4c, 0x69, 0x6e, 0x6b, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x30, 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, 0x61, + 0x70, 0x69, 0x2f, 0x76, 0x32, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x4d, 0x41, + 0x58, 0xaa, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x70, 0x69, 0x2e, 0x56, 0x32, + 0xca, 0x02, 0x0c, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, 0xe2, + 0x02, 0x18, 0x4d, 0x65, 0x6d, 0x6f, 0x73, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x32, 0x5c, 0x47, + 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e, 0x4d, 0x65, 0x6d, + 0x6f, 0x73, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -236,12 +236,12 @@ func file_api_v2_link_service_proto_rawDescGZIP() []byte { var file_api_v2_link_service_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_api_v2_link_service_proto_goTypes = []interface{}{ - (*Metadata)(nil), // 0: memos.api.v2.Metadata + (*LinkMetadata)(nil), // 0: memos.api.v2.LinkMetadata (*GetLinkMetadataRequest)(nil), // 1: memos.api.v2.GetLinkMetadataRequest (*GetLinkMetadataResponse)(nil), // 2: memos.api.v2.GetLinkMetadataResponse } var file_api_v2_link_service_proto_depIdxs = []int32{ - 0, // 0: memos.api.v2.GetLinkMetadataResponse.metadata:type_name -> memos.api.v2.Metadata + 0, // 0: memos.api.v2.GetLinkMetadataResponse.metadata:type_name -> memos.api.v2.LinkMetadata 1, // 1: memos.api.v2.LinkService.GetLinkMetadata:input_type -> memos.api.v2.GetLinkMetadataRequest 2, // 2: memos.api.v2.LinkService.GetLinkMetadata:output_type -> memos.api.v2.GetLinkMetadataResponse 2, // [2:3] is the sub-list for method output_type @@ -258,7 +258,7 @@ func file_api_v2_link_service_proto_init() { } if !protoimpl.UnsafeEnabled { file_api_v2_link_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Metadata); i { + switch v := v.(*LinkMetadata); i { case 0: return &v.state case 1: diff --git a/server/route/api/v2/apidocs.swagger.yaml b/server/route/api/v2/apidocs.swagger.yaml index 0880e423..a495910f 100644 --- a/server/route/api/v2/apidocs.swagger.yaml +++ b/server/route/api/v2/apidocs.swagger.yaml @@ -172,12 +172,16 @@ paths: type: integer format: int32 - name: pageToken - description: "A page token, received from a previous `ListMemos` call.\r\nProvide this to retrieve the subsequent page." + description: |- + A page token, received from a previous `ListMemos` call. + Provide this to retrieve the subsequent page. in: query required: false type: string - name: filter - description: "Filter is used to filter memos returned in the list.\r\nFormat: \"creator == users/{username} && visibilities == ['PUBLIC', 'PROTECTED']\"" + description: |- + Filter is used to filter memos returned in the list. + Format: "creator == users/{username} && visibilities == ['PUBLIC', 'PROTECTED']" in: query required: false type: string @@ -238,12 +242,17 @@ paths: $ref: '#/definitions/googlerpcStatus' parameters: - name: name - description: "name is the name of the user to get stats for.\r\nFormat: users/{username}" + description: |- + name is the name of the user to get stats for. + Format: users/{username} in: query required: false type: string - name: timezone - description: "timezone location\r\nFormat: uses tz identifier\r\nhttps://en.wikipedia.org/wiki/List_of_tz_database_time_zones" + description: |- + timezone location + Format: uses tz identifier + https://en.wikipedia.org/wiki/List_of_tz_database_time_zones in: query required: false type: string @@ -575,7 +584,9 @@ paths: $ref: '#/definitions/apiv2RowStatus' creator: type: string - title: "The name of the creator.\r\nFormat: users/{username}" + title: |- + The name of the creator. + Format: users/{username} creatorId: type: integer format: int32 @@ -652,7 +663,7 @@ paths: schema: $ref: '#/definitions/googlerpcStatus' parameters: - - name: url + - name: link in: query required: false type: string @@ -827,7 +838,9 @@ paths: $ref: '#/definitions/googlerpcStatus' parameters: - name: user - description: "The creator of tags.\r\nFormat: users/{username}" + description: |- + The creator of tags. + Format: users/{username} in: query required: false type: string @@ -851,7 +864,9 @@ paths: required: false type: string - name: tag.creator - description: "The creator of tags.\r\nFormat: users/{username}" + description: |- + The creator of tags. + Format: users/{username} in: query required: false type: string @@ -891,7 +906,9 @@ paths: $ref: '#/definitions/googlerpcStatus' parameters: - name: user - description: "The creator of tags.\r\nFormat: users/{username}" + description: |- + The creator of tags. + Format: users/{username} in: query required: false type: string @@ -914,7 +931,9 @@ paths: - TagService /api/v2/tags:rename: patch: - summary: "RenameTag renames a tag.\r\nAll related memos will be updated." + summary: |- + RenameTag renames a tag. + All related memos will be updated. operationId: TagService_RenameTag responses: "200": @@ -927,7 +946,9 @@ paths: $ref: '#/definitions/googlerpcStatus' parameters: - name: user - description: "The creator of tags.\r\nFormat: users/{username}" + description: |- + The creator of tags. + Format: users/{username} in: query required: false type: string @@ -1130,7 +1151,9 @@ paths: $ref: '#/definitions/googlerpcStatus' parameters: - name: name - description: "The resource name of the workspace setting.\r\nFormat: settings/{setting}" + description: |- + The resource name of the workspace setting. + Format: settings/{setting} in: path required: true type: string @@ -1152,7 +1175,9 @@ paths: $ref: '#/definitions/googlerpcStatus' parameters: - name: setting.name - description: "name is the name of the setting.\r\nFormat: settings/{setting}" + description: |- + name is the name of the setting. + Format: settings/{setting} in: path required: true type: string @@ -1185,7 +1210,9 @@ paths: $ref: '#/definitions/googlerpcStatus' parameters: - name: inbox.name - description: "The name of the inbox.\r\nFormat: inboxes/{uid}" + description: |- + The name of the inbox. + Format: inboxes/{uid} in: path required: true type: string @@ -1229,7 +1256,9 @@ paths: $ref: '#/definitions/googlerpcStatus' parameters: - name: name_1 - description: "The name of the inbox to delete.\r\nFormat: inboxes/{uid}" + description: |- + The name of the inbox to delete. + Format: inboxes/{uid} in: path required: true type: string @@ -1251,7 +1280,9 @@ paths: $ref: '#/definitions/googlerpcStatus' parameters: - name: name - description: "The name of the user.\r\nFormat: users/{username}" + description: |- + The name of the user. + Format: users/{username} in: path required: true type: string @@ -1272,7 +1303,9 @@ paths: $ref: '#/definitions/googlerpcStatus' parameters: - name: name - description: "The name of the user.\r\nFormat: users/{username}" + description: |- + The name of the user. + Format: users/{username} in: path required: true type: string @@ -1294,7 +1327,9 @@ paths: $ref: '#/definitions/googlerpcStatus' parameters: - name: name - description: "The name of the user.\r\nFormat: users/{username}" + description: |- + The name of the user. + Format: users/{username} in: path required: true type: string @@ -1315,7 +1350,9 @@ paths: $ref: '#/definitions/googlerpcStatus' parameters: - name: name - description: "The name of the user.\r\nFormat: users/{username}" + description: |- + The name of the user. + Format: users/{username} in: path required: true type: string @@ -1342,7 +1379,9 @@ paths: $ref: '#/definitions/googlerpcStatus' parameters: - name: name - description: "The name of the user.\r\nFormat: users/{username}" + description: |- + The name of the user. + Format: users/{username} in: path required: true type: string @@ -1369,7 +1408,9 @@ paths: $ref: '#/definitions/googlerpcStatus' parameters: - name: name - description: "The name of the user.\r\nFormat: users/{username}" + description: |- + The name of the user. + Format: users/{username} in: path required: true type: string @@ -1391,7 +1432,9 @@ paths: $ref: '#/definitions/googlerpcStatus' parameters: - name: setting.name - description: "The name of the user.\r\nFormat: users/{username}" + description: |- + The name of the user. + Format: users/{username} in: path required: true type: string @@ -1431,7 +1474,9 @@ paths: $ref: '#/definitions/googlerpcStatus' parameters: - name: user.name - description: "The name of the user.\r\nFormat: users/{username}" + description: |- + The name of the user. + Format: users/{username} in: path required: true type: string @@ -1583,7 +1628,9 @@ definitions: properties: name: type: string - title: "The name of the user.\r\nFormat: users/{username}" + title: |- + The name of the user. + Format: users/{username} locale: type: string description: The preferred locale of the user. @@ -1640,7 +1687,9 @@ definitions: properties: name: type: string - title: "name is the name of the setting.\r\nFormat: settings/{setting}" + title: |- + name is the name of the setting. + Format: settings/{setting} generalSetting: $ref: '#/definitions/apiv2WorkspaceGeneralSetting' description: general_setting is the general setting of workspace. @@ -1763,7 +1812,7 @@ definitions: type: object properties: metadata: - $ref: '#/definitions/v2Metadata' + $ref: '#/definitions/v2LinkMetadata' v2GetMemoByNameResponse: type: object properties: @@ -1799,7 +1848,9 @@ definitions: additionalProperties: type: integer format: int32 - description: "stats is the stats of memo creating/updating activities.\r\nkey is the year-month-day string. e.g. \"2020-01-01\"." + description: |- + stats is the stats of memo creating/updating activities. + key is the year-month-day string. e.g. "2020-01-01". v2GetUserResponse: type: object properties: @@ -1830,7 +1881,9 @@ definitions: properties: name: type: string - title: "The name of the inbox.\r\nFormat: inboxes/{uid}" + title: |- + The name of the inbox. + Format: inboxes/{uid} sender: type: string title: 'Format: users/{username}' @@ -1861,6 +1914,15 @@ definitions: - TYPE_MEMO_COMMENT - TYPE_VERSION_UPDATE default: TYPE_UNSPECIFIED + v2LinkMetadata: + type: object + properties: + title: + type: string + description: + type: string + image: + type: string v2ListInboxesResponse: type: object properties: @@ -1911,7 +1973,9 @@ definitions: $ref: '#/definitions/v2Memo' nextPageToken: type: string - description: "A token, which can be sent as `page_token` to retrieve the next page.\r\nIf this field is omitted, there are no subsequent pages." + description: |- + A token, which can be sent as `page_token` to retrieve the next page. + If this field is omitted, there are no subsequent pages. v2ListResourcesResponse: type: object properties: @@ -1966,7 +2030,9 @@ definitions: $ref: '#/definitions/apiv2RowStatus' creator: type: string - title: "The name of the creator.\r\nFormat: users/{username}" + title: |- + The name of the creator. + Format: users/{username} creatorId: type: integer format: int32 @@ -2025,16 +2091,6 @@ definitions: - REFERENCE - COMMENT default: TYPE_UNSPECIFIED - v2Metadata: - type: object - properties: - title: - type: string - description: - type: string - image: - type: string - title: Metadata message v2RenameTagResponse: type: object properties: @@ -2098,7 +2154,9 @@ definitions: type: string creator: type: string - title: "The creator of tags.\r\nFormat: users/{username}" + title: |- + The creator of tags. + Format: users/{username} v2UpdateInboxResponse: type: object properties: @@ -2149,7 +2207,9 @@ definitions: properties: name: type: string - title: "The name of the user.\r\nFormat: users/{username}" + title: |- + The name of the user. + Format: users/{username} id: type: integer format: int32 diff --git a/server/route/api/v2/link_service.go b/server/route/api/v2/link_service.go index ade87872..5d894839 100644 --- a/server/route/api/v2/link_service.go +++ b/server/route/api/v2/link_service.go @@ -7,16 +7,14 @@ import ( apiv2pb "github.com/usememos/memos/proto/gen/api/v2" ) -func (*APIV2Service) GetMetadata(_ context.Context, request *apiv2pb.GetLinkMetadataRequest) (*apiv2pb.GetLinkMetadataResponse, error) { - urlStr := request.Url - - htmlMeta, err := getter.GetHTMLMeta(urlStr) +func (*APIV2Service) GetLinkMetadata(_ context.Context, request *apiv2pb.GetLinkMetadataRequest) (*apiv2pb.GetLinkMetadataResponse, error) { + htmlMeta, err := getter.GetHTMLMeta(request.Link) if err != nil { return nil, err } return &apiv2pb.GetLinkMetadataResponse{ - Metadata: &apiv2pb.Metadata{ + Metadata: &apiv2pb.LinkMetadata{ Title: htmlMeta.Title, Description: htmlMeta.Description, Image: htmlMeta.Image,