mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-20 22:07:15 +00:00
chore: tweak shortcut service response
This commit is contained in:
parent
da94907913
commit
c356bc03e5
@ -26,12 +26,9 @@ const useShortcutStore = create(
|
|||||||
return shortcuts;
|
return shortcuts;
|
||||||
},
|
},
|
||||||
fetchShortcutByName: async (name: string) => {
|
fetchShortcutByName: async (name: string) => {
|
||||||
const { shortcut } = await shortcutServiceClient.getShortcutByName({
|
const shortcut = await shortcutServiceClient.getShortcutByName({
|
||||||
name,
|
name,
|
||||||
});
|
});
|
||||||
if (!shortcut) {
|
|
||||||
throw new Error(`Shortcut with name ${name} not found`);
|
|
||||||
}
|
|
||||||
return shortcut;
|
return shortcut;
|
||||||
},
|
},
|
||||||
getOrFetchShortcutById: async (id: number) => {
|
getOrFetchShortcutById: async (id: number) => {
|
||||||
@ -40,13 +37,9 @@ const useShortcutStore = create(
|
|||||||
return shortcutMap[id] as Shortcut;
|
return shortcutMap[id] as Shortcut;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { shortcut } = await shortcutServiceClient.getShortcut({
|
const shortcut = await shortcutServiceClient.getShortcut({
|
||||||
id,
|
id,
|
||||||
});
|
});
|
||||||
if (!shortcut) {
|
|
||||||
throw new Error(`Shortcut with id ${id} not found`);
|
|
||||||
}
|
|
||||||
|
|
||||||
shortcutMap[id] = shortcut;
|
shortcutMap[id] = shortcut;
|
||||||
set({ shortcutMapById: shortcutMap });
|
set({ shortcutMapById: shortcutMap });
|
||||||
return shortcut;
|
return shortcut;
|
||||||
@ -59,25 +52,19 @@ const useShortcutStore = create(
|
|||||||
return Object.values(get().shortcutMapById);
|
return Object.values(get().shortcutMapById);
|
||||||
},
|
},
|
||||||
createShortcut: async (shortcut: Shortcut) => {
|
createShortcut: async (shortcut: Shortcut) => {
|
||||||
const { shortcut: createdShortcut } = await shortcutServiceClient.createShortcut({
|
const createdShortcut = await shortcutServiceClient.createShortcut({
|
||||||
shortcut: shortcut,
|
shortcut: shortcut,
|
||||||
});
|
});
|
||||||
if (!createdShortcut) {
|
|
||||||
throw new Error(`Failed to create shortcut`);
|
|
||||||
}
|
|
||||||
const shortcutMap = get().shortcutMapById;
|
const shortcutMap = get().shortcutMapById;
|
||||||
shortcutMap[createdShortcut.id] = createdShortcut;
|
shortcutMap[createdShortcut.id] = createdShortcut;
|
||||||
set({ shortcutMapById: shortcutMap });
|
set({ shortcutMapById: shortcutMap });
|
||||||
return createdShortcut;
|
return createdShortcut;
|
||||||
},
|
},
|
||||||
updateShortcut: async (shortcut: Partial<Shortcut>, updateMask: string[]) => {
|
updateShortcut: async (shortcut: Partial<Shortcut>, updateMask: string[]) => {
|
||||||
const { shortcut: updatedShortcut } = await shortcutServiceClient.updateShortcut({
|
const updatedShortcut = await shortcutServiceClient.updateShortcut({
|
||||||
shortcut: shortcut,
|
shortcut: shortcut,
|
||||||
updateMask,
|
updateMask,
|
||||||
});
|
});
|
||||||
if (!updatedShortcut) {
|
|
||||||
throw new Error(`Failed to update shortcut`);
|
|
||||||
}
|
|
||||||
const shortcutMap = get().shortcutMapById;
|
const shortcutMap = get().shortcutMapById;
|
||||||
shortcutMap[updatedShortcut.id] = updatedShortcut;
|
shortcutMap[updatedShortcut.id] = updatedShortcut;
|
||||||
set({ shortcutMapById: shortcutMap });
|
set({ shortcutMapById: shortcutMap });
|
||||||
|
@ -5,6 +5,7 @@ package slash.api.v1;
|
|||||||
import "api/v1/common.proto";
|
import "api/v1/common.proto";
|
||||||
import "google/api/annotations.proto";
|
import "google/api/annotations.proto";
|
||||||
import "google/api/client.proto";
|
import "google/api/client.proto";
|
||||||
|
import "google/protobuf/empty.proto";
|
||||||
import "google/protobuf/field_mask.proto";
|
import "google/protobuf/field_mask.proto";
|
||||||
import "google/protobuf/timestamp.proto";
|
import "google/protobuf/timestamp.proto";
|
||||||
|
|
||||||
@ -16,21 +17,21 @@ service ShortcutService {
|
|||||||
option (google.api.http) = {get: "/api/v1/shortcuts"};
|
option (google.api.http) = {get: "/api/v1/shortcuts"};
|
||||||
}
|
}
|
||||||
// GetShortcut returns a shortcut by id.
|
// GetShortcut returns a shortcut by id.
|
||||||
rpc GetShortcut(GetShortcutRequest) returns (GetShortcutResponse) {
|
rpc GetShortcut(GetShortcutRequest) returns (Shortcut) {
|
||||||
option (google.api.http) = {get: "/api/v1/shortcuts/{id}"};
|
option (google.api.http) = {get: "/api/v1/shortcuts/{id}"};
|
||||||
option (google.api.method_signature) = "id";
|
option (google.api.method_signature) = "id";
|
||||||
}
|
}
|
||||||
// GetShortcutByName returns a shortcut by name.
|
// GetShortcutByName returns a shortcut by name.
|
||||||
rpc GetShortcutByName(GetShortcutByNameRequest) returns (GetShortcutByNameResponse) {}
|
rpc GetShortcutByName(GetShortcutByNameRequest) returns (Shortcut) {}
|
||||||
// CreateShortcut creates a shortcut.
|
// CreateShortcut creates a shortcut.
|
||||||
rpc CreateShortcut(CreateShortcutRequest) returns (CreateShortcutResponse) {
|
rpc CreateShortcut(CreateShortcutRequest) returns (Shortcut) {
|
||||||
option (google.api.http) = {
|
option (google.api.http) = {
|
||||||
post: "/api/v1/shortcuts"
|
post: "/api/v1/shortcuts"
|
||||||
body: "shortcut"
|
body: "shortcut"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// UpdateShortcut updates a shortcut.
|
// UpdateShortcut updates a shortcut.
|
||||||
rpc UpdateShortcut(UpdateShortcutRequest) returns (UpdateShortcutResponse) {
|
rpc UpdateShortcut(UpdateShortcutRequest) returns (Shortcut) {
|
||||||
option (google.api.http) = {
|
option (google.api.http) = {
|
||||||
put: "/api/v1/shortcuts/{shortcut.id}"
|
put: "/api/v1/shortcuts/{shortcut.id}"
|
||||||
body: "shortcut"
|
body: "shortcut"
|
||||||
@ -38,7 +39,7 @@ service ShortcutService {
|
|||||||
option (google.api.method_signature) = "shortcut,update_mask";
|
option (google.api.method_signature) = "shortcut,update_mask";
|
||||||
}
|
}
|
||||||
// DeleteShortcut deletes a shortcut by name.
|
// DeleteShortcut deletes a shortcut by name.
|
||||||
rpc DeleteShortcut(DeleteShortcutRequest) returns (DeleteShortcutResponse) {
|
rpc DeleteShortcut(DeleteShortcutRequest) returns (google.protobuf.Empty) {
|
||||||
option (google.api.http) = {delete: "/api/v1/shortcuts/{id}"};
|
option (google.api.http) = {delete: "/api/v1/shortcuts/{id}"};
|
||||||
option (google.api.method_signature) = "id";
|
option (google.api.method_signature) = "id";
|
||||||
}
|
}
|
||||||
@ -75,16 +76,17 @@ message Shortcut {
|
|||||||
int32 view_count = 12;
|
int32 view_count = 12;
|
||||||
|
|
||||||
OpenGraphMetadata og_metadata = 13;
|
OpenGraphMetadata og_metadata = 13;
|
||||||
}
|
|
||||||
|
|
||||||
message OpenGraphMetadata {
|
message OpenGraphMetadata {
|
||||||
string title = 1;
|
string title = 1;
|
||||||
|
|
||||||
string description = 2;
|
string description = 2;
|
||||||
|
|
||||||
string image = 3;
|
string image = 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
message ListShortcutsRequest {}
|
message ListShortcutsRequest {}
|
||||||
|
|
||||||
message ListShortcutsResponse {
|
message ListShortcutsResponse {
|
||||||
@ -95,42 +97,24 @@ message GetShortcutRequest {
|
|||||||
int32 id = 1;
|
int32 id = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetShortcutResponse {
|
|
||||||
Shortcut shortcut = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message GetShortcutByNameRequest {
|
message GetShortcutByNameRequest {
|
||||||
string name = 1;
|
string name = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message GetShortcutByNameResponse {
|
|
||||||
Shortcut shortcut = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message CreateShortcutRequest {
|
message CreateShortcutRequest {
|
||||||
Shortcut shortcut = 1;
|
Shortcut shortcut = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message CreateShortcutResponse {
|
|
||||||
Shortcut shortcut = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message UpdateShortcutRequest {
|
message UpdateShortcutRequest {
|
||||||
Shortcut shortcut = 1;
|
Shortcut shortcut = 1;
|
||||||
|
|
||||||
google.protobuf.FieldMask update_mask = 2;
|
google.protobuf.FieldMask update_mask = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
message UpdateShortcutResponse {
|
|
||||||
Shortcut shortcut = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message DeleteShortcutRequest {
|
message DeleteShortcutRequest {
|
||||||
int32 id = 1;
|
int32 id = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message DeleteShortcutResponse {}
|
|
||||||
|
|
||||||
message GetShortcutAnalyticsRequest {
|
message GetShortcutAnalyticsRequest {
|
||||||
int32 id = 1;
|
int32 id = 1;
|
||||||
}
|
}
|
||||||
|
@ -59,22 +59,17 @@
|
|||||||
|
|
||||||
- [api/v1/shortcut_service.proto](#api_v1_shortcut_service-proto)
|
- [api/v1/shortcut_service.proto](#api_v1_shortcut_service-proto)
|
||||||
- [CreateShortcutRequest](#slash-api-v1-CreateShortcutRequest)
|
- [CreateShortcutRequest](#slash-api-v1-CreateShortcutRequest)
|
||||||
- [CreateShortcutResponse](#slash-api-v1-CreateShortcutResponse)
|
|
||||||
- [DeleteShortcutRequest](#slash-api-v1-DeleteShortcutRequest)
|
- [DeleteShortcutRequest](#slash-api-v1-DeleteShortcutRequest)
|
||||||
- [DeleteShortcutResponse](#slash-api-v1-DeleteShortcutResponse)
|
|
||||||
- [GetShortcutAnalyticsRequest](#slash-api-v1-GetShortcutAnalyticsRequest)
|
- [GetShortcutAnalyticsRequest](#slash-api-v1-GetShortcutAnalyticsRequest)
|
||||||
- [GetShortcutAnalyticsResponse](#slash-api-v1-GetShortcutAnalyticsResponse)
|
- [GetShortcutAnalyticsResponse](#slash-api-v1-GetShortcutAnalyticsResponse)
|
||||||
- [GetShortcutAnalyticsResponse.AnalyticsItem](#slash-api-v1-GetShortcutAnalyticsResponse-AnalyticsItem)
|
- [GetShortcutAnalyticsResponse.AnalyticsItem](#slash-api-v1-GetShortcutAnalyticsResponse-AnalyticsItem)
|
||||||
- [GetShortcutByNameRequest](#slash-api-v1-GetShortcutByNameRequest)
|
- [GetShortcutByNameRequest](#slash-api-v1-GetShortcutByNameRequest)
|
||||||
- [GetShortcutByNameResponse](#slash-api-v1-GetShortcutByNameResponse)
|
|
||||||
- [GetShortcutRequest](#slash-api-v1-GetShortcutRequest)
|
- [GetShortcutRequest](#slash-api-v1-GetShortcutRequest)
|
||||||
- [GetShortcutResponse](#slash-api-v1-GetShortcutResponse)
|
|
||||||
- [ListShortcutsRequest](#slash-api-v1-ListShortcutsRequest)
|
- [ListShortcutsRequest](#slash-api-v1-ListShortcutsRequest)
|
||||||
- [ListShortcutsResponse](#slash-api-v1-ListShortcutsResponse)
|
- [ListShortcutsResponse](#slash-api-v1-ListShortcutsResponse)
|
||||||
- [OpenGraphMetadata](#slash-api-v1-OpenGraphMetadata)
|
|
||||||
- [Shortcut](#slash-api-v1-Shortcut)
|
- [Shortcut](#slash-api-v1-Shortcut)
|
||||||
|
- [Shortcut.OpenGraphMetadata](#slash-api-v1-Shortcut-OpenGraphMetadata)
|
||||||
- [UpdateShortcutRequest](#slash-api-v1-UpdateShortcutRequest)
|
- [UpdateShortcutRequest](#slash-api-v1-UpdateShortcutRequest)
|
||||||
- [UpdateShortcutResponse](#slash-api-v1-UpdateShortcutResponse)
|
|
||||||
|
|
||||||
- [ShortcutService](#slash-api-v1-ShortcutService)
|
- [ShortcutService](#slash-api-v1-ShortcutService)
|
||||||
|
|
||||||
@ -824,21 +819,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="slash-api-v1-CreateShortcutResponse"></a>
|
|
||||||
|
|
||||||
### CreateShortcutResponse
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
| Field | Type | Label | Description |
|
|
||||||
| ----- | ---- | ----- | ----------- |
|
|
||||||
| shortcut | [Shortcut](#slash-api-v1-Shortcut) | | |
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="slash-api-v1-DeleteShortcutRequest"></a>
|
<a name="slash-api-v1-DeleteShortcutRequest"></a>
|
||||||
|
|
||||||
### DeleteShortcutRequest
|
### DeleteShortcutRequest
|
||||||
@ -854,16 +834,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="slash-api-v1-DeleteShortcutResponse"></a>
|
|
||||||
|
|
||||||
### DeleteShortcutResponse
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="slash-api-v1-GetShortcutAnalyticsRequest"></a>
|
<a name="slash-api-v1-GetShortcutAnalyticsRequest"></a>
|
||||||
|
|
||||||
### GetShortcutAnalyticsRequest
|
### GetShortcutAnalyticsRequest
|
||||||
@ -927,21 +897,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="slash-api-v1-GetShortcutByNameResponse"></a>
|
|
||||||
|
|
||||||
### GetShortcutByNameResponse
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
| Field | Type | Label | Description |
|
|
||||||
| ----- | ---- | ----- | ----------- |
|
|
||||||
| shortcut | [Shortcut](#slash-api-v1-Shortcut) | | |
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="slash-api-v1-GetShortcutRequest"></a>
|
<a name="slash-api-v1-GetShortcutRequest"></a>
|
||||||
|
|
||||||
### GetShortcutRequest
|
### GetShortcutRequest
|
||||||
@ -957,21 +912,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="slash-api-v1-GetShortcutResponse"></a>
|
|
||||||
|
|
||||||
### GetShortcutResponse
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
| Field | Type | Label | Description |
|
|
||||||
| ----- | ---- | ----- | ----------- |
|
|
||||||
| shortcut | [Shortcut](#slash-api-v1-Shortcut) | | |
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="slash-api-v1-ListShortcutsRequest"></a>
|
<a name="slash-api-v1-ListShortcutsRequest"></a>
|
||||||
|
|
||||||
### ListShortcutsRequest
|
### ListShortcutsRequest
|
||||||
@ -997,23 +937,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="slash-api-v1-OpenGraphMetadata"></a>
|
|
||||||
|
|
||||||
### OpenGraphMetadata
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
| Field | Type | Label | Description |
|
|
||||||
| ----- | ---- | ----- | ----------- |
|
|
||||||
| title | [string](#string) | | |
|
|
||||||
| description | [string](#string) | | |
|
|
||||||
| image | [string](#string) | | |
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="slash-api-v1-Shortcut"></a>
|
<a name="slash-api-v1-Shortcut"></a>
|
||||||
|
|
||||||
### Shortcut
|
### Shortcut
|
||||||
@ -1034,7 +957,24 @@
|
|||||||
| description | [string](#string) | | |
|
| description | [string](#string) | | |
|
||||||
| visibility | [Visibility](#slash-api-v1-Visibility) | | |
|
| visibility | [Visibility](#slash-api-v1-Visibility) | | |
|
||||||
| view_count | [int32](#int32) | | |
|
| view_count | [int32](#int32) | | |
|
||||||
| og_metadata | [OpenGraphMetadata](#slash-api-v1-OpenGraphMetadata) | | |
|
| og_metadata | [Shortcut.OpenGraphMetadata](#slash-api-v1-Shortcut-OpenGraphMetadata) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<a name="slash-api-v1-Shortcut-OpenGraphMetadata"></a>
|
||||||
|
|
||||||
|
### Shortcut.OpenGraphMetadata
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
| Field | Type | Label | Description |
|
||||||
|
| ----- | ---- | ----- | ----------- |
|
||||||
|
| title | [string](#string) | | |
|
||||||
|
| description | [string](#string) | | |
|
||||||
|
| image | [string](#string) | | |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1057,21 +997,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<a name="slash-api-v1-UpdateShortcutResponse"></a>
|
|
||||||
|
|
||||||
### UpdateShortcutResponse
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
| Field | Type | Label | Description |
|
|
||||||
| ----- | ---- | ----- | ----------- |
|
|
||||||
| shortcut | [Shortcut](#slash-api-v1-Shortcut) | | |
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -1086,11 +1011,11 @@
|
|||||||
| Method Name | Request Type | Response Type | Description |
|
| Method Name | Request Type | Response Type | Description |
|
||||||
| ----------- | ------------ | ------------- | ------------|
|
| ----------- | ------------ | ------------- | ------------|
|
||||||
| ListShortcuts | [ListShortcutsRequest](#slash-api-v1-ListShortcutsRequest) | [ListShortcutsResponse](#slash-api-v1-ListShortcutsResponse) | ListShortcuts returns a list of shortcuts. |
|
| ListShortcuts | [ListShortcutsRequest](#slash-api-v1-ListShortcutsRequest) | [ListShortcutsResponse](#slash-api-v1-ListShortcutsResponse) | ListShortcuts returns a list of shortcuts. |
|
||||||
| GetShortcut | [GetShortcutRequest](#slash-api-v1-GetShortcutRequest) | [GetShortcutResponse](#slash-api-v1-GetShortcutResponse) | GetShortcut returns a shortcut by id. |
|
| GetShortcut | [GetShortcutRequest](#slash-api-v1-GetShortcutRequest) | [Shortcut](#slash-api-v1-Shortcut) | GetShortcut returns a shortcut by id. |
|
||||||
| GetShortcutByName | [GetShortcutByNameRequest](#slash-api-v1-GetShortcutByNameRequest) | [GetShortcutByNameResponse](#slash-api-v1-GetShortcutByNameResponse) | GetShortcutByName returns a shortcut by name. |
|
| GetShortcutByName | [GetShortcutByNameRequest](#slash-api-v1-GetShortcutByNameRequest) | [Shortcut](#slash-api-v1-Shortcut) | GetShortcutByName returns a shortcut by name. |
|
||||||
| CreateShortcut | [CreateShortcutRequest](#slash-api-v1-CreateShortcutRequest) | [CreateShortcutResponse](#slash-api-v1-CreateShortcutResponse) | CreateShortcut creates a shortcut. |
|
| CreateShortcut | [CreateShortcutRequest](#slash-api-v1-CreateShortcutRequest) | [Shortcut](#slash-api-v1-Shortcut) | CreateShortcut creates a shortcut. |
|
||||||
| UpdateShortcut | [UpdateShortcutRequest](#slash-api-v1-UpdateShortcutRequest) | [UpdateShortcutResponse](#slash-api-v1-UpdateShortcutResponse) | UpdateShortcut updates a shortcut. |
|
| UpdateShortcut | [UpdateShortcutRequest](#slash-api-v1-UpdateShortcutRequest) | [Shortcut](#slash-api-v1-Shortcut) | UpdateShortcut updates a shortcut. |
|
||||||
| DeleteShortcut | [DeleteShortcutRequest](#slash-api-v1-DeleteShortcutRequest) | [DeleteShortcutResponse](#slash-api-v1-DeleteShortcutResponse) | DeleteShortcut deletes a shortcut by name. |
|
| DeleteShortcut | [DeleteShortcutRequest](#slash-api-v1-DeleteShortcutRequest) | [.google.protobuf.Empty](#google-protobuf-Empty) | DeleteShortcut deletes a shortcut by name. |
|
||||||
| GetShortcutAnalytics | [GetShortcutAnalyticsRequest](#slash-api-v1-GetShortcutAnalyticsRequest) | [GetShortcutAnalyticsResponse](#slash-api-v1-GetShortcutAnalyticsResponse) | GetShortcutAnalytics returns the analytics for a shortcut. |
|
| GetShortcutAnalytics | [GetShortcutAnalyticsRequest](#slash-api-v1-GetShortcutAnalyticsRequest) | [GetShortcutAnalyticsResponse](#slash-api-v1-GetShortcutAnalyticsResponse) | GetShortcutAnalytics returns the analytics for a shortcut. |
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,7 @@ import (
|
|||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
codes "google.golang.org/grpc/codes"
|
codes "google.golang.org/grpc/codes"
|
||||||
status "google.golang.org/grpc/status"
|
status "google.golang.org/grpc/status"
|
||||||
|
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
// This is a compile-time assertion to ensure that this generated file
|
||||||
@ -35,15 +36,15 @@ type ShortcutServiceClient interface {
|
|||||||
// ListShortcuts returns a list of shortcuts.
|
// ListShortcuts returns a list of shortcuts.
|
||||||
ListShortcuts(ctx context.Context, in *ListShortcutsRequest, opts ...grpc.CallOption) (*ListShortcutsResponse, error)
|
ListShortcuts(ctx context.Context, in *ListShortcutsRequest, opts ...grpc.CallOption) (*ListShortcutsResponse, error)
|
||||||
// GetShortcut returns a shortcut by id.
|
// GetShortcut returns a shortcut by id.
|
||||||
GetShortcut(ctx context.Context, in *GetShortcutRequest, opts ...grpc.CallOption) (*GetShortcutResponse, error)
|
GetShortcut(ctx context.Context, in *GetShortcutRequest, opts ...grpc.CallOption) (*Shortcut, error)
|
||||||
// GetShortcutByName returns a shortcut by name.
|
// GetShortcutByName returns a shortcut by name.
|
||||||
GetShortcutByName(ctx context.Context, in *GetShortcutByNameRequest, opts ...grpc.CallOption) (*GetShortcutByNameResponse, error)
|
GetShortcutByName(ctx context.Context, in *GetShortcutByNameRequest, opts ...grpc.CallOption) (*Shortcut, error)
|
||||||
// CreateShortcut creates a shortcut.
|
// CreateShortcut creates a shortcut.
|
||||||
CreateShortcut(ctx context.Context, in *CreateShortcutRequest, opts ...grpc.CallOption) (*CreateShortcutResponse, error)
|
CreateShortcut(ctx context.Context, in *CreateShortcutRequest, opts ...grpc.CallOption) (*Shortcut, error)
|
||||||
// UpdateShortcut updates a shortcut.
|
// UpdateShortcut updates a shortcut.
|
||||||
UpdateShortcut(ctx context.Context, in *UpdateShortcutRequest, opts ...grpc.CallOption) (*UpdateShortcutResponse, error)
|
UpdateShortcut(ctx context.Context, in *UpdateShortcutRequest, opts ...grpc.CallOption) (*Shortcut, error)
|
||||||
// DeleteShortcut deletes a shortcut by name.
|
// DeleteShortcut deletes a shortcut by name.
|
||||||
DeleteShortcut(ctx context.Context, in *DeleteShortcutRequest, opts ...grpc.CallOption) (*DeleteShortcutResponse, error)
|
DeleteShortcut(ctx context.Context, in *DeleteShortcutRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||||
// GetShortcutAnalytics returns the analytics for a shortcut.
|
// GetShortcutAnalytics returns the analytics for a shortcut.
|
||||||
GetShortcutAnalytics(ctx context.Context, in *GetShortcutAnalyticsRequest, opts ...grpc.CallOption) (*GetShortcutAnalyticsResponse, error)
|
GetShortcutAnalytics(ctx context.Context, in *GetShortcutAnalyticsRequest, opts ...grpc.CallOption) (*GetShortcutAnalyticsResponse, error)
|
||||||
}
|
}
|
||||||
@ -66,9 +67,9 @@ func (c *shortcutServiceClient) ListShortcuts(ctx context.Context, in *ListShort
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *shortcutServiceClient) GetShortcut(ctx context.Context, in *GetShortcutRequest, opts ...grpc.CallOption) (*GetShortcutResponse, error) {
|
func (c *shortcutServiceClient) GetShortcut(ctx context.Context, in *GetShortcutRequest, opts ...grpc.CallOption) (*Shortcut, error) {
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
out := new(GetShortcutResponse)
|
out := new(Shortcut)
|
||||||
err := c.cc.Invoke(ctx, ShortcutService_GetShortcut_FullMethodName, in, out, cOpts...)
|
err := c.cc.Invoke(ctx, ShortcutService_GetShortcut_FullMethodName, in, out, cOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -76,9 +77,9 @@ func (c *shortcutServiceClient) GetShortcut(ctx context.Context, in *GetShortcut
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *shortcutServiceClient) GetShortcutByName(ctx context.Context, in *GetShortcutByNameRequest, opts ...grpc.CallOption) (*GetShortcutByNameResponse, error) {
|
func (c *shortcutServiceClient) GetShortcutByName(ctx context.Context, in *GetShortcutByNameRequest, opts ...grpc.CallOption) (*Shortcut, error) {
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
out := new(GetShortcutByNameResponse)
|
out := new(Shortcut)
|
||||||
err := c.cc.Invoke(ctx, ShortcutService_GetShortcutByName_FullMethodName, in, out, cOpts...)
|
err := c.cc.Invoke(ctx, ShortcutService_GetShortcutByName_FullMethodName, in, out, cOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -86,9 +87,9 @@ func (c *shortcutServiceClient) GetShortcutByName(ctx context.Context, in *GetSh
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *shortcutServiceClient) CreateShortcut(ctx context.Context, in *CreateShortcutRequest, opts ...grpc.CallOption) (*CreateShortcutResponse, error) {
|
func (c *shortcutServiceClient) CreateShortcut(ctx context.Context, in *CreateShortcutRequest, opts ...grpc.CallOption) (*Shortcut, error) {
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
out := new(CreateShortcutResponse)
|
out := new(Shortcut)
|
||||||
err := c.cc.Invoke(ctx, ShortcutService_CreateShortcut_FullMethodName, in, out, cOpts...)
|
err := c.cc.Invoke(ctx, ShortcutService_CreateShortcut_FullMethodName, in, out, cOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -96,9 +97,9 @@ func (c *shortcutServiceClient) CreateShortcut(ctx context.Context, in *CreateSh
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *shortcutServiceClient) UpdateShortcut(ctx context.Context, in *UpdateShortcutRequest, opts ...grpc.CallOption) (*UpdateShortcutResponse, error) {
|
func (c *shortcutServiceClient) UpdateShortcut(ctx context.Context, in *UpdateShortcutRequest, opts ...grpc.CallOption) (*Shortcut, error) {
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
out := new(UpdateShortcutResponse)
|
out := new(Shortcut)
|
||||||
err := c.cc.Invoke(ctx, ShortcutService_UpdateShortcut_FullMethodName, in, out, cOpts...)
|
err := c.cc.Invoke(ctx, ShortcutService_UpdateShortcut_FullMethodName, in, out, cOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -106,9 +107,9 @@ func (c *shortcutServiceClient) UpdateShortcut(ctx context.Context, in *UpdateSh
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *shortcutServiceClient) DeleteShortcut(ctx context.Context, in *DeleteShortcutRequest, opts ...grpc.CallOption) (*DeleteShortcutResponse, error) {
|
func (c *shortcutServiceClient) DeleteShortcut(ctx context.Context, in *DeleteShortcutRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
out := new(DeleteShortcutResponse)
|
out := new(emptypb.Empty)
|
||||||
err := c.cc.Invoke(ctx, ShortcutService_DeleteShortcut_FullMethodName, in, out, cOpts...)
|
err := c.cc.Invoke(ctx, ShortcutService_DeleteShortcut_FullMethodName, in, out, cOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -133,15 +134,15 @@ type ShortcutServiceServer interface {
|
|||||||
// ListShortcuts returns a list of shortcuts.
|
// ListShortcuts returns a list of shortcuts.
|
||||||
ListShortcuts(context.Context, *ListShortcutsRequest) (*ListShortcutsResponse, error)
|
ListShortcuts(context.Context, *ListShortcutsRequest) (*ListShortcutsResponse, error)
|
||||||
// GetShortcut returns a shortcut by id.
|
// GetShortcut returns a shortcut by id.
|
||||||
GetShortcut(context.Context, *GetShortcutRequest) (*GetShortcutResponse, error)
|
GetShortcut(context.Context, *GetShortcutRequest) (*Shortcut, error)
|
||||||
// GetShortcutByName returns a shortcut by name.
|
// GetShortcutByName returns a shortcut by name.
|
||||||
GetShortcutByName(context.Context, *GetShortcutByNameRequest) (*GetShortcutByNameResponse, error)
|
GetShortcutByName(context.Context, *GetShortcutByNameRequest) (*Shortcut, error)
|
||||||
// CreateShortcut creates a shortcut.
|
// CreateShortcut creates a shortcut.
|
||||||
CreateShortcut(context.Context, *CreateShortcutRequest) (*CreateShortcutResponse, error)
|
CreateShortcut(context.Context, *CreateShortcutRequest) (*Shortcut, error)
|
||||||
// UpdateShortcut updates a shortcut.
|
// UpdateShortcut updates a shortcut.
|
||||||
UpdateShortcut(context.Context, *UpdateShortcutRequest) (*UpdateShortcutResponse, error)
|
UpdateShortcut(context.Context, *UpdateShortcutRequest) (*Shortcut, error)
|
||||||
// DeleteShortcut deletes a shortcut by name.
|
// DeleteShortcut deletes a shortcut by name.
|
||||||
DeleteShortcut(context.Context, *DeleteShortcutRequest) (*DeleteShortcutResponse, error)
|
DeleteShortcut(context.Context, *DeleteShortcutRequest) (*emptypb.Empty, error)
|
||||||
// GetShortcutAnalytics returns the analytics for a shortcut.
|
// GetShortcutAnalytics returns the analytics for a shortcut.
|
||||||
GetShortcutAnalytics(context.Context, *GetShortcutAnalyticsRequest) (*GetShortcutAnalyticsResponse, error)
|
GetShortcutAnalytics(context.Context, *GetShortcutAnalyticsRequest) (*GetShortcutAnalyticsResponse, error)
|
||||||
mustEmbedUnimplementedShortcutServiceServer()
|
mustEmbedUnimplementedShortcutServiceServer()
|
||||||
@ -157,19 +158,19 @@ type UnimplementedShortcutServiceServer struct{}
|
|||||||
func (UnimplementedShortcutServiceServer) ListShortcuts(context.Context, *ListShortcutsRequest) (*ListShortcutsResponse, error) {
|
func (UnimplementedShortcutServiceServer) ListShortcuts(context.Context, *ListShortcutsRequest) (*ListShortcutsResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method ListShortcuts not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method ListShortcuts not implemented")
|
||||||
}
|
}
|
||||||
func (UnimplementedShortcutServiceServer) GetShortcut(context.Context, *GetShortcutRequest) (*GetShortcutResponse, error) {
|
func (UnimplementedShortcutServiceServer) GetShortcut(context.Context, *GetShortcutRequest) (*Shortcut, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method GetShortcut not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method GetShortcut not implemented")
|
||||||
}
|
}
|
||||||
func (UnimplementedShortcutServiceServer) GetShortcutByName(context.Context, *GetShortcutByNameRequest) (*GetShortcutByNameResponse, error) {
|
func (UnimplementedShortcutServiceServer) GetShortcutByName(context.Context, *GetShortcutByNameRequest) (*Shortcut, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method GetShortcutByName not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method GetShortcutByName not implemented")
|
||||||
}
|
}
|
||||||
func (UnimplementedShortcutServiceServer) CreateShortcut(context.Context, *CreateShortcutRequest) (*CreateShortcutResponse, error) {
|
func (UnimplementedShortcutServiceServer) CreateShortcut(context.Context, *CreateShortcutRequest) (*Shortcut, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method CreateShortcut not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method CreateShortcut not implemented")
|
||||||
}
|
}
|
||||||
func (UnimplementedShortcutServiceServer) UpdateShortcut(context.Context, *UpdateShortcutRequest) (*UpdateShortcutResponse, error) {
|
func (UnimplementedShortcutServiceServer) UpdateShortcut(context.Context, *UpdateShortcutRequest) (*Shortcut, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateShortcut not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method UpdateShortcut not implemented")
|
||||||
}
|
}
|
||||||
func (UnimplementedShortcutServiceServer) DeleteShortcut(context.Context, *DeleteShortcutRequest) (*DeleteShortcutResponse, error) {
|
func (UnimplementedShortcutServiceServer) DeleteShortcut(context.Context, *DeleteShortcutRequest) (*emptypb.Empty, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteShortcut not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method DeleteShortcut not implemented")
|
||||||
}
|
}
|
||||||
func (UnimplementedShortcutServiceServer) GetShortcutAnalytics(context.Context, *GetShortcutAnalyticsRequest) (*GetShortcutAnalyticsResponse, error) {
|
func (UnimplementedShortcutServiceServer) GetShortcutAnalytics(context.Context, *GetShortcutAnalyticsRequest) (*GetShortcutAnalyticsResponse, error) {
|
||||||
|
@ -280,7 +280,7 @@ paths:
|
|||||||
"200":
|
"200":
|
||||||
description: A successful response.
|
description: A successful response.
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/v1CreateShortcutResponse'
|
$ref: '#/definitions/apiv1Shortcut'
|
||||||
default:
|
default:
|
||||||
description: An unexpected error response.
|
description: An unexpected error response.
|
||||||
schema:
|
schema:
|
||||||
@ -301,7 +301,7 @@ paths:
|
|||||||
"200":
|
"200":
|
||||||
description: A successful response.
|
description: A successful response.
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/v1GetShortcutResponse'
|
$ref: '#/definitions/apiv1Shortcut'
|
||||||
default:
|
default:
|
||||||
description: An unexpected error response.
|
description: An unexpected error response.
|
||||||
schema:
|
schema:
|
||||||
@ -321,7 +321,8 @@ paths:
|
|||||||
"200":
|
"200":
|
||||||
description: A successful response.
|
description: A successful response.
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/v1DeleteShortcutResponse'
|
type: object
|
||||||
|
properties: {}
|
||||||
default:
|
default:
|
||||||
description: An unexpected error response.
|
description: An unexpected error response.
|
||||||
schema:
|
schema:
|
||||||
@ -363,7 +364,7 @@ paths:
|
|||||||
"200":
|
"200":
|
||||||
description: A successful response.
|
description: A successful response.
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/v1UpdateShortcutResponse'
|
$ref: '#/definitions/apiv1Shortcut'
|
||||||
default:
|
default:
|
||||||
description: An unexpected error response.
|
description: An unexpected error response.
|
||||||
schema:
|
schema:
|
||||||
@ -409,7 +410,7 @@ paths:
|
|||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
ogMetadata:
|
ogMetadata:
|
||||||
$ref: '#/definitions/apiv1OpenGraphMetadata'
|
$ref: '#/definitions/v1ShortcutOpenGraphMetadata'
|
||||||
- name: updateMask
|
- name: updateMask
|
||||||
in: query
|
in: query
|
||||||
required: false
|
required: false
|
||||||
@ -851,15 +852,6 @@ definitions:
|
|||||||
- TYPE_UNSPECIFIED
|
- TYPE_UNSPECIFIED
|
||||||
- OAUTH2
|
- OAUTH2
|
||||||
default: TYPE_UNSPECIFIED
|
default: TYPE_UNSPECIFIED
|
||||||
apiv1OpenGraphMetadata:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
title:
|
|
||||||
type: string
|
|
||||||
description:
|
|
||||||
type: string
|
|
||||||
image:
|
|
||||||
type: string
|
|
||||||
apiv1RowStatus:
|
apiv1RowStatus:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
@ -902,7 +894,7 @@ definitions:
|
|||||||
type: integer
|
type: integer
|
||||||
format: int32
|
format: int32
|
||||||
ogMetadata:
|
ogMetadata:
|
||||||
$ref: '#/definitions/apiv1OpenGraphMetadata'
|
$ref: '#/definitions/v1ShortcutOpenGraphMetadata'
|
||||||
apiv1UserSetting:
|
apiv1UserSetting:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -995,11 +987,6 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
collection:
|
collection:
|
||||||
$ref: '#/definitions/apiv1Collection'
|
$ref: '#/definitions/apiv1Collection'
|
||||||
v1CreateShortcutResponse:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
shortcut:
|
|
||||||
$ref: '#/definitions/apiv1Shortcut'
|
|
||||||
v1CreateUserAccessTokenResponse:
|
v1CreateUserAccessTokenResponse:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -1012,8 +999,6 @@ definitions:
|
|||||||
$ref: '#/definitions/v1User'
|
$ref: '#/definitions/v1User'
|
||||||
v1DeleteCollectionResponse:
|
v1DeleteCollectionResponse:
|
||||||
type: object
|
type: object
|
||||||
v1DeleteShortcutResponse:
|
|
||||||
type: object
|
|
||||||
v1DeleteUserAccessTokenResponse:
|
v1DeleteUserAccessTokenResponse:
|
||||||
type: object
|
type: object
|
||||||
v1DeleteUserResponse:
|
v1DeleteUserResponse:
|
||||||
@ -1046,16 +1031,6 @@ definitions:
|
|||||||
items:
|
items:
|
||||||
type: object
|
type: object
|
||||||
$ref: '#/definitions/GetShortcutAnalyticsResponseAnalyticsItem'
|
$ref: '#/definitions/GetShortcutAnalyticsResponseAnalyticsItem'
|
||||||
v1GetShortcutByNameResponse:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
shortcut:
|
|
||||||
$ref: '#/definitions/apiv1Shortcut'
|
|
||||||
v1GetShortcutResponse:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
shortcut:
|
|
||||||
$ref: '#/definitions/apiv1Shortcut'
|
|
||||||
v1GetUserResponse:
|
v1GetUserResponse:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -1113,6 +1088,15 @@ definitions:
|
|||||||
- ADMIN
|
- ADMIN
|
||||||
- USER
|
- USER
|
||||||
default: ROLE_UNSPECIFIED
|
default: ROLE_UNSPECIFIED
|
||||||
|
v1ShortcutOpenGraphMetadata:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
title:
|
||||||
|
type: string
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
|
image:
|
||||||
|
type: string
|
||||||
v1Subscription:
|
v1Subscription:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@ -1149,11 +1133,6 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
collection:
|
collection:
|
||||||
$ref: '#/definitions/apiv1Collection'
|
$ref: '#/definitions/apiv1Collection'
|
||||||
v1UpdateShortcutResponse:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
shortcut:
|
|
||||||
$ref: '#/definitions/apiv1Shortcut'
|
|
||||||
v1UpdateSubscriptionRequest:
|
v1UpdateSubscriptionRequest:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
"google.golang.org/grpc/peer"
|
"google.golang.org/grpc/peer"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
"google.golang.org/protobuf/encoding/protojson"
|
"google.golang.org/protobuf/encoding/protojson"
|
||||||
|
"google.golang.org/protobuf/types/known/emptypb"
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
|
|
||||||
v1pb "github.com/yourselfhosted/slash/proto/gen/api/v1"
|
v1pb "github.com/yourselfhosted/slash/proto/gen/api/v1"
|
||||||
@ -58,7 +59,7 @@ func (s *APIV1Service) ListShortcuts(ctx context.Context, _ *v1pb.ListShortcutsR
|
|||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *APIV1Service) GetShortcut(ctx context.Context, request *v1pb.GetShortcutRequest) (*v1pb.GetShortcutResponse, error) {
|
func (s *APIV1Service) GetShortcut(ctx context.Context, request *v1pb.GetShortcutRequest) (*v1pb.Shortcut, error) {
|
||||||
shortcut, err := s.Store.GetShortcut(ctx, &store.FindShortcut{
|
shortcut, err := s.Store.GetShortcut(ctx, &store.FindShortcut{
|
||||||
ID: &request.Id,
|
ID: &request.Id,
|
||||||
})
|
})
|
||||||
@ -84,13 +85,10 @@ func (s *APIV1Service) GetShortcut(ctx context.Context, request *v1pb.GetShortcu
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.Internal, "failed to convert shortcut, err: %v", err)
|
return nil, status.Errorf(codes.Internal, "failed to convert shortcut, err: %v", err)
|
||||||
}
|
}
|
||||||
response := &v1pb.GetShortcutResponse{
|
return composedShortcut, nil
|
||||||
Shortcut: composedShortcut,
|
|
||||||
}
|
|
||||||
return response, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *APIV1Service) GetShortcutByName(ctx context.Context, request *v1pb.GetShortcutByNameRequest) (*v1pb.GetShortcutByNameResponse, error) {
|
func (s *APIV1Service) GetShortcutByName(ctx context.Context, request *v1pb.GetShortcutByNameRequest) (*v1pb.Shortcut, error) {
|
||||||
shortcut, err := s.Store.GetShortcut(ctx, &store.FindShortcut{
|
shortcut, err := s.Store.GetShortcut(ctx, &store.FindShortcut{
|
||||||
Name: &request.Name,
|
Name: &request.Name,
|
||||||
})
|
})
|
||||||
@ -121,13 +119,10 @@ func (s *APIV1Service) GetShortcutByName(ctx context.Context, request *v1pb.GetS
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.Internal, "failed to convert shortcut, err: %v", err)
|
return nil, status.Errorf(codes.Internal, "failed to convert shortcut, err: %v", err)
|
||||||
}
|
}
|
||||||
response := &v1pb.GetShortcutByNameResponse{
|
return composedShortcut, nil
|
||||||
Shortcut: composedShortcut,
|
|
||||||
}
|
|
||||||
return response, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *APIV1Service) CreateShortcut(ctx context.Context, request *v1pb.CreateShortcutRequest) (*v1pb.CreateShortcutResponse, error) {
|
func (s *APIV1Service) CreateShortcut(ctx context.Context, request *v1pb.CreateShortcutRequest) (*v1pb.Shortcut, error) {
|
||||||
if request.Shortcut.Name == "" || request.Shortcut.Link == "" {
|
if request.Shortcut.Name == "" || request.Shortcut.Link == "" {
|
||||||
return nil, status.Errorf(codes.InvalidArgument, "name and link are required")
|
return nil, status.Errorf(codes.InvalidArgument, "name and link are required")
|
||||||
}
|
}
|
||||||
@ -187,14 +182,11 @@ func (s *APIV1Service) CreateShortcut(ctx context.Context, request *v1pb.CreateS
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.Internal, "failed to convert shortcut, err: %v", err)
|
return nil, status.Errorf(codes.Internal, "failed to convert shortcut, err: %v", err)
|
||||||
}
|
}
|
||||||
response := &v1pb.CreateShortcutResponse{
|
|
||||||
Shortcut: composedShortcut,
|
|
||||||
}
|
|
||||||
metric.Enqueue("shortcut create")
|
metric.Enqueue("shortcut create")
|
||||||
return response, nil
|
return composedShortcut, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *APIV1Service) UpdateShortcut(ctx context.Context, request *v1pb.UpdateShortcutRequest) (*v1pb.UpdateShortcutResponse, error) {
|
func (s *APIV1Service) UpdateShortcut(ctx context.Context, request *v1pb.UpdateShortcutRequest) (*v1pb.Shortcut, error) {
|
||||||
if request.UpdateMask == nil || len(request.UpdateMask.Paths) == 0 {
|
if request.UpdateMask == nil || len(request.UpdateMask.Paths) == 0 {
|
||||||
return nil, status.Errorf(codes.InvalidArgument, "updateMask is required")
|
return nil, status.Errorf(codes.InvalidArgument, "updateMask is required")
|
||||||
}
|
}
|
||||||
@ -254,13 +246,10 @@ func (s *APIV1Service) UpdateShortcut(ctx context.Context, request *v1pb.UpdateS
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.Internal, "failed to convert shortcut, err: %v", err)
|
return nil, status.Errorf(codes.Internal, "failed to convert shortcut, err: %v", err)
|
||||||
}
|
}
|
||||||
response := &v1pb.UpdateShortcutResponse{
|
return composedShortcut, nil
|
||||||
Shortcut: composedShortcut,
|
|
||||||
}
|
|
||||||
return response, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *APIV1Service) DeleteShortcut(ctx context.Context, request *v1pb.DeleteShortcutRequest) (*v1pb.DeleteShortcutResponse, error) {
|
func (s *APIV1Service) DeleteShortcut(ctx context.Context, request *v1pb.DeleteShortcutRequest) (*emptypb.Empty, error) {
|
||||||
user, err := getCurrentUser(ctx, s.Store)
|
user, err := getCurrentUser(ctx, s.Store)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.Unauthenticated, "failed to get current user: %v", err)
|
return nil, status.Errorf(codes.Unauthenticated, "failed to get current user: %v", err)
|
||||||
@ -284,8 +273,7 @@ func (s *APIV1Service) DeleteShortcut(ctx context.Context, request *v1pb.DeleteS
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, status.Errorf(codes.Internal, "failed to delete shortcut, err: %v", err)
|
return nil, status.Errorf(codes.Internal, "failed to delete shortcut, err: %v", err)
|
||||||
}
|
}
|
||||||
response := &v1pb.DeleteShortcutResponse{}
|
return &emptypb.Empty{}, nil
|
||||||
return response, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *APIV1Service) GetShortcutAnalytics(ctx context.Context, request *v1pb.GetShortcutAnalyticsRequest) (*v1pb.GetShortcutAnalyticsResponse, error) {
|
func (s *APIV1Service) GetShortcutAnalytics(ctx context.Context, request *v1pb.GetShortcutAnalyticsRequest) (*v1pb.GetShortcutAnalyticsResponse, error) {
|
||||||
@ -427,7 +415,7 @@ func (s *APIV1Service) convertShortcutFromStorepb(ctx context.Context, shortcut
|
|||||||
Tags: shortcut.Tags,
|
Tags: shortcut.Tags,
|
||||||
Description: shortcut.Description,
|
Description: shortcut.Description,
|
||||||
Visibility: v1pb.Visibility(shortcut.Visibility),
|
Visibility: v1pb.Visibility(shortcut.Visibility),
|
||||||
OgMetadata: &v1pb.OpenGraphMetadata{
|
OgMetadata: &v1pb.Shortcut_OpenGraphMetadata{
|
||||||
Title: shortcut.OgMetadata.Title,
|
Title: shortcut.OgMetadata.Title,
|
||||||
Description: shortcut.OgMetadata.Description,
|
Description: shortcut.OgMetadata.Description,
|
||||||
Image: shortcut.OgMetadata.Image,
|
Image: shortcut.OgMetadata.Image,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user