Commit 5d740c38 authored by Steven's avatar Steven

chore: update link service

parent 0abe20df
...@@ -12,17 +12,16 @@ service LinkService { ...@@ -12,17 +12,16 @@ service LinkService {
} }
} }
// Metadata message message LinkMetadata {
message Metadata {
string title = 1; string title = 1;
string description = 2; string description = 2;
string image = 3; string image = 3;
} }
message GetLinkMetadataRequest { message GetLinkMetadataRequest {
string url = 1; string link = 1;
} }
message GetLinkMetadataResponse { message GetLinkMetadataResponse {
Metadata metadata = 1; LinkMetadata metadata = 1;
} }
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
- [api/v2/link_service.proto](#api_v2_link_service-proto) - [api/v2/link_service.proto](#api_v2_link_service-proto)
- [GetLinkMetadataRequest](#memos-api-v2-GetLinkMetadataRequest) - [GetLinkMetadataRequest](#memos-api-v2-GetLinkMetadataRequest)
- [GetLinkMetadataResponse](#memos-api-v2-GetLinkMetadataResponse) - [GetLinkMetadataResponse](#memos-api-v2-GetLinkMetadataResponse)
- [Metadata](#memos-api-v2-Metadata) - [LinkMetadata](#memos-api-v2-LinkMetadata)
- [LinkService](#memos-api-v2-LinkService) - [LinkService](#memos-api-v2-LinkService)
...@@ -1119,7 +1119,7 @@ Used internally for obfuscating the page token. ...@@ -1119,7 +1119,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| url | [string](#string) | | | | link | [string](#string) | | |
...@@ -1134,17 +1134,17 @@ Used internally for obfuscating the page token. ...@@ -1134,17 +1134,17 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description | | Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- | | ----- | ---- | ----- | ----------- |
| metadata | [Metadata](#memos-api-v2-Metadata) | | | | metadata | [LinkMetadata](#memos-api-v2-LinkMetadata) | | |
<a name="memos-api-v2-LinkMetadata"></a>
<a name="memos-api-v2-Metadata"></a> ### LinkMetadata
### Metadata
Metadata message
| Field | Type | Label | Description | | Field | Type | Label | Description |
......
This diff is collapsed.
This diff is collapsed.
...@@ -7,16 +7,14 @@ import ( ...@@ -7,16 +7,14 @@ import (
apiv2pb "github.com/usememos/memos/proto/gen/api/v2" apiv2pb "github.com/usememos/memos/proto/gen/api/v2"
) )
func (*APIV2Service) GetMetadata(_ context.Context, request *apiv2pb.GetLinkMetadataRequest) (*apiv2pb.GetLinkMetadataResponse, error) { func (*APIV2Service) GetLinkMetadata(_ context.Context, request *apiv2pb.GetLinkMetadataRequest) (*apiv2pb.GetLinkMetadataResponse, error) {
urlStr := request.Url htmlMeta, err := getter.GetHTMLMeta(request.Link)
htmlMeta, err := getter.GetHTMLMeta(urlStr)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &apiv2pb.GetLinkMetadataResponse{ return &apiv2pb.GetLinkMetadataResponse{
Metadata: &apiv2pb.Metadata{ Metadata: &apiv2pb.LinkMetadata{
Title: htmlMeta.Title, Title: htmlMeta.Title,
Description: htmlMeta.Description, Description: htmlMeta.Description,
Image: htmlMeta.Image, Image: htmlMeta.Image,
......
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