Compare commits
10 commits
607dc28413
...
497ae1959d
| Author | SHA1 | Date | |
|---|---|---|---|
| 497ae1959d | |||
| e57f966119 | |||
| 8fa018e6ec | |||
|
|
51b434d3b5 | ||
|
|
e02899e514 | ||
|
|
b3e67399b8 | ||
|
|
805e608aa5 | ||
|
|
34dbb83948 | ||
|
|
92a95a262f | ||
|
|
2d75439ecc |
152 changed files with 7883 additions and 3061 deletions
|
|
@ -9,7 +9,6 @@ coverage.out
|
|||
/.worktrees/
|
||||
|
||||
# Not used by the image build
|
||||
/web/
|
||||
/docs/
|
||||
/.github/
|
||||
*.md
|
||||
|
|
@ -25,3 +24,4 @@ coverage.out
|
|||
/.vscode/
|
||||
/.claude/
|
||||
**/.DS_Store
|
||||
/.git/
|
||||
|
|
|
|||
39
Dockerfile
Normal file
39
Dockerfile
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# ---- 1. frontend -----------------------------------------------------------
|
||||
FROM node:24-alpine AS frontend
|
||||
RUN corepack enable
|
||||
WORKDIR /src/web
|
||||
# Copy dependency manifest + patches first (pinned install), then the rest.
|
||||
COPY web/ ./
|
||||
RUN pnpm install --frozen-lockfile
|
||||
RUN pnpm release
|
||||
|
||||
# ---- 2. backend ------------------------------------------------------------
|
||||
FROM golang:1.27-alpine AS backend
|
||||
RUN apk add --no-cache git ca-certificates
|
||||
WORKDIR /src
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY . .
|
||||
COPY --from=frontend /src/server/router/frontend/dist ./server/router/frontend/dist
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build \
|
||||
-trimpath \
|
||||
-ldflags="-s -w -extldflags '-static'" \
|
||||
-tags netgo,osusergo \
|
||||
-o memos \
|
||||
./cmd/memos
|
||||
|
||||
# ---- 3. runtime ------------------------------------------------------------
|
||||
FROM alpine:3.21
|
||||
RUN apk add --no-cache tzdata ca-certificates su-exec && \
|
||||
addgroup -g 10001 -S nonroot && \
|
||||
adduser -u 10001 -S -G nonroot -h /var/opt/memos nonroot && \
|
||||
mkdir -p /var/opt/memos /usr/local/memos && \
|
||||
chown -R nonroot:nonroot /var/opt/memos
|
||||
COPY --from=backend /src/memos /usr/local/memos/memos
|
||||
COPY --from=backend --chmod=755 /src/scripts/entrypoint.sh /usr/local/memos/entrypoint.sh
|
||||
USER root
|
||||
WORKDIR /var/opt/memos
|
||||
VOLUME /var/opt/memos
|
||||
ENV TZ="UTC" MEMOS_PORT="5230"
|
||||
EXPOSE 5230
|
||||
ENTRYPOINT ["/usr/local/memos/entrypoint.sh", "/usr/local/memos/memos"]
|
||||
|
|
@ -93,8 +93,8 @@ Distribution is derived rather than separately configured:
|
|||
- A Space feed first requires active membership, then returns readable memos assigned to that Space that do not have a `COMMENT` relation. Membership does not make another author's assigned `PRIVATE` memo readable.
|
||||
- Direct memo reads evaluate each memo independently, including comments.
|
||||
- A comment or conversation query requires its context memo to be readable, then filters every replying memo by that memo's own audience.
|
||||
- A `COMMENT` or `REFERENCE` relation and its snippet are returned only when both endpoints are readable.
|
||||
- Reactions are readable whenever their memo is readable.
|
||||
- A `COMMENT` or `REFERENCE` relation and its snippet are returned only when both endpoints are readable. A readable comment's `parent` field still identifies its context memo; this identity does not grant access. Clients fetch it independently and render an unavailable context on permission denial or not-found. Bearer-share responses omit this field.
|
||||
- Reactions are readable whenever their memo is readable. An active reaction creator can withdraw their own reaction even after losing memo access or Space membership.
|
||||
- Public profiles and other public surfaces continue to use `PUBLIC`, not Space placement.
|
||||
|
||||
### Participation and governance
|
||||
|
|
|
|||
7
internal/markdown/parser/emoji.go
Normal file
7
internal/markdown/parser/emoji.go
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package parser
|
||||
|
||||
// IsEmoji reports whether value is one fully qualified Unicode emoji sequence.
|
||||
func IsEmoji(value string) bool {
|
||||
_, ok := emoji17FullyQualified[value]
|
||||
return ok
|
||||
}
|
||||
|
|
@ -20,25 +20,11 @@ var (
|
|||
|
||||
const maxMetadataScanBytes = 256 * 1024
|
||||
|
||||
// DetectJPEG detects embedded video in an in-memory JPEG.
|
||||
func DetectJPEG(blob []byte) *Detection {
|
||||
if len(blob) < 16 || !bytes.HasPrefix(blob, []byte{0xFF, 0xD8}) {
|
||||
return nil
|
||||
}
|
||||
|
||||
text := string(blob[:min(len(blob), maxMetadataScanBytes)])
|
||||
if !motionPhotoMarkerRegex.MatchString(text) {
|
||||
return nil
|
||||
}
|
||||
|
||||
videoStart := detectVideoStart(blob, text)
|
||||
if videoStart < 0 || videoStart >= len(blob) {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &Detection{
|
||||
VideoStart: videoStart,
|
||||
PresentationTimestampUs: parsePresentationTimestampUs(text),
|
||||
}
|
||||
// bytes.Reader never fails within bounds, so the error is unreachable.
|
||||
detection, _ := DetectJPEGReader(bytes.NewReader(blob), int64(len(blob)))
|
||||
return detection
|
||||
}
|
||||
|
||||
func ExtractVideo(blob []byte) ([]byte, *Detection) {
|
||||
|
|
@ -55,19 +41,6 @@ func ExtractVideo(blob []byte) ([]byte, *Detection) {
|
|||
return videoBlob, detection
|
||||
}
|
||||
|
||||
func detectVideoStart(blob []byte, text string) int {
|
||||
if matches := microVideoOffsetRegex.FindStringSubmatch(text); len(matches) == 2 {
|
||||
if offset, err := strconv.Atoi(matches[1]); err == nil && offset > 0 && offset < len(blob) {
|
||||
start := len(blob) - offset
|
||||
if looksLikeMP4(blob[start:]) {
|
||||
return start
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return findEmbeddedMP4Start(blob)
|
||||
}
|
||||
|
||||
func parsePresentationTimestampUs(text string) int64 {
|
||||
matches := presentationRegex.FindStringSubmatch(text)
|
||||
if len(matches) != 2 {
|
||||
|
|
|
|||
56
internal/motionphoto/reader.go
Normal file
56
internal/motionphoto/reader.go
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
package motionphoto
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
// DetectJPEGReader detects embedded video without loading the JPEG into memory.
|
||||
// It reads at most the metadata header plus the blocks needed to locate the video.
|
||||
func DetectJPEGReader(reader io.ReaderAt, size int64) (*Detection, error) {
|
||||
if size < 16 {
|
||||
return nil, nil
|
||||
}
|
||||
header := make([]byte, min(size, maxMetadataScanBytes))
|
||||
if _, err := reader.ReadAt(header, 0); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !bytes.HasPrefix(header, []byte{0xFF, 0xD8}) || !motionPhotoMarkerRegex.Match(header) {
|
||||
return nil, nil
|
||||
}
|
||||
text := string(header)
|
||||
makeDetection := func(start int64) *Detection {
|
||||
return &Detection{VideoStart: int(start), PresentationTimestampUs: parsePresentationTimestampUs(text)}
|
||||
}
|
||||
if matches := microVideoOffsetRegex.FindStringSubmatch(text); len(matches) == 2 {
|
||||
if offset, err := strconv.ParseInt(matches[1], 10, 64); err == nil && offset >= 12 && offset < size {
|
||||
var probe [12]byte
|
||||
if _, err := reader.ReadAt(probe[:], size-offset); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if looksLikeMP4(probe[:]) {
|
||||
return makeDetection(size - offset), nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to the last valid ftyp box, scanning backwards with overlap so
|
||||
// a box header crossing a block boundary is still found.
|
||||
buffer := make([]byte, 64*1024)
|
||||
for end := size; end >= 12; {
|
||||
start := max(int64(0), end-int64(len(buffer)))
|
||||
block := buffer[:end-start]
|
||||
if _, err := reader.ReadAt(block, start); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if index := findEmbeddedMP4Start(block); index >= 0 {
|
||||
return makeDetection(start + int64(index)), nil
|
||||
}
|
||||
if start == 0 {
|
||||
break
|
||||
}
|
||||
end = start + 11
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
45
internal/motionphoto/reader_test.go
Normal file
45
internal/motionphoto/reader_test.go
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
package motionphoto
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/usememos/memos/internal/testutil"
|
||||
)
|
||||
|
||||
func TestDetectJPEGReader(t *testing.T) {
|
||||
for _, blob := range [][]byte{nil, []byte("not a JPEG"), []byte("\xff\xd8 no motion marker here at all")} {
|
||||
detected, err := DetectJPEGReader(bytes.NewReader(blob), int64(len(blob)))
|
||||
require.NoError(t, err)
|
||||
require.Nil(t, detected)
|
||||
}
|
||||
fixture := testutil.BuildMotionPhotoJPEG()
|
||||
detected, err := DetectJPEGReader(bytes.NewReader(fixture), int64(len(fixture)))
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, detected)
|
||||
require.True(t, looksLikeMP4(fixture[detected.VideoStart:]))
|
||||
require.EqualValues(t, 123456, detected.PresentationTimestampUs)
|
||||
|
||||
// Exercise MP4 headers straddling both sides of the backwards scan boundary.
|
||||
for offset := -12; offset <= 12; offset++ {
|
||||
blob := make([]byte, 200_000)
|
||||
copy(blob, []byte("\xff\xd8 Camera:MotionPhoto=\"1\""))
|
||||
start := len(blob) - 64*1024 + offset
|
||||
copy(blob[start:], []byte{0, 0, 0, 16, 'f', 't', 'y', 'p', 'm', 'p', '4', '2'})
|
||||
detected, err := DetectJPEGReader(bytes.NewReader(blob), int64(len(blob)))
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, detected, "offset %d", offset)
|
||||
require.Equal(t, start, detected.VideoStart, "offset %d", offset)
|
||||
}
|
||||
|
||||
// Prefer the explicit MicroVideoOffset even when a later ftyp box exists.
|
||||
blob := make([]byte, 1024)
|
||||
copy(blob, []byte("\xff\xd8 Camera:MotionPhoto=\"1\" Camera:MicroVideoOffset=\"128\""))
|
||||
copy(blob[896:], []byte{0, 0, 0, 16, 'f', 't', 'y', 'p', 'm', 'p', '4', '2'})
|
||||
copy(blob[1000:], []byte{0, 0, 0, 16, 'f', 't', 'y', 'p', 'm', 'p', '4', '2'})
|
||||
detected, err = DetectJPEGReader(bytes.NewReader(blob), int64(len(blob)))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 896, detected.VideoStart)
|
||||
}
|
||||
|
|
@ -21,6 +21,16 @@ service AttachmentService {
|
|||
};
|
||||
option (google.api.method_signature) = "attachment";
|
||||
}
|
||||
// UploadAttachment uploads a file in bounded chunks. The first call carries
|
||||
// the spec and returns an upload_id; later calls carry that upload_id.
|
||||
// Uploads are bound to the authenticated user, expire after 30 minutes of
|
||||
// inactivity, and do not survive a server restart.
|
||||
rpc UploadAttachment(UploadAttachmentRequest) returns (UploadAttachmentResponse) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/attachments:upload"
|
||||
body: "*"
|
||||
};
|
||||
}
|
||||
// ListAttachments lists all attachments.
|
||||
rpc ListAttachments(ListAttachmentsRequest) returns (ListAttachmentsResponse) {
|
||||
option (google.api.http) = {get: "/api/v1/attachments"};
|
||||
|
|
@ -179,6 +189,61 @@ message CreateAttachmentRequest {
|
|||
string attachment_id = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message UploadAttachmentRequest {
|
||||
// Required. Start a new upload or continue an existing one.
|
||||
oneof upload {
|
||||
// Starts a new upload. The same call may also carry data and finish_write.
|
||||
UploadAttachmentSpec spec = 1;
|
||||
|
||||
// Continues the upload identified by a previous response.
|
||||
string upload_id = 2;
|
||||
}
|
||||
|
||||
// Required. Zero-based byte offset at which data is written. Must equal the
|
||||
// committed size, except when retrying the most recently accepted chunk
|
||||
// with identical bytes and offset, which is accepted without writing again.
|
||||
int64 write_offset = 3 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. File bytes, at most max_chunk_size long. With no data and
|
||||
// finish_write false, the call reports progress without writing, and
|
||||
// write_offset is ignored.
|
||||
bytes data = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. Finalize the upload after writing data. The committed size must
|
||||
// then equal total_size. Any later call for the same upload_id returns the
|
||||
// created attachment.
|
||||
bool finish_write = 5 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message UploadAttachmentSpec {
|
||||
// Required. Metadata for the attachment to create. content must be empty;
|
||||
// file bytes are sent in data.
|
||||
Attachment attachment = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. The attachment ID to use for this attachment.
|
||||
// If empty, a unique ID will be generated.
|
||||
// Format: ^[a-zA-Z0-9]([a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?$
|
||||
string attachment_id = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. Total size of the file in bytes before media processing.
|
||||
// Zero represents an empty file.
|
||||
int64 total_size = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message UploadAttachmentResponse {
|
||||
// Opaque ID for subsequent calls. This is not a resource name.
|
||||
string upload_id = 1;
|
||||
|
||||
// Number of file bytes committed so far.
|
||||
int64 committed_size = 2;
|
||||
|
||||
// Set once the upload has been finalized.
|
||||
Attachment attachment = 3;
|
||||
|
||||
// Maximum number of data bytes accepted in one call.
|
||||
int32 max_chunk_size = 4;
|
||||
}
|
||||
|
||||
message ListAttachmentsRequest {
|
||||
// Optional. The maximum number of attachments to return.
|
||||
// The service may return fewer than this value.
|
||||
|
|
|
|||
|
|
@ -258,8 +258,9 @@ message Memo {
|
|||
// Output only. The computed properties of the memo.
|
||||
Property property = 15 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Output only. The readable context memo of this COMMENT relation, if any.
|
||||
// This is omitted unless the caller may independently read both memos.
|
||||
// Output only. The context memo of this COMMENT relation, if any.
|
||||
// Its identity is returned even when the caller cannot read the parent.
|
||||
// Fetch the parent independently; this field does not grant read access.
|
||||
// Format: memos/{memo}
|
||||
optional string parent = 16 [
|
||||
(google.api.field_behavior) = OUTPUT_ONLY,
|
||||
|
|
|
|||
|
|
@ -1,127 +0,0 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package memos.api.v1;
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
import "google/api/client.proto";
|
||||
import "google/api/field_behavior.proto";
|
||||
import "google/api/resource.proto";
|
||||
import "google/protobuf/empty.proto";
|
||||
import "google/protobuf/field_mask.proto";
|
||||
|
||||
option go_package = "gen/api/v1";
|
||||
|
||||
service MemoViewService {
|
||||
// ListMemoViews returns a user's memo views. Each view is a named, reusable
|
||||
// CEL filter (see MemoView.filter); pass its filter string directly to the
|
||||
// ListMemos `filter` argument.
|
||||
rpc ListMemoViews(ListMemoViewsRequest) returns (ListMemoViewsResponse) {
|
||||
option (google.api.http) = {get: "/api/v1/{parent=users/*}/views"};
|
||||
option (google.api.method_signature) = "parent";
|
||||
}
|
||||
|
||||
// GetMemoView gets a memo view by name.
|
||||
rpc GetMemoView(GetMemoViewRequest) returns (MemoView) {
|
||||
option (google.api.http) = {get: "/api/v1/{name=users/*/views/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// CreateMemoView creates a new memo view for a user.
|
||||
rpc CreateMemoView(CreateMemoViewRequest) returns (MemoView) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/{parent=users/*}/views"
|
||||
body: "memo_view"
|
||||
};
|
||||
option (google.api.method_signature) = "parent,memo_view";
|
||||
}
|
||||
|
||||
// UpdateMemoView updates a memo view for a user.
|
||||
rpc UpdateMemoView(UpdateMemoViewRequest) returns (MemoView) {
|
||||
option (google.api.http) = {
|
||||
patch: "/api/v1/{memo_view.name=users/*/views/*}"
|
||||
body: "memo_view"
|
||||
};
|
||||
option (google.api.method_signature) = "memo_view,update_mask";
|
||||
}
|
||||
|
||||
// DeleteMemoView deletes a memo view for a user.
|
||||
rpc DeleteMemoView(DeleteMemoViewRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {delete: "/api/v1/{name=users/*/views/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
}
|
||||
|
||||
message MemoView {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api.v1/MemoView"
|
||||
pattern: "users/{user}/views/{view}"
|
||||
singular: "view"
|
||||
plural: "views"
|
||||
};
|
||||
|
||||
// The resource name of the memo view.
|
||||
// Format: users/{user}/views/{view}
|
||||
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
|
||||
|
||||
// The title of the memo view.
|
||||
string title = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// The CEL filter expression for the memo view, using the same grammar as the
|
||||
// ListMemos `filter` argument. Reuse it by passing this value to ListMemos.
|
||||
string filter = 3 [(google.api.field_behavior) = REQUIRED];
|
||||
}
|
||||
|
||||
message ListMemoViewsRequest {
|
||||
// Required. The parent resource where memo views are listed.
|
||||
// Format: users/{user}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {child_type: "memos.api.v1/MemoView"}
|
||||
];
|
||||
}
|
||||
|
||||
message ListMemoViewsResponse {
|
||||
// The list of memo views.
|
||||
repeated MemoView memo_views = 1;
|
||||
}
|
||||
|
||||
message GetMemoViewRequest {
|
||||
// Required. The resource name of the memo view to retrieve.
|
||||
// Format: users/{user}/views/{view}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/MemoView"}
|
||||
];
|
||||
}
|
||||
|
||||
message CreateMemoViewRequest {
|
||||
// Required. The parent resource where this memo view will be created.
|
||||
// Format: users/{user}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {child_type: "memos.api.v1/MemoView"}
|
||||
];
|
||||
|
||||
// Required. The memo view to create.
|
||||
MemoView memo_view = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. If set, validate the request, but do not actually create the memo view.
|
||||
bool validate_only = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message UpdateMemoViewRequest {
|
||||
// Required. The memo view resource which replaces the resource on the server.
|
||||
MemoView memo_view = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. The list of fields to update.
|
||||
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message DeleteMemoViewRequest {
|
||||
// Required. The resource name of the memo view to delete.
|
||||
// Format: users/{user}/views/{view}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/MemoView"}
|
||||
];
|
||||
}
|
||||
|
|
@ -157,6 +157,19 @@ message Space {
|
|||
// Output only. The number of accepted members in this space. Pending
|
||||
// invitations are excluded. Zero when this Space is exposed as metadata-only.
|
||||
int32 member_count = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
|
||||
|
||||
// Optional. Display icon. Omit when updating with the "icon" mask to reset
|
||||
// to the default Space mark.
|
||||
Icon icon = 6 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
message Icon {
|
||||
oneof value {
|
||||
// A Unicode emoji sequence.
|
||||
string emoji = 1;
|
||||
// A canonical Lucide icon name, such as "leaf".
|
||||
string lucide = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SpaceMember is a user's membership and governance role in a space.
|
||||
|
|
|
|||
|
|
@ -92,6 +92,44 @@ service UserService {
|
|||
option (google.api.method_signature) = "parent";
|
||||
}
|
||||
|
||||
// ListMemoViews returns a user's memo views. Each view is a named, reusable
|
||||
// CEL filter (see MemoView.filter); pass its filter string directly to the
|
||||
// ListMemos `filter` argument.
|
||||
rpc ListMemoViews(ListMemoViewsRequest) returns (ListMemoViewsResponse) {
|
||||
option (google.api.http) = {get: "/api/v1/{parent=users/*}/views"};
|
||||
option (google.api.method_signature) = "parent";
|
||||
}
|
||||
|
||||
// GetMemoView gets a memo view by name.
|
||||
rpc GetMemoView(GetMemoViewRequest) returns (MemoView) {
|
||||
option (google.api.http) = {get: "/api/v1/{name=users/*/views/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// CreateMemoView creates a new memo view for a user.
|
||||
rpc CreateMemoView(CreateMemoViewRequest) returns (MemoView) {
|
||||
option (google.api.http) = {
|
||||
post: "/api/v1/{parent=users/*}/views"
|
||||
body: "memo_view"
|
||||
};
|
||||
option (google.api.method_signature) = "parent,memo_view";
|
||||
}
|
||||
|
||||
// UpdateMemoView updates a memo view for a user.
|
||||
rpc UpdateMemoView(UpdateMemoViewRequest) returns (MemoView) {
|
||||
option (google.api.http) = {
|
||||
patch: "/api/v1/{memo_view.name=users/*/views/*}"
|
||||
body: "memo_view"
|
||||
};
|
||||
option (google.api.method_signature) = "memo_view,update_mask";
|
||||
}
|
||||
|
||||
// DeleteMemoView deletes a memo view for a user.
|
||||
rpc DeleteMemoView(DeleteMemoViewRequest) returns (google.protobuf.Empty) {
|
||||
option (google.api.http) = {delete: "/api/v1/{name=users/*/views/*}"};
|
||||
option (google.api.method_signature) = "name";
|
||||
}
|
||||
|
||||
// ListLinkedIdentities returns a list of linked SSO identities for a user.
|
||||
rpc ListLinkedIdentities(ListLinkedIdentitiesRequest) returns (ListLinkedIdentitiesResponse) {
|
||||
option (google.api.http) = {get: "/api/v1/{parent=users/*}/linkedIdentities"};
|
||||
|
|
@ -541,6 +579,95 @@ message ListUserSettingsResponse {
|
|||
string next_page_token = 2;
|
||||
}
|
||||
|
||||
// Saved memo view messages
|
||||
message MemoView {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api.v1/MemoView"
|
||||
pattern: "users/{user}/views/{view}"
|
||||
singular: "view"
|
||||
plural: "views"
|
||||
};
|
||||
|
||||
// The resource name of the memo view.
|
||||
// Format: users/{user}/views/{view}
|
||||
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
|
||||
|
||||
// The title of the memo view.
|
||||
string title = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// The CEL filter expression for the memo view, using the same grammar as the
|
||||
// ListMemos `filter` argument. Reuse it by passing this value to ListMemos.
|
||||
string filter = 3 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. Display icon. Omit when updating with the "icon" mask to reset
|
||||
// to the default view icon.
|
||||
Icon icon = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
message Icon {
|
||||
oneof value {
|
||||
// A Unicode emoji sequence.
|
||||
string emoji = 1;
|
||||
// A canonical Lucide icon name, such as "leaf".
|
||||
string lucide = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
message ListMemoViewsRequest {
|
||||
// Required. The parent resource where memo views are listed.
|
||||
// Format: users/{user}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {child_type: "memos.api.v1/MemoView"}
|
||||
];
|
||||
}
|
||||
|
||||
message ListMemoViewsResponse {
|
||||
// The list of memo views.
|
||||
repeated MemoView memo_views = 1;
|
||||
}
|
||||
|
||||
message GetMemoViewRequest {
|
||||
// Required. The resource name of the memo view to retrieve.
|
||||
// Format: users/{user}/views/{view}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/MemoView"}
|
||||
];
|
||||
}
|
||||
|
||||
message CreateMemoViewRequest {
|
||||
// Required. The parent resource where this memo view will be created.
|
||||
// Format: users/{user}
|
||||
string parent = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {child_type: "memos.api.v1/MemoView"}
|
||||
];
|
||||
|
||||
// Required. The memo view to create.
|
||||
MemoView memo_view = 2 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. If set, validate the request, but do not actually create the memo view.
|
||||
bool validate_only = 3 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message UpdateMemoViewRequest {
|
||||
// Required. The memo view resource which replaces the resource on the server.
|
||||
MemoView memo_view = 1 [(google.api.field_behavior) = REQUIRED];
|
||||
|
||||
// Optional. The list of fields to update.
|
||||
google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
message DeleteMemoViewRequest {
|
||||
// Required. The resource name of the memo view to delete.
|
||||
// Format: users/{user}/views/{view}
|
||||
string name = 1 [
|
||||
(google.api.field_behavior) = REQUIRED,
|
||||
(google.api.resource_reference) = {type: "memos.api.v1/MemoView"}
|
||||
];
|
||||
}
|
||||
|
||||
// LinkedIdentity represents an SSO identity linked to a user account.
|
||||
message LinkedIdentity {
|
||||
option (google.api.resource) = {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ const (
|
|||
// AttachmentServiceCreateAttachmentProcedure is the fully-qualified name of the AttachmentService's
|
||||
// CreateAttachment RPC.
|
||||
AttachmentServiceCreateAttachmentProcedure = "/memos.api.v1.AttachmentService/CreateAttachment"
|
||||
// AttachmentServiceUploadAttachmentProcedure is the fully-qualified name of the AttachmentService's
|
||||
// UploadAttachment RPC.
|
||||
AttachmentServiceUploadAttachmentProcedure = "/memos.api.v1.AttachmentService/UploadAttachment"
|
||||
// AttachmentServiceListAttachmentsProcedure is the fully-qualified name of the AttachmentService's
|
||||
// ListAttachments RPC.
|
||||
AttachmentServiceListAttachmentsProcedure = "/memos.api.v1.AttachmentService/ListAttachments"
|
||||
|
|
@ -58,6 +61,11 @@ const (
|
|||
type AttachmentServiceClient interface {
|
||||
// CreateAttachment creates a new attachment.
|
||||
CreateAttachment(context.Context, *connect.Request[v1.CreateAttachmentRequest]) (*connect.Response[v1.Attachment], error)
|
||||
// UploadAttachment uploads a file in bounded chunks. The first call carries
|
||||
// the spec and returns an upload_id; later calls carry that upload_id.
|
||||
// Uploads are bound to the authenticated user, expire after 30 minutes of
|
||||
// inactivity, and do not survive a server restart.
|
||||
UploadAttachment(context.Context, *connect.Request[v1.UploadAttachmentRequest]) (*connect.Response[v1.UploadAttachmentResponse], error)
|
||||
// ListAttachments lists all attachments.
|
||||
ListAttachments(context.Context, *connect.Request[v1.ListAttachmentsRequest]) (*connect.Response[v1.ListAttachmentsResponse], error)
|
||||
// GetAttachment returns an attachment by name.
|
||||
|
|
@ -87,6 +95,12 @@ func NewAttachmentServiceClient(httpClient connect.HTTPClient, baseURL string, o
|
|||
connect.WithSchema(attachmentServiceMethods.ByName("CreateAttachment")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
uploadAttachment: connect.NewClient[v1.UploadAttachmentRequest, v1.UploadAttachmentResponse](
|
||||
httpClient,
|
||||
baseURL+AttachmentServiceUploadAttachmentProcedure,
|
||||
connect.WithSchema(attachmentServiceMethods.ByName("UploadAttachment")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
listAttachments: connect.NewClient[v1.ListAttachmentsRequest, v1.ListAttachmentsResponse](
|
||||
httpClient,
|
||||
baseURL+AttachmentServiceListAttachmentsProcedure,
|
||||
|
|
@ -123,6 +137,7 @@ func NewAttachmentServiceClient(httpClient connect.HTTPClient, baseURL string, o
|
|||
// attachmentServiceClient implements AttachmentServiceClient.
|
||||
type attachmentServiceClient struct {
|
||||
createAttachment *connect.Client[v1.CreateAttachmentRequest, v1.Attachment]
|
||||
uploadAttachment *connect.Client[v1.UploadAttachmentRequest, v1.UploadAttachmentResponse]
|
||||
listAttachments *connect.Client[v1.ListAttachmentsRequest, v1.ListAttachmentsResponse]
|
||||
getAttachment *connect.Client[v1.GetAttachmentRequest, v1.Attachment]
|
||||
updateAttachment *connect.Client[v1.UpdateAttachmentRequest, v1.Attachment]
|
||||
|
|
@ -135,6 +150,11 @@ func (c *attachmentServiceClient) CreateAttachment(ctx context.Context, req *con
|
|||
return c.createAttachment.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// UploadAttachment calls memos.api.v1.AttachmentService.UploadAttachment.
|
||||
func (c *attachmentServiceClient) UploadAttachment(ctx context.Context, req *connect.Request[v1.UploadAttachmentRequest]) (*connect.Response[v1.UploadAttachmentResponse], error) {
|
||||
return c.uploadAttachment.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// ListAttachments calls memos.api.v1.AttachmentService.ListAttachments.
|
||||
func (c *attachmentServiceClient) ListAttachments(ctx context.Context, req *connect.Request[v1.ListAttachmentsRequest]) (*connect.Response[v1.ListAttachmentsResponse], error) {
|
||||
return c.listAttachments.CallUnary(ctx, req)
|
||||
|
|
@ -164,6 +184,11 @@ func (c *attachmentServiceClient) BatchDeleteAttachments(ctx context.Context, re
|
|||
type AttachmentServiceHandler interface {
|
||||
// CreateAttachment creates a new attachment.
|
||||
CreateAttachment(context.Context, *connect.Request[v1.CreateAttachmentRequest]) (*connect.Response[v1.Attachment], error)
|
||||
// UploadAttachment uploads a file in bounded chunks. The first call carries
|
||||
// the spec and returns an upload_id; later calls carry that upload_id.
|
||||
// Uploads are bound to the authenticated user, expire after 30 minutes of
|
||||
// inactivity, and do not survive a server restart.
|
||||
UploadAttachment(context.Context, *connect.Request[v1.UploadAttachmentRequest]) (*connect.Response[v1.UploadAttachmentResponse], error)
|
||||
// ListAttachments lists all attachments.
|
||||
ListAttachments(context.Context, *connect.Request[v1.ListAttachmentsRequest]) (*connect.Response[v1.ListAttachmentsResponse], error)
|
||||
// GetAttachment returns an attachment by name.
|
||||
|
|
@ -189,6 +214,12 @@ func NewAttachmentServiceHandler(svc AttachmentServiceHandler, opts ...connect.H
|
|||
connect.WithSchema(attachmentServiceMethods.ByName("CreateAttachment")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
attachmentServiceUploadAttachmentHandler := connect.NewUnaryHandler(
|
||||
AttachmentServiceUploadAttachmentProcedure,
|
||||
svc.UploadAttachment,
|
||||
connect.WithSchema(attachmentServiceMethods.ByName("UploadAttachment")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
attachmentServiceListAttachmentsHandler := connect.NewUnaryHandler(
|
||||
AttachmentServiceListAttachmentsProcedure,
|
||||
svc.ListAttachments,
|
||||
|
|
@ -223,6 +254,8 @@ func NewAttachmentServiceHandler(svc AttachmentServiceHandler, opts ...connect.H
|
|||
switch r.URL.Path {
|
||||
case AttachmentServiceCreateAttachmentProcedure:
|
||||
attachmentServiceCreateAttachmentHandler.ServeHTTP(w, r)
|
||||
case AttachmentServiceUploadAttachmentProcedure:
|
||||
attachmentServiceUploadAttachmentHandler.ServeHTTP(w, r)
|
||||
case AttachmentServiceListAttachmentsProcedure:
|
||||
attachmentServiceListAttachmentsHandler.ServeHTTP(w, r)
|
||||
case AttachmentServiceGetAttachmentProcedure:
|
||||
|
|
@ -246,6 +279,10 @@ func (UnimplementedAttachmentServiceHandler) CreateAttachment(context.Context, *
|
|||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AttachmentService.CreateAttachment is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAttachmentServiceHandler) UploadAttachment(context.Context, *connect.Request[v1.UploadAttachmentRequest]) (*connect.Response[v1.UploadAttachmentResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AttachmentService.UploadAttachment is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedAttachmentServiceHandler) ListAttachments(context.Context, *connect.Request[v1.ListAttachmentsRequest]) (*connect.Response[v1.ListAttachmentsResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.AttachmentService.ListAttachments is not implemented"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,240 +0,0 @@
|
|||
// Code generated by protoc-gen-connect-go. DO NOT EDIT.
|
||||
//
|
||||
// Source: api/v1/memo_view_service.proto
|
||||
|
||||
package apiv1connect
|
||||
|
||||
import (
|
||||
connect "connectrpc.com/connect"
|
||||
context "context"
|
||||
errors "errors"
|
||||
v1 "github.com/usememos/memos/proto/gen/api/v1"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
http "net/http"
|
||||
strings "strings"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file and the connect package are
|
||||
// compatible. If you get a compiler error that this constant is not defined, this code was
|
||||
// generated with a version of connect newer than the one compiled into your binary. You can fix the
|
||||
// problem by either regenerating this code with an older version of connect or updating the connect
|
||||
// version compiled into your binary.
|
||||
const _ = connect.IsAtLeastVersion1_13_0
|
||||
|
||||
const (
|
||||
// MemoViewServiceName is the fully-qualified name of the MemoViewService service.
|
||||
MemoViewServiceName = "memos.api.v1.MemoViewService"
|
||||
)
|
||||
|
||||
// These constants are the fully-qualified names of the RPCs defined in this package. They're
|
||||
// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
|
||||
//
|
||||
// Note that these are different from the fully-qualified method names used by
|
||||
// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
|
||||
// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
|
||||
// period.
|
||||
const (
|
||||
// MemoViewServiceListMemoViewsProcedure is the fully-qualified name of the MemoViewService's
|
||||
// ListMemoViews RPC.
|
||||
MemoViewServiceListMemoViewsProcedure = "/memos.api.v1.MemoViewService/ListMemoViews"
|
||||
// MemoViewServiceGetMemoViewProcedure is the fully-qualified name of the MemoViewService's
|
||||
// GetMemoView RPC.
|
||||
MemoViewServiceGetMemoViewProcedure = "/memos.api.v1.MemoViewService/GetMemoView"
|
||||
// MemoViewServiceCreateMemoViewProcedure is the fully-qualified name of the MemoViewService's
|
||||
// CreateMemoView RPC.
|
||||
MemoViewServiceCreateMemoViewProcedure = "/memos.api.v1.MemoViewService/CreateMemoView"
|
||||
// MemoViewServiceUpdateMemoViewProcedure is the fully-qualified name of the MemoViewService's
|
||||
// UpdateMemoView RPC.
|
||||
MemoViewServiceUpdateMemoViewProcedure = "/memos.api.v1.MemoViewService/UpdateMemoView"
|
||||
// MemoViewServiceDeleteMemoViewProcedure is the fully-qualified name of the MemoViewService's
|
||||
// DeleteMemoView RPC.
|
||||
MemoViewServiceDeleteMemoViewProcedure = "/memos.api.v1.MemoViewService/DeleteMemoView"
|
||||
)
|
||||
|
||||
// MemoViewServiceClient is a client for the memos.api.v1.MemoViewService service.
|
||||
type MemoViewServiceClient interface {
|
||||
// ListMemoViews returns a user's memo views. Each view is a named, reusable
|
||||
// CEL filter (see MemoView.filter); pass its filter string directly to the
|
||||
// ListMemos `filter` argument.
|
||||
ListMemoViews(context.Context, *connect.Request[v1.ListMemoViewsRequest]) (*connect.Response[v1.ListMemoViewsResponse], error)
|
||||
// GetMemoView gets a memo view by name.
|
||||
GetMemoView(context.Context, *connect.Request[v1.GetMemoViewRequest]) (*connect.Response[v1.MemoView], error)
|
||||
// CreateMemoView creates a new memo view for a user.
|
||||
CreateMemoView(context.Context, *connect.Request[v1.CreateMemoViewRequest]) (*connect.Response[v1.MemoView], error)
|
||||
// UpdateMemoView updates a memo view for a user.
|
||||
UpdateMemoView(context.Context, *connect.Request[v1.UpdateMemoViewRequest]) (*connect.Response[v1.MemoView], error)
|
||||
// DeleteMemoView deletes a memo view for a user.
|
||||
DeleteMemoView(context.Context, *connect.Request[v1.DeleteMemoViewRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
}
|
||||
|
||||
// NewMemoViewServiceClient constructs a client for the memos.api.v1.MemoViewService service. By
|
||||
// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses,
|
||||
// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the
|
||||
// connect.WithGRPC() or connect.WithGRPCWeb() options.
|
||||
//
|
||||
// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
|
||||
// http://api.acme.com or https://acme.com/grpc).
|
||||
func NewMemoViewServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) MemoViewServiceClient {
|
||||
baseURL = strings.TrimRight(baseURL, "/")
|
||||
memoViewServiceMethods := v1.File_api_v1_memo_view_service_proto.Services().ByName("MemoViewService").Methods()
|
||||
return &memoViewServiceClient{
|
||||
listMemoViews: connect.NewClient[v1.ListMemoViewsRequest, v1.ListMemoViewsResponse](
|
||||
httpClient,
|
||||
baseURL+MemoViewServiceListMemoViewsProcedure,
|
||||
connect.WithSchema(memoViewServiceMethods.ByName("ListMemoViews")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
getMemoView: connect.NewClient[v1.GetMemoViewRequest, v1.MemoView](
|
||||
httpClient,
|
||||
baseURL+MemoViewServiceGetMemoViewProcedure,
|
||||
connect.WithSchema(memoViewServiceMethods.ByName("GetMemoView")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
createMemoView: connect.NewClient[v1.CreateMemoViewRequest, v1.MemoView](
|
||||
httpClient,
|
||||
baseURL+MemoViewServiceCreateMemoViewProcedure,
|
||||
connect.WithSchema(memoViewServiceMethods.ByName("CreateMemoView")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
updateMemoView: connect.NewClient[v1.UpdateMemoViewRequest, v1.MemoView](
|
||||
httpClient,
|
||||
baseURL+MemoViewServiceUpdateMemoViewProcedure,
|
||||
connect.WithSchema(memoViewServiceMethods.ByName("UpdateMemoView")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
deleteMemoView: connect.NewClient[v1.DeleteMemoViewRequest, emptypb.Empty](
|
||||
httpClient,
|
||||
baseURL+MemoViewServiceDeleteMemoViewProcedure,
|
||||
connect.WithSchema(memoViewServiceMethods.ByName("DeleteMemoView")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
// memoViewServiceClient implements MemoViewServiceClient.
|
||||
type memoViewServiceClient struct {
|
||||
listMemoViews *connect.Client[v1.ListMemoViewsRequest, v1.ListMemoViewsResponse]
|
||||
getMemoView *connect.Client[v1.GetMemoViewRequest, v1.MemoView]
|
||||
createMemoView *connect.Client[v1.CreateMemoViewRequest, v1.MemoView]
|
||||
updateMemoView *connect.Client[v1.UpdateMemoViewRequest, v1.MemoView]
|
||||
deleteMemoView *connect.Client[v1.DeleteMemoViewRequest, emptypb.Empty]
|
||||
}
|
||||
|
||||
// ListMemoViews calls memos.api.v1.MemoViewService.ListMemoViews.
|
||||
func (c *memoViewServiceClient) ListMemoViews(ctx context.Context, req *connect.Request[v1.ListMemoViewsRequest]) (*connect.Response[v1.ListMemoViewsResponse], error) {
|
||||
return c.listMemoViews.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// GetMemoView calls memos.api.v1.MemoViewService.GetMemoView.
|
||||
func (c *memoViewServiceClient) GetMemoView(ctx context.Context, req *connect.Request[v1.GetMemoViewRequest]) (*connect.Response[v1.MemoView], error) {
|
||||
return c.getMemoView.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// CreateMemoView calls memos.api.v1.MemoViewService.CreateMemoView.
|
||||
func (c *memoViewServiceClient) CreateMemoView(ctx context.Context, req *connect.Request[v1.CreateMemoViewRequest]) (*connect.Response[v1.MemoView], error) {
|
||||
return c.createMemoView.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// UpdateMemoView calls memos.api.v1.MemoViewService.UpdateMemoView.
|
||||
func (c *memoViewServiceClient) UpdateMemoView(ctx context.Context, req *connect.Request[v1.UpdateMemoViewRequest]) (*connect.Response[v1.MemoView], error) {
|
||||
return c.updateMemoView.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// DeleteMemoView calls memos.api.v1.MemoViewService.DeleteMemoView.
|
||||
func (c *memoViewServiceClient) DeleteMemoView(ctx context.Context, req *connect.Request[v1.DeleteMemoViewRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return c.deleteMemoView.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// MemoViewServiceHandler is an implementation of the memos.api.v1.MemoViewService service.
|
||||
type MemoViewServiceHandler interface {
|
||||
// ListMemoViews returns a user's memo views. Each view is a named, reusable
|
||||
// CEL filter (see MemoView.filter); pass its filter string directly to the
|
||||
// ListMemos `filter` argument.
|
||||
ListMemoViews(context.Context, *connect.Request[v1.ListMemoViewsRequest]) (*connect.Response[v1.ListMemoViewsResponse], error)
|
||||
// GetMemoView gets a memo view by name.
|
||||
GetMemoView(context.Context, *connect.Request[v1.GetMemoViewRequest]) (*connect.Response[v1.MemoView], error)
|
||||
// CreateMemoView creates a new memo view for a user.
|
||||
CreateMemoView(context.Context, *connect.Request[v1.CreateMemoViewRequest]) (*connect.Response[v1.MemoView], error)
|
||||
// UpdateMemoView updates a memo view for a user.
|
||||
UpdateMemoView(context.Context, *connect.Request[v1.UpdateMemoViewRequest]) (*connect.Response[v1.MemoView], error)
|
||||
// DeleteMemoView deletes a memo view for a user.
|
||||
DeleteMemoView(context.Context, *connect.Request[v1.DeleteMemoViewRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
}
|
||||
|
||||
// NewMemoViewServiceHandler builds an HTTP handler from the service implementation. It returns the
|
||||
// path on which to mount the handler and the handler itself.
|
||||
//
|
||||
// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
|
||||
// and JSON codecs. They also support gzip compression.
|
||||
func NewMemoViewServiceHandler(svc MemoViewServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
|
||||
memoViewServiceMethods := v1.File_api_v1_memo_view_service_proto.Services().ByName("MemoViewService").Methods()
|
||||
memoViewServiceListMemoViewsHandler := connect.NewUnaryHandler(
|
||||
MemoViewServiceListMemoViewsProcedure,
|
||||
svc.ListMemoViews,
|
||||
connect.WithSchema(memoViewServiceMethods.ByName("ListMemoViews")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
memoViewServiceGetMemoViewHandler := connect.NewUnaryHandler(
|
||||
MemoViewServiceGetMemoViewProcedure,
|
||||
svc.GetMemoView,
|
||||
connect.WithSchema(memoViewServiceMethods.ByName("GetMemoView")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
memoViewServiceCreateMemoViewHandler := connect.NewUnaryHandler(
|
||||
MemoViewServiceCreateMemoViewProcedure,
|
||||
svc.CreateMemoView,
|
||||
connect.WithSchema(memoViewServiceMethods.ByName("CreateMemoView")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
memoViewServiceUpdateMemoViewHandler := connect.NewUnaryHandler(
|
||||
MemoViewServiceUpdateMemoViewProcedure,
|
||||
svc.UpdateMemoView,
|
||||
connect.WithSchema(memoViewServiceMethods.ByName("UpdateMemoView")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
memoViewServiceDeleteMemoViewHandler := connect.NewUnaryHandler(
|
||||
MemoViewServiceDeleteMemoViewProcedure,
|
||||
svc.DeleteMemoView,
|
||||
connect.WithSchema(memoViewServiceMethods.ByName("DeleteMemoView")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
return "/memos.api.v1.MemoViewService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
switch r.URL.Path {
|
||||
case MemoViewServiceListMemoViewsProcedure:
|
||||
memoViewServiceListMemoViewsHandler.ServeHTTP(w, r)
|
||||
case MemoViewServiceGetMemoViewProcedure:
|
||||
memoViewServiceGetMemoViewHandler.ServeHTTP(w, r)
|
||||
case MemoViewServiceCreateMemoViewProcedure:
|
||||
memoViewServiceCreateMemoViewHandler.ServeHTTP(w, r)
|
||||
case MemoViewServiceUpdateMemoViewProcedure:
|
||||
memoViewServiceUpdateMemoViewHandler.ServeHTTP(w, r)
|
||||
case MemoViewServiceDeleteMemoViewProcedure:
|
||||
memoViewServiceDeleteMemoViewHandler.ServeHTTP(w, r)
|
||||
default:
|
||||
http.NotFound(w, r)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// UnimplementedMemoViewServiceHandler returns CodeUnimplemented from all methods.
|
||||
type UnimplementedMemoViewServiceHandler struct{}
|
||||
|
||||
func (UnimplementedMemoViewServiceHandler) ListMemoViews(context.Context, *connect.Request[v1.ListMemoViewsRequest]) (*connect.Response[v1.ListMemoViewsResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoViewService.ListMemoViews is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedMemoViewServiceHandler) GetMemoView(context.Context, *connect.Request[v1.GetMemoViewRequest]) (*connect.Response[v1.MemoView], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoViewService.GetMemoView is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedMemoViewServiceHandler) CreateMemoView(context.Context, *connect.Request[v1.CreateMemoViewRequest]) (*connect.Response[v1.MemoView], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoViewService.CreateMemoView is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedMemoViewServiceHandler) UpdateMemoView(context.Context, *connect.Request[v1.UpdateMemoViewRequest]) (*connect.Response[v1.MemoView], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoViewService.UpdateMemoView is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedMemoViewServiceHandler) DeleteMemoView(context.Context, *connect.Request[v1.DeleteMemoViewRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.MemoViewService.DeleteMemoView is not implemented"))
|
||||
}
|
||||
|
|
@ -62,6 +62,20 @@ const (
|
|||
// UserServiceListUserSettingsProcedure is the fully-qualified name of the UserService's
|
||||
// ListUserSettings RPC.
|
||||
UserServiceListUserSettingsProcedure = "/memos.api.v1.UserService/ListUserSettings"
|
||||
// UserServiceListMemoViewsProcedure is the fully-qualified name of the UserService's ListMemoViews
|
||||
// RPC.
|
||||
UserServiceListMemoViewsProcedure = "/memos.api.v1.UserService/ListMemoViews"
|
||||
// UserServiceGetMemoViewProcedure is the fully-qualified name of the UserService's GetMemoView RPC.
|
||||
UserServiceGetMemoViewProcedure = "/memos.api.v1.UserService/GetMemoView"
|
||||
// UserServiceCreateMemoViewProcedure is the fully-qualified name of the UserService's
|
||||
// CreateMemoView RPC.
|
||||
UserServiceCreateMemoViewProcedure = "/memos.api.v1.UserService/CreateMemoView"
|
||||
// UserServiceUpdateMemoViewProcedure is the fully-qualified name of the UserService's
|
||||
// UpdateMemoView RPC.
|
||||
UserServiceUpdateMemoViewProcedure = "/memos.api.v1.UserService/UpdateMemoView"
|
||||
// UserServiceDeleteMemoViewProcedure is the fully-qualified name of the UserService's
|
||||
// DeleteMemoView RPC.
|
||||
UserServiceDeleteMemoViewProcedure = "/memos.api.v1.UserService/DeleteMemoView"
|
||||
// UserServiceListLinkedIdentitiesProcedure is the fully-qualified name of the UserService's
|
||||
// ListLinkedIdentities RPC.
|
||||
UserServiceListLinkedIdentitiesProcedure = "/memos.api.v1.UserService/ListLinkedIdentities"
|
||||
|
|
@ -134,6 +148,18 @@ type UserServiceClient interface {
|
|||
UpdateUserSetting(context.Context, *connect.Request[v1.UpdateUserSettingRequest]) (*connect.Response[v1.UserSetting], error)
|
||||
// ListUserSettings returns a list of user settings.
|
||||
ListUserSettings(context.Context, *connect.Request[v1.ListUserSettingsRequest]) (*connect.Response[v1.ListUserSettingsResponse], error)
|
||||
// ListMemoViews returns a user's memo views. Each view is a named, reusable
|
||||
// CEL filter (see MemoView.filter); pass its filter string directly to the
|
||||
// ListMemos `filter` argument.
|
||||
ListMemoViews(context.Context, *connect.Request[v1.ListMemoViewsRequest]) (*connect.Response[v1.ListMemoViewsResponse], error)
|
||||
// GetMemoView gets a memo view by name.
|
||||
GetMemoView(context.Context, *connect.Request[v1.GetMemoViewRequest]) (*connect.Response[v1.MemoView], error)
|
||||
// CreateMemoView creates a new memo view for a user.
|
||||
CreateMemoView(context.Context, *connect.Request[v1.CreateMemoViewRequest]) (*connect.Response[v1.MemoView], error)
|
||||
// UpdateMemoView updates a memo view for a user.
|
||||
UpdateMemoView(context.Context, *connect.Request[v1.UpdateMemoViewRequest]) (*connect.Response[v1.MemoView], error)
|
||||
// DeleteMemoView deletes a memo view for a user.
|
||||
DeleteMemoView(context.Context, *connect.Request[v1.DeleteMemoViewRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// ListLinkedIdentities returns a list of linked SSO identities for a user.
|
||||
ListLinkedIdentities(context.Context, *connect.Request[v1.ListLinkedIdentitiesRequest]) (*connect.Response[v1.ListLinkedIdentitiesResponse], error)
|
||||
// CreateLinkedIdentity links an SSO identity to the authenticated user.
|
||||
|
|
@ -247,6 +273,36 @@ func NewUserServiceClient(httpClient connect.HTTPClient, baseURL string, opts ..
|
|||
connect.WithSchema(userServiceMethods.ByName("ListUserSettings")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
listMemoViews: connect.NewClient[v1.ListMemoViewsRequest, v1.ListMemoViewsResponse](
|
||||
httpClient,
|
||||
baseURL+UserServiceListMemoViewsProcedure,
|
||||
connect.WithSchema(userServiceMethods.ByName("ListMemoViews")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
getMemoView: connect.NewClient[v1.GetMemoViewRequest, v1.MemoView](
|
||||
httpClient,
|
||||
baseURL+UserServiceGetMemoViewProcedure,
|
||||
connect.WithSchema(userServiceMethods.ByName("GetMemoView")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
createMemoView: connect.NewClient[v1.CreateMemoViewRequest, v1.MemoView](
|
||||
httpClient,
|
||||
baseURL+UserServiceCreateMemoViewProcedure,
|
||||
connect.WithSchema(userServiceMethods.ByName("CreateMemoView")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
updateMemoView: connect.NewClient[v1.UpdateMemoViewRequest, v1.MemoView](
|
||||
httpClient,
|
||||
baseURL+UserServiceUpdateMemoViewProcedure,
|
||||
connect.WithSchema(userServiceMethods.ByName("UpdateMemoView")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
deleteMemoView: connect.NewClient[v1.DeleteMemoViewRequest, emptypb.Empty](
|
||||
httpClient,
|
||||
baseURL+UserServiceDeleteMemoViewProcedure,
|
||||
connect.WithSchema(userServiceMethods.ByName("DeleteMemoView")),
|
||||
connect.WithClientOptions(opts...),
|
||||
),
|
||||
listLinkedIdentities: connect.NewClient[v1.ListLinkedIdentitiesRequest, v1.ListLinkedIdentitiesResponse](
|
||||
httpClient,
|
||||
baseURL+UserServiceListLinkedIdentitiesProcedure,
|
||||
|
|
@ -353,6 +409,11 @@ type userServiceClient struct {
|
|||
getUserSetting *connect.Client[v1.GetUserSettingRequest, v1.UserSetting]
|
||||
updateUserSetting *connect.Client[v1.UpdateUserSettingRequest, v1.UserSetting]
|
||||
listUserSettings *connect.Client[v1.ListUserSettingsRequest, v1.ListUserSettingsResponse]
|
||||
listMemoViews *connect.Client[v1.ListMemoViewsRequest, v1.ListMemoViewsResponse]
|
||||
getMemoView *connect.Client[v1.GetMemoViewRequest, v1.MemoView]
|
||||
createMemoView *connect.Client[v1.CreateMemoViewRequest, v1.MemoView]
|
||||
updateMemoView *connect.Client[v1.UpdateMemoViewRequest, v1.MemoView]
|
||||
deleteMemoView *connect.Client[v1.DeleteMemoViewRequest, emptypb.Empty]
|
||||
listLinkedIdentities *connect.Client[v1.ListLinkedIdentitiesRequest, v1.ListLinkedIdentitiesResponse]
|
||||
createLinkedIdentity *connect.Client[v1.CreateLinkedIdentityRequest, v1.LinkedIdentity]
|
||||
getLinkedIdentity *connect.Client[v1.GetLinkedIdentityRequest, v1.LinkedIdentity]
|
||||
|
|
@ -425,6 +486,31 @@ func (c *userServiceClient) ListUserSettings(ctx context.Context, req *connect.R
|
|||
return c.listUserSettings.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// ListMemoViews calls memos.api.v1.UserService.ListMemoViews.
|
||||
func (c *userServiceClient) ListMemoViews(ctx context.Context, req *connect.Request[v1.ListMemoViewsRequest]) (*connect.Response[v1.ListMemoViewsResponse], error) {
|
||||
return c.listMemoViews.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// GetMemoView calls memos.api.v1.UserService.GetMemoView.
|
||||
func (c *userServiceClient) GetMemoView(ctx context.Context, req *connect.Request[v1.GetMemoViewRequest]) (*connect.Response[v1.MemoView], error) {
|
||||
return c.getMemoView.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// CreateMemoView calls memos.api.v1.UserService.CreateMemoView.
|
||||
func (c *userServiceClient) CreateMemoView(ctx context.Context, req *connect.Request[v1.CreateMemoViewRequest]) (*connect.Response[v1.MemoView], error) {
|
||||
return c.createMemoView.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// UpdateMemoView calls memos.api.v1.UserService.UpdateMemoView.
|
||||
func (c *userServiceClient) UpdateMemoView(ctx context.Context, req *connect.Request[v1.UpdateMemoViewRequest]) (*connect.Response[v1.MemoView], error) {
|
||||
return c.updateMemoView.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// DeleteMemoView calls memos.api.v1.UserService.DeleteMemoView.
|
||||
func (c *userServiceClient) DeleteMemoView(ctx context.Context, req *connect.Request[v1.DeleteMemoViewRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return c.deleteMemoView.CallUnary(ctx, req)
|
||||
}
|
||||
|
||||
// ListLinkedIdentities calls memos.api.v1.UserService.ListLinkedIdentities.
|
||||
func (c *userServiceClient) ListLinkedIdentities(ctx context.Context, req *connect.Request[v1.ListLinkedIdentitiesRequest]) (*connect.Response[v1.ListLinkedIdentitiesResponse], error) {
|
||||
return c.listLinkedIdentities.CallUnary(ctx, req)
|
||||
|
|
@ -525,6 +611,18 @@ type UserServiceHandler interface {
|
|||
UpdateUserSetting(context.Context, *connect.Request[v1.UpdateUserSettingRequest]) (*connect.Response[v1.UserSetting], error)
|
||||
// ListUserSettings returns a list of user settings.
|
||||
ListUserSettings(context.Context, *connect.Request[v1.ListUserSettingsRequest]) (*connect.Response[v1.ListUserSettingsResponse], error)
|
||||
// ListMemoViews returns a user's memo views. Each view is a named, reusable
|
||||
// CEL filter (see MemoView.filter); pass its filter string directly to the
|
||||
// ListMemos `filter` argument.
|
||||
ListMemoViews(context.Context, *connect.Request[v1.ListMemoViewsRequest]) (*connect.Response[v1.ListMemoViewsResponse], error)
|
||||
// GetMemoView gets a memo view by name.
|
||||
GetMemoView(context.Context, *connect.Request[v1.GetMemoViewRequest]) (*connect.Response[v1.MemoView], error)
|
||||
// CreateMemoView creates a new memo view for a user.
|
||||
CreateMemoView(context.Context, *connect.Request[v1.CreateMemoViewRequest]) (*connect.Response[v1.MemoView], error)
|
||||
// UpdateMemoView updates a memo view for a user.
|
||||
UpdateMemoView(context.Context, *connect.Request[v1.UpdateMemoViewRequest]) (*connect.Response[v1.MemoView], error)
|
||||
// DeleteMemoView deletes a memo view for a user.
|
||||
DeleteMemoView(context.Context, *connect.Request[v1.DeleteMemoViewRequest]) (*connect.Response[emptypb.Empty], error)
|
||||
// ListLinkedIdentities returns a list of linked SSO identities for a user.
|
||||
ListLinkedIdentities(context.Context, *connect.Request[v1.ListLinkedIdentitiesRequest]) (*connect.Response[v1.ListLinkedIdentitiesResponse], error)
|
||||
// CreateLinkedIdentity links an SSO identity to the authenticated user.
|
||||
|
|
@ -634,6 +732,36 @@ func NewUserServiceHandler(svc UserServiceHandler, opts ...connect.HandlerOption
|
|||
connect.WithSchema(userServiceMethods.ByName("ListUserSettings")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
userServiceListMemoViewsHandler := connect.NewUnaryHandler(
|
||||
UserServiceListMemoViewsProcedure,
|
||||
svc.ListMemoViews,
|
||||
connect.WithSchema(userServiceMethods.ByName("ListMemoViews")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
userServiceGetMemoViewHandler := connect.NewUnaryHandler(
|
||||
UserServiceGetMemoViewProcedure,
|
||||
svc.GetMemoView,
|
||||
connect.WithSchema(userServiceMethods.ByName("GetMemoView")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
userServiceCreateMemoViewHandler := connect.NewUnaryHandler(
|
||||
UserServiceCreateMemoViewProcedure,
|
||||
svc.CreateMemoView,
|
||||
connect.WithSchema(userServiceMethods.ByName("CreateMemoView")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
userServiceUpdateMemoViewHandler := connect.NewUnaryHandler(
|
||||
UserServiceUpdateMemoViewProcedure,
|
||||
svc.UpdateMemoView,
|
||||
connect.WithSchema(userServiceMethods.ByName("UpdateMemoView")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
userServiceDeleteMemoViewHandler := connect.NewUnaryHandler(
|
||||
UserServiceDeleteMemoViewProcedure,
|
||||
svc.DeleteMemoView,
|
||||
connect.WithSchema(userServiceMethods.ByName("DeleteMemoView")),
|
||||
connect.WithHandlerOptions(opts...),
|
||||
)
|
||||
userServiceListLinkedIdentitiesHandler := connect.NewUnaryHandler(
|
||||
UserServiceListLinkedIdentitiesProcedure,
|
||||
svc.ListLinkedIdentities,
|
||||
|
|
@ -748,6 +876,16 @@ func NewUserServiceHandler(svc UserServiceHandler, opts ...connect.HandlerOption
|
|||
userServiceUpdateUserSettingHandler.ServeHTTP(w, r)
|
||||
case UserServiceListUserSettingsProcedure:
|
||||
userServiceListUserSettingsHandler.ServeHTTP(w, r)
|
||||
case UserServiceListMemoViewsProcedure:
|
||||
userServiceListMemoViewsHandler.ServeHTTP(w, r)
|
||||
case UserServiceGetMemoViewProcedure:
|
||||
userServiceGetMemoViewHandler.ServeHTTP(w, r)
|
||||
case UserServiceCreateMemoViewProcedure:
|
||||
userServiceCreateMemoViewHandler.ServeHTTP(w, r)
|
||||
case UserServiceUpdateMemoViewProcedure:
|
||||
userServiceUpdateMemoViewHandler.ServeHTTP(w, r)
|
||||
case UserServiceDeleteMemoViewProcedure:
|
||||
userServiceDeleteMemoViewHandler.ServeHTTP(w, r)
|
||||
case UserServiceListLinkedIdentitiesProcedure:
|
||||
userServiceListLinkedIdentitiesHandler.ServeHTTP(w, r)
|
||||
case UserServiceCreateLinkedIdentityProcedure:
|
||||
|
|
@ -831,6 +969,26 @@ func (UnimplementedUserServiceHandler) ListUserSettings(context.Context, *connec
|
|||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.ListUserSettings is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServiceHandler) ListMemoViews(context.Context, *connect.Request[v1.ListMemoViewsRequest]) (*connect.Response[v1.ListMemoViewsResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.ListMemoViews is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServiceHandler) GetMemoView(context.Context, *connect.Request[v1.GetMemoViewRequest]) (*connect.Response[v1.MemoView], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.GetMemoView is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServiceHandler) CreateMemoView(context.Context, *connect.Request[v1.CreateMemoViewRequest]) (*connect.Response[v1.MemoView], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.CreateMemoView is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServiceHandler) UpdateMemoView(context.Context, *connect.Request[v1.UpdateMemoViewRequest]) (*connect.Response[v1.MemoView], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.UpdateMemoView is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServiceHandler) DeleteMemoView(context.Context, *connect.Request[v1.DeleteMemoViewRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.DeleteMemoView is not implemented"))
|
||||
}
|
||||
|
||||
func (UnimplementedUserServiceHandler) ListLinkedIdentities(context.Context, *connect.Request[v1.ListLinkedIdentitiesRequest]) (*connect.Response[v1.ListLinkedIdentitiesResponse], error) {
|
||||
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.ListLinkedIdentities is not implemented"))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -770,6 +770,264 @@ func (x *CreateAttachmentRequest) GetAttachmentId() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
type UploadAttachmentRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Required. Start a new upload or continue an existing one.
|
||||
//
|
||||
// Types that are valid to be assigned to Upload:
|
||||
//
|
||||
// *UploadAttachmentRequest_Spec
|
||||
// *UploadAttachmentRequest_UploadId
|
||||
Upload isUploadAttachmentRequest_Upload `protobuf_oneof:"upload"`
|
||||
// Required. Zero-based byte offset at which data is written. Must equal the
|
||||
// committed size, except when retrying the most recently accepted chunk
|
||||
// with identical bytes and offset, which is accepted without writing again.
|
||||
WriteOffset int64 `protobuf:"varint,3,opt,name=write_offset,json=writeOffset,proto3" json:"write_offset,omitempty"`
|
||||
// Optional. File bytes, at most max_chunk_size long. With no data and
|
||||
// finish_write false, the call reports progress without writing, and
|
||||
// write_offset is ignored.
|
||||
Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
|
||||
// Optional. Finalize the upload after writing data. The committed size must
|
||||
// then equal total_size. Any later call for the same upload_id returns the
|
||||
// created attachment.
|
||||
FinishWrite bool `protobuf:"varint,5,opt,name=finish_write,json=finishWrite,proto3" json:"finish_write,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentRequest) Reset() {
|
||||
*x = UploadAttachmentRequest{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[8]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UploadAttachmentRequest) ProtoMessage() {}
|
||||
|
||||
func (x *UploadAttachmentRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[8]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UploadAttachmentRequest.ProtoReflect.Descriptor instead.
|
||||
func (*UploadAttachmentRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{8}
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentRequest) GetUpload() isUploadAttachmentRequest_Upload {
|
||||
if x != nil {
|
||||
return x.Upload
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentRequest) GetSpec() *UploadAttachmentSpec {
|
||||
if x != nil {
|
||||
if x, ok := x.Upload.(*UploadAttachmentRequest_Spec); ok {
|
||||
return x.Spec
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentRequest) GetUploadId() string {
|
||||
if x != nil {
|
||||
if x, ok := x.Upload.(*UploadAttachmentRequest_UploadId); ok {
|
||||
return x.UploadId
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentRequest) GetWriteOffset() int64 {
|
||||
if x != nil {
|
||||
return x.WriteOffset
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentRequest) GetData() []byte {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentRequest) GetFinishWrite() bool {
|
||||
if x != nil {
|
||||
return x.FinishWrite
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type isUploadAttachmentRequest_Upload interface {
|
||||
isUploadAttachmentRequest_Upload()
|
||||
}
|
||||
|
||||
type UploadAttachmentRequest_Spec struct {
|
||||
// Starts a new upload. The same call may also carry data and finish_write.
|
||||
Spec *UploadAttachmentSpec `protobuf:"bytes,1,opt,name=spec,proto3,oneof"`
|
||||
}
|
||||
|
||||
type UploadAttachmentRequest_UploadId struct {
|
||||
// Continues the upload identified by a previous response.
|
||||
UploadId string `protobuf:"bytes,2,opt,name=upload_id,json=uploadId,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*UploadAttachmentRequest_Spec) isUploadAttachmentRequest_Upload() {}
|
||||
|
||||
func (*UploadAttachmentRequest_UploadId) isUploadAttachmentRequest_Upload() {}
|
||||
|
||||
type UploadAttachmentSpec struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Required. Metadata for the attachment to create. content must be empty;
|
||||
// file bytes are sent in data.
|
||||
Attachment *Attachment `protobuf:"bytes,1,opt,name=attachment,proto3" json:"attachment,omitempty"`
|
||||
// Optional. The attachment ID to use for this attachment.
|
||||
// If empty, a unique ID will be generated.
|
||||
// Format: ^[a-zA-Z0-9]([a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?$
|
||||
AttachmentId string `protobuf:"bytes,2,opt,name=attachment_id,json=attachmentId,proto3" json:"attachment_id,omitempty"`
|
||||
// Optional. Total size of the file in bytes before media processing.
|
||||
// Zero represents an empty file.
|
||||
TotalSize int64 `protobuf:"varint,3,opt,name=total_size,json=totalSize,proto3" json:"total_size,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentSpec) Reset() {
|
||||
*x = UploadAttachmentSpec{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[9]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentSpec) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UploadAttachmentSpec) ProtoMessage() {}
|
||||
|
||||
func (x *UploadAttachmentSpec) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[9]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UploadAttachmentSpec.ProtoReflect.Descriptor instead.
|
||||
func (*UploadAttachmentSpec) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{9}
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentSpec) GetAttachment() *Attachment {
|
||||
if x != nil {
|
||||
return x.Attachment
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentSpec) GetAttachmentId() string {
|
||||
if x != nil {
|
||||
return x.AttachmentId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentSpec) GetTotalSize() int64 {
|
||||
if x != nil {
|
||||
return x.TotalSize
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type UploadAttachmentResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Opaque ID for subsequent calls. This is not a resource name.
|
||||
UploadId string `protobuf:"bytes,1,opt,name=upload_id,json=uploadId,proto3" json:"upload_id,omitempty"`
|
||||
// Number of file bytes committed so far.
|
||||
CommittedSize int64 `protobuf:"varint,2,opt,name=committed_size,json=committedSize,proto3" json:"committed_size,omitempty"`
|
||||
// Set once the upload has been finalized.
|
||||
Attachment *Attachment `protobuf:"bytes,3,opt,name=attachment,proto3" json:"attachment,omitempty"`
|
||||
// Maximum number of data bytes accepted in one call.
|
||||
MaxChunkSize int32 `protobuf:"varint,4,opt,name=max_chunk_size,json=maxChunkSize,proto3" json:"max_chunk_size,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentResponse) Reset() {
|
||||
*x = UploadAttachmentResponse{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[10]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UploadAttachmentResponse) ProtoMessage() {}
|
||||
|
||||
func (x *UploadAttachmentResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[10]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UploadAttachmentResponse.ProtoReflect.Descriptor instead.
|
||||
func (*UploadAttachmentResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{10}
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentResponse) GetUploadId() string {
|
||||
if x != nil {
|
||||
return x.UploadId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentResponse) GetCommittedSize() int64 {
|
||||
if x != nil {
|
||||
return x.CommittedSize
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentResponse) GetAttachment() *Attachment {
|
||||
if x != nil {
|
||||
return x.Attachment
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *UploadAttachmentResponse) GetMaxChunkSize() int32 {
|
||||
if x != nil {
|
||||
return x.MaxChunkSize
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type ListAttachmentsRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Optional. The maximum number of attachments to return.
|
||||
|
|
@ -798,7 +1056,7 @@ type ListAttachmentsRequest struct {
|
|||
|
||||
func (x *ListAttachmentsRequest) Reset() {
|
||||
*x = ListAttachmentsRequest{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[8]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[11]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -810,7 +1068,7 @@ func (x *ListAttachmentsRequest) String() string {
|
|||
func (*ListAttachmentsRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ListAttachmentsRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[8]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[11]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -823,7 +1081,7 @@ func (x *ListAttachmentsRequest) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use ListAttachmentsRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ListAttachmentsRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{8}
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{11}
|
||||
}
|
||||
|
||||
func (x *ListAttachmentsRequest) GetPageSize() int32 {
|
||||
|
|
@ -867,7 +1125,7 @@ type ListAttachmentsResponse struct {
|
|||
|
||||
func (x *ListAttachmentsResponse) Reset() {
|
||||
*x = ListAttachmentsResponse{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[9]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[12]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -879,7 +1137,7 @@ func (x *ListAttachmentsResponse) String() string {
|
|||
func (*ListAttachmentsResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ListAttachmentsResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[9]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[12]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -892,7 +1150,7 @@ func (x *ListAttachmentsResponse) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use ListAttachmentsResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ListAttachmentsResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{9}
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{12}
|
||||
}
|
||||
|
||||
func (x *ListAttachmentsResponse) GetAttachments() []*Attachment {
|
||||
|
|
@ -920,7 +1178,7 @@ type GetAttachmentRequest struct {
|
|||
|
||||
func (x *GetAttachmentRequest) Reset() {
|
||||
*x = GetAttachmentRequest{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[10]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[13]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -932,7 +1190,7 @@ func (x *GetAttachmentRequest) String() string {
|
|||
func (*GetAttachmentRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetAttachmentRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[10]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[13]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -945,7 +1203,7 @@ func (x *GetAttachmentRequest) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use GetAttachmentRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetAttachmentRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{10}
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{13}
|
||||
}
|
||||
|
||||
func (x *GetAttachmentRequest) GetName() string {
|
||||
|
|
@ -967,7 +1225,7 @@ type UpdateAttachmentRequest struct {
|
|||
|
||||
func (x *UpdateAttachmentRequest) Reset() {
|
||||
*x = UpdateAttachmentRequest{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[11]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[14]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -979,7 +1237,7 @@ func (x *UpdateAttachmentRequest) String() string {
|
|||
func (*UpdateAttachmentRequest) ProtoMessage() {}
|
||||
|
||||
func (x *UpdateAttachmentRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[11]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[14]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -992,7 +1250,7 @@ func (x *UpdateAttachmentRequest) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use UpdateAttachmentRequest.ProtoReflect.Descriptor instead.
|
||||
func (*UpdateAttachmentRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{11}
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{14}
|
||||
}
|
||||
|
||||
func (x *UpdateAttachmentRequest) GetAttachment() *Attachment {
|
||||
|
|
@ -1020,7 +1278,7 @@ type DeleteAttachmentRequest struct {
|
|||
|
||||
func (x *DeleteAttachmentRequest) Reset() {
|
||||
*x = DeleteAttachmentRequest{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[12]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[15]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -1032,7 +1290,7 @@ func (x *DeleteAttachmentRequest) String() string {
|
|||
func (*DeleteAttachmentRequest) ProtoMessage() {}
|
||||
|
||||
func (x *DeleteAttachmentRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[12]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[15]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -1045,7 +1303,7 @@ func (x *DeleteAttachmentRequest) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use DeleteAttachmentRequest.ProtoReflect.Descriptor instead.
|
||||
func (*DeleteAttachmentRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{12}
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{15}
|
||||
}
|
||||
|
||||
func (x *DeleteAttachmentRequest) GetName() string {
|
||||
|
|
@ -1064,7 +1322,7 @@ type BatchDeleteAttachmentsRequest struct {
|
|||
|
||||
func (x *BatchDeleteAttachmentsRequest) Reset() {
|
||||
*x = BatchDeleteAttachmentsRequest{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[13]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[16]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -1076,7 +1334,7 @@ func (x *BatchDeleteAttachmentsRequest) String() string {
|
|||
func (*BatchDeleteAttachmentsRequest) ProtoMessage() {}
|
||||
|
||||
func (x *BatchDeleteAttachmentsRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[13]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[16]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -1089,7 +1347,7 @@ func (x *BatchDeleteAttachmentsRequest) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use BatchDeleteAttachmentsRequest.ProtoReflect.Descriptor instead.
|
||||
func (*BatchDeleteAttachmentsRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{13}
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{16}
|
||||
}
|
||||
|
||||
func (x *BatchDeleteAttachmentsRequest) GetNames() []string {
|
||||
|
|
@ -1174,7 +1432,28 @@ const file_api_v1_attachment_service_proto_rawDesc = "" +
|
|||
"\n" +
|
||||
"attachment\x18\x01 \x01(\v2\x18.memos.api.v1.AttachmentB\x03\xe0A\x02R\n" +
|
||||
"attachment\x12(\n" +
|
||||
"\rattachment_id\x18\x02 \x01(\tB\x03\xe0A\x01R\fattachmentId\"\xba\x01\n" +
|
||||
"\rattachment_id\x18\x02 \x01(\tB\x03\xe0A\x01R\fattachmentId\"\xe5\x01\n" +
|
||||
"\x17UploadAttachmentRequest\x128\n" +
|
||||
"\x04spec\x18\x01 \x01(\v2\".memos.api.v1.UploadAttachmentSpecH\x00R\x04spec\x12\x1d\n" +
|
||||
"\tupload_id\x18\x02 \x01(\tH\x00R\buploadId\x12&\n" +
|
||||
"\fwrite_offset\x18\x03 \x01(\x03B\x03\xe0A\x02R\vwriteOffset\x12\x17\n" +
|
||||
"\x04data\x18\x04 \x01(\fB\x03\xe0A\x01R\x04data\x12&\n" +
|
||||
"\ffinish_write\x18\x05 \x01(\bB\x03\xe0A\x01R\vfinishWriteB\b\n" +
|
||||
"\x06upload\"\xa3\x01\n" +
|
||||
"\x14UploadAttachmentSpec\x12=\n" +
|
||||
"\n" +
|
||||
"attachment\x18\x01 \x01(\v2\x18.memos.api.v1.AttachmentB\x03\xe0A\x02R\n" +
|
||||
"attachment\x12(\n" +
|
||||
"\rattachment_id\x18\x02 \x01(\tB\x03\xe0A\x01R\fattachmentId\x12\"\n" +
|
||||
"\n" +
|
||||
"total_size\x18\x03 \x01(\x03B\x03\xe0A\x01R\ttotalSize\"\xbe\x01\n" +
|
||||
"\x18UploadAttachmentResponse\x12\x1b\n" +
|
||||
"\tupload_id\x18\x01 \x01(\tR\buploadId\x12%\n" +
|
||||
"\x0ecommitted_size\x18\x02 \x01(\x03R\rcommittedSize\x128\n" +
|
||||
"\n" +
|
||||
"attachment\x18\x03 \x01(\v2\x18.memos.api.v1.AttachmentR\n" +
|
||||
"attachment\x12$\n" +
|
||||
"\x0emax_chunk_size\x18\x04 \x01(\x05R\fmaxChunkSize\"\xba\x01\n" +
|
||||
"\x16ListAttachmentsRequest\x12 \n" +
|
||||
"\tpage_size\x18\x01 \x01(\x05B\x03\xe0A\x01R\bpageSize\x12\"\n" +
|
||||
"\n" +
|
||||
|
|
@ -1207,11 +1486,12 @@ const file_api_v1_attachment_service_proto_rawDesc = "" +
|
|||
"\x1dMOTION_MEDIA_ROLE_UNSPECIFIED\x10\x00\x12\t\n" +
|
||||
"\x05STILL\x10\x01\x12\t\n" +
|
||||
"\x05VIDEO\x10\x02\x12\r\n" +
|
||||
"\tCONTAINER\x10\x032\xd0\x06\n" +
|
||||
"\tCONTAINER\x10\x032\xdb\a\n" +
|
||||
"\x11AttachmentService\x12\x89\x01\n" +
|
||||
"\x10CreateAttachment\x12%.memos.api.v1.CreateAttachmentRequest\x1a\x18.memos.api.v1.Attachment\"4\xdaA\n" +
|
||||
"attachment\x82\xd3\xe4\x93\x02!:\n" +
|
||||
"attachment\"\x13/api/v1/attachments\x12{\n" +
|
||||
"attachment\"\x13/api/v1/attachments\x12\x88\x01\n" +
|
||||
"\x10UploadAttachment\x12%.memos.api.v1.UploadAttachmentRequest\x1a&.memos.api.v1.UploadAttachmentResponse\"%\x82\xd3\xe4\x93\x02\x1f:\x01*\"\x1a/api/v1/attachments:upload\x12{\n" +
|
||||
"\x0fListAttachments\x12$.memos.api.v1.ListAttachmentsRequest\x1a%.memos.api.v1.ListAttachmentsResponse\"\x1b\x82\xd3\xe4\x93\x02\x15\x12\x13/api/v1/attachments\x12z\n" +
|
||||
"\rGetAttachment\x12\".memos.api.v1.GetAttachmentRequest\x1a\x18.memos.api.v1.Attachment\"+\xdaA\x04name\x82\xd3\xe4\x93\x02\x1e\x12\x1c/api/v1/{name=attachments/*}\x12\xa9\x01\n" +
|
||||
"\x10UpdateAttachment\x12%.memos.api.v1.UpdateAttachmentRequest\x1a\x18.memos.api.v1.Attachment\"T\xdaA\x16attachment,update_mask\x82\xd3\xe4\x93\x025:\n" +
|
||||
|
|
@ -1233,7 +1513,7 @@ func file_api_v1_attachment_service_proto_rawDescGZIP() []byte {
|
|||
}
|
||||
|
||||
var file_api_v1_attachment_service_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
||||
var file_api_v1_attachment_service_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
|
||||
var file_api_v1_attachment_service_proto_msgTypes = make([]protoimpl.MessageInfo, 17)
|
||||
var file_api_v1_attachment_service_proto_goTypes = []any{
|
||||
(MotionMediaFamily)(0), // 0: memos.api.v1.MotionMediaFamily
|
||||
(MotionMediaRole)(0), // 1: memos.api.v1.MotionMediaRole
|
||||
|
|
@ -1245,15 +1525,18 @@ var file_api_v1_attachment_service_proto_goTypes = []any{
|
|||
(*VideoMetadata)(nil), // 7: memos.api.v1.VideoMetadata
|
||||
(*Attachment)(nil), // 8: memos.api.v1.Attachment
|
||||
(*CreateAttachmentRequest)(nil), // 9: memos.api.v1.CreateAttachmentRequest
|
||||
(*ListAttachmentsRequest)(nil), // 10: memos.api.v1.ListAttachmentsRequest
|
||||
(*ListAttachmentsResponse)(nil), // 11: memos.api.v1.ListAttachmentsResponse
|
||||
(*GetAttachmentRequest)(nil), // 12: memos.api.v1.GetAttachmentRequest
|
||||
(*UpdateAttachmentRequest)(nil), // 13: memos.api.v1.UpdateAttachmentRequest
|
||||
(*DeleteAttachmentRequest)(nil), // 14: memos.api.v1.DeleteAttachmentRequest
|
||||
(*BatchDeleteAttachmentsRequest)(nil), // 15: memos.api.v1.BatchDeleteAttachmentsRequest
|
||||
(*timestamppb.Timestamp)(nil), // 16: google.protobuf.Timestamp
|
||||
(*fieldmaskpb.FieldMask)(nil), // 17: google.protobuf.FieldMask
|
||||
(*emptypb.Empty)(nil), // 18: google.protobuf.Empty
|
||||
(*UploadAttachmentRequest)(nil), // 10: memos.api.v1.UploadAttachmentRequest
|
||||
(*UploadAttachmentSpec)(nil), // 11: memos.api.v1.UploadAttachmentSpec
|
||||
(*UploadAttachmentResponse)(nil), // 12: memos.api.v1.UploadAttachmentResponse
|
||||
(*ListAttachmentsRequest)(nil), // 13: memos.api.v1.ListAttachmentsRequest
|
||||
(*ListAttachmentsResponse)(nil), // 14: memos.api.v1.ListAttachmentsResponse
|
||||
(*GetAttachmentRequest)(nil), // 15: memos.api.v1.GetAttachmentRequest
|
||||
(*UpdateAttachmentRequest)(nil), // 16: memos.api.v1.UpdateAttachmentRequest
|
||||
(*DeleteAttachmentRequest)(nil), // 17: memos.api.v1.DeleteAttachmentRequest
|
||||
(*BatchDeleteAttachmentsRequest)(nil), // 18: memos.api.v1.BatchDeleteAttachmentsRequest
|
||||
(*timestamppb.Timestamp)(nil), // 19: google.protobuf.Timestamp
|
||||
(*fieldmaskpb.FieldMask)(nil), // 20: google.protobuf.FieldMask
|
||||
(*emptypb.Empty)(nil), // 21: google.protobuf.Empty
|
||||
}
|
||||
var file_api_v1_attachment_service_proto_depIdxs = []int32{
|
||||
0, // 0: memos.api.v1.MotionMedia.family:type_name -> memos.api.v1.MotionMediaFamily
|
||||
|
|
@ -1262,30 +1545,35 @@ var file_api_v1_attachment_service_proto_depIdxs = []int32{
|
|||
7, // 3: memos.api.v1.MediaMetadata.video:type_name -> memos.api.v1.VideoMetadata
|
||||
5, // 4: memos.api.v1.PhotoMetadata.capture_time:type_name -> memos.api.v1.MediaCaptureTime
|
||||
6, // 5: memos.api.v1.PhotoMetadata.location:type_name -> memos.api.v1.MediaLocation
|
||||
16, // 6: memos.api.v1.Attachment.create_time:type_name -> google.protobuf.Timestamp
|
||||
19, // 6: memos.api.v1.Attachment.create_time:type_name -> google.protobuf.Timestamp
|
||||
2, // 7: memos.api.v1.Attachment.motion_media:type_name -> memos.api.v1.MotionMedia
|
||||
3, // 8: memos.api.v1.Attachment.media_metadata:type_name -> memos.api.v1.MediaMetadata
|
||||
8, // 9: memos.api.v1.CreateAttachmentRequest.attachment:type_name -> memos.api.v1.Attachment
|
||||
8, // 10: memos.api.v1.ListAttachmentsResponse.attachments:type_name -> memos.api.v1.Attachment
|
||||
8, // 11: memos.api.v1.UpdateAttachmentRequest.attachment:type_name -> memos.api.v1.Attachment
|
||||
17, // 12: memos.api.v1.UpdateAttachmentRequest.update_mask:type_name -> google.protobuf.FieldMask
|
||||
9, // 13: memos.api.v1.AttachmentService.CreateAttachment:input_type -> memos.api.v1.CreateAttachmentRequest
|
||||
10, // 14: memos.api.v1.AttachmentService.ListAttachments:input_type -> memos.api.v1.ListAttachmentsRequest
|
||||
12, // 15: memos.api.v1.AttachmentService.GetAttachment:input_type -> memos.api.v1.GetAttachmentRequest
|
||||
13, // 16: memos.api.v1.AttachmentService.UpdateAttachment:input_type -> memos.api.v1.UpdateAttachmentRequest
|
||||
14, // 17: memos.api.v1.AttachmentService.DeleteAttachment:input_type -> memos.api.v1.DeleteAttachmentRequest
|
||||
15, // 18: memos.api.v1.AttachmentService.BatchDeleteAttachments:input_type -> memos.api.v1.BatchDeleteAttachmentsRequest
|
||||
8, // 19: memos.api.v1.AttachmentService.CreateAttachment:output_type -> memos.api.v1.Attachment
|
||||
11, // 20: memos.api.v1.AttachmentService.ListAttachments:output_type -> memos.api.v1.ListAttachmentsResponse
|
||||
8, // 21: memos.api.v1.AttachmentService.GetAttachment:output_type -> memos.api.v1.Attachment
|
||||
8, // 22: memos.api.v1.AttachmentService.UpdateAttachment:output_type -> memos.api.v1.Attachment
|
||||
18, // 23: memos.api.v1.AttachmentService.DeleteAttachment:output_type -> google.protobuf.Empty
|
||||
18, // 24: memos.api.v1.AttachmentService.BatchDeleteAttachments:output_type -> google.protobuf.Empty
|
||||
19, // [19:25] is the sub-list for method output_type
|
||||
13, // [13:19] is the sub-list for method input_type
|
||||
13, // [13:13] is the sub-list for extension type_name
|
||||
13, // [13:13] is the sub-list for extension extendee
|
||||
0, // [0:13] is the sub-list for field type_name
|
||||
11, // 10: memos.api.v1.UploadAttachmentRequest.spec:type_name -> memos.api.v1.UploadAttachmentSpec
|
||||
8, // 11: memos.api.v1.UploadAttachmentSpec.attachment:type_name -> memos.api.v1.Attachment
|
||||
8, // 12: memos.api.v1.UploadAttachmentResponse.attachment:type_name -> memos.api.v1.Attachment
|
||||
8, // 13: memos.api.v1.ListAttachmentsResponse.attachments:type_name -> memos.api.v1.Attachment
|
||||
8, // 14: memos.api.v1.UpdateAttachmentRequest.attachment:type_name -> memos.api.v1.Attachment
|
||||
20, // 15: memos.api.v1.UpdateAttachmentRequest.update_mask:type_name -> google.protobuf.FieldMask
|
||||
9, // 16: memos.api.v1.AttachmentService.CreateAttachment:input_type -> memos.api.v1.CreateAttachmentRequest
|
||||
10, // 17: memos.api.v1.AttachmentService.UploadAttachment:input_type -> memos.api.v1.UploadAttachmentRequest
|
||||
13, // 18: memos.api.v1.AttachmentService.ListAttachments:input_type -> memos.api.v1.ListAttachmentsRequest
|
||||
15, // 19: memos.api.v1.AttachmentService.GetAttachment:input_type -> memos.api.v1.GetAttachmentRequest
|
||||
16, // 20: memos.api.v1.AttachmentService.UpdateAttachment:input_type -> memos.api.v1.UpdateAttachmentRequest
|
||||
17, // 21: memos.api.v1.AttachmentService.DeleteAttachment:input_type -> memos.api.v1.DeleteAttachmentRequest
|
||||
18, // 22: memos.api.v1.AttachmentService.BatchDeleteAttachments:input_type -> memos.api.v1.BatchDeleteAttachmentsRequest
|
||||
8, // 23: memos.api.v1.AttachmentService.CreateAttachment:output_type -> memos.api.v1.Attachment
|
||||
12, // 24: memos.api.v1.AttachmentService.UploadAttachment:output_type -> memos.api.v1.UploadAttachmentResponse
|
||||
14, // 25: memos.api.v1.AttachmentService.ListAttachments:output_type -> memos.api.v1.ListAttachmentsResponse
|
||||
8, // 26: memos.api.v1.AttachmentService.GetAttachment:output_type -> memos.api.v1.Attachment
|
||||
8, // 27: memos.api.v1.AttachmentService.UpdateAttachment:output_type -> memos.api.v1.Attachment
|
||||
21, // 28: memos.api.v1.AttachmentService.DeleteAttachment:output_type -> google.protobuf.Empty
|
||||
21, // 29: memos.api.v1.AttachmentService.BatchDeleteAttachments:output_type -> google.protobuf.Empty
|
||||
23, // [23:30] is the sub-list for method output_type
|
||||
16, // [16:23] is the sub-list for method input_type
|
||||
16, // [16:16] is the sub-list for extension type_name
|
||||
16, // [16:16] is the sub-list for extension extendee
|
||||
0, // [0:16] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_v1_attachment_service_proto_init() }
|
||||
|
|
@ -1302,13 +1590,17 @@ func file_api_v1_attachment_service_proto_init() {
|
|||
file_api_v1_attachment_service_proto_msgTypes[4].OneofWrappers = []any{}
|
||||
file_api_v1_attachment_service_proto_msgTypes[5].OneofWrappers = []any{}
|
||||
file_api_v1_attachment_service_proto_msgTypes[6].OneofWrappers = []any{}
|
||||
file_api_v1_attachment_service_proto_msgTypes[8].OneofWrappers = []any{
|
||||
(*UploadAttachmentRequest_Spec)(nil),
|
||||
(*UploadAttachmentRequest_UploadId)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_v1_attachment_service_proto_rawDesc), len(file_api_v1_attachment_service_proto_rawDesc)),
|
||||
NumEnums: 2,
|
||||
NumMessages: 14,
|
||||
NumMessages: 17,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -76,6 +76,33 @@ func local_request_AttachmentService_CreateAttachment_0(ctx context.Context, mar
|
|||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func request_AttachmentService_UploadAttachment_0(ctx context.Context, marshaler runtime.Marshaler, client AttachmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq UploadAttachmentRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.UploadAttachment(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_AttachmentService_UploadAttachment_0(ctx context.Context, marshaler runtime.Marshaler, server AttachmentServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq UploadAttachmentRequest
|
||||
metadata runtime.ServerMetadata
|
||||
)
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
msg, err := server.UploadAttachment(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
var filter_AttachmentService_ListAttachments_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
|
||||
func request_AttachmentService_ListAttachments_0(ctx context.Context, marshaler runtime.Marshaler, client AttachmentServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
|
|
@ -323,6 +350,26 @@ func RegisterAttachmentServiceHandlerServer(ctx context.Context, mux *runtime.Se
|
|||
}
|
||||
forward_AttachmentService_CreateAttachment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_AttachmentService_UploadAttachment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.AttachmentService/UploadAttachment", runtime.WithHTTPPathPattern("/api/v1/attachments:upload"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_AttachmentService_UploadAttachment_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AttachmentService_UploadAttachment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodGet, pattern_AttachmentService_ListAttachments_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
|
|
@ -480,6 +527,23 @@ func RegisterAttachmentServiceHandlerClient(ctx context.Context, mux *runtime.Se
|
|||
}
|
||||
forward_AttachmentService_CreateAttachment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_AttachmentService_UploadAttachment_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.AttachmentService/UploadAttachment", runtime.WithHTTPPathPattern("/api/v1/attachments:upload"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_AttachmentService_UploadAttachment_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_AttachmentService_UploadAttachment_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodGet, pattern_AttachmentService_ListAttachments_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
|
|
@ -570,6 +634,7 @@ func RegisterAttachmentServiceHandlerClient(ctx context.Context, mux *runtime.Se
|
|||
|
||||
var (
|
||||
pattern_AttachmentService_CreateAttachment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "attachments"}, ""))
|
||||
pattern_AttachmentService_UploadAttachment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "attachments"}, "upload"))
|
||||
pattern_AttachmentService_ListAttachments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "v1", "attachments"}, ""))
|
||||
pattern_AttachmentService_GetAttachment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v1", "attachments", "name"}, ""))
|
||||
pattern_AttachmentService_UpdateAttachment_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3}, []string{"api", "v1", "attachments", "attachment.name"}, ""))
|
||||
|
|
@ -579,6 +644,7 @@ var (
|
|||
|
||||
var (
|
||||
forward_AttachmentService_CreateAttachment_0 = runtime.ForwardResponseMessage
|
||||
forward_AttachmentService_UploadAttachment_0 = runtime.ForwardResponseMessage
|
||||
forward_AttachmentService_ListAttachments_0 = runtime.ForwardResponseMessage
|
||||
forward_AttachmentService_GetAttachment_0 = runtime.ForwardResponseMessage
|
||||
forward_AttachmentService_UpdateAttachment_0 = runtime.ForwardResponseMessage
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ const _ = grpc.SupportPackageIsVersion9
|
|||
|
||||
const (
|
||||
AttachmentService_CreateAttachment_FullMethodName = "/memos.api.v1.AttachmentService/CreateAttachment"
|
||||
AttachmentService_UploadAttachment_FullMethodName = "/memos.api.v1.AttachmentService/UploadAttachment"
|
||||
AttachmentService_ListAttachments_FullMethodName = "/memos.api.v1.AttachmentService/ListAttachments"
|
||||
AttachmentService_GetAttachment_FullMethodName = "/memos.api.v1.AttachmentService/GetAttachment"
|
||||
AttachmentService_UpdateAttachment_FullMethodName = "/memos.api.v1.AttachmentService/UpdateAttachment"
|
||||
|
|
@ -34,6 +35,11 @@ const (
|
|||
type AttachmentServiceClient interface {
|
||||
// CreateAttachment creates a new attachment.
|
||||
CreateAttachment(ctx context.Context, in *CreateAttachmentRequest, opts ...grpc.CallOption) (*Attachment, error)
|
||||
// UploadAttachment uploads a file in bounded chunks. The first call carries
|
||||
// the spec and returns an upload_id; later calls carry that upload_id.
|
||||
// Uploads are bound to the authenticated user, expire after 30 minutes of
|
||||
// inactivity, and do not survive a server restart.
|
||||
UploadAttachment(ctx context.Context, in *UploadAttachmentRequest, opts ...grpc.CallOption) (*UploadAttachmentResponse, error)
|
||||
// ListAttachments lists all attachments.
|
||||
ListAttachments(ctx context.Context, in *ListAttachmentsRequest, opts ...grpc.CallOption) (*ListAttachmentsResponse, error)
|
||||
// GetAttachment returns an attachment by name.
|
||||
|
|
@ -64,6 +70,16 @@ func (c *attachmentServiceClient) CreateAttachment(ctx context.Context, in *Crea
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *attachmentServiceClient) UploadAttachment(ctx context.Context, in *UploadAttachmentRequest, opts ...grpc.CallOption) (*UploadAttachmentResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(UploadAttachmentResponse)
|
||||
err := c.cc.Invoke(ctx, AttachmentService_UploadAttachment_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *attachmentServiceClient) ListAttachments(ctx context.Context, in *ListAttachmentsRequest, opts ...grpc.CallOption) (*ListAttachmentsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListAttachmentsResponse)
|
||||
|
|
@ -120,6 +136,11 @@ func (c *attachmentServiceClient) BatchDeleteAttachments(ctx context.Context, in
|
|||
type AttachmentServiceServer interface {
|
||||
// CreateAttachment creates a new attachment.
|
||||
CreateAttachment(context.Context, *CreateAttachmentRequest) (*Attachment, error)
|
||||
// UploadAttachment uploads a file in bounded chunks. The first call carries
|
||||
// the spec and returns an upload_id; later calls carry that upload_id.
|
||||
// Uploads are bound to the authenticated user, expire after 30 minutes of
|
||||
// inactivity, and do not survive a server restart.
|
||||
UploadAttachment(context.Context, *UploadAttachmentRequest) (*UploadAttachmentResponse, error)
|
||||
// ListAttachments lists all attachments.
|
||||
ListAttachments(context.Context, *ListAttachmentsRequest) (*ListAttachmentsResponse, error)
|
||||
// GetAttachment returns an attachment by name.
|
||||
|
|
@ -143,6 +164,9 @@ type UnimplementedAttachmentServiceServer struct{}
|
|||
func (UnimplementedAttachmentServiceServer) CreateAttachment(context.Context, *CreateAttachmentRequest) (*Attachment, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateAttachment not implemented")
|
||||
}
|
||||
func (UnimplementedAttachmentServiceServer) UploadAttachment(context.Context, *UploadAttachmentRequest) (*UploadAttachmentResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method UploadAttachment not implemented")
|
||||
}
|
||||
func (UnimplementedAttachmentServiceServer) ListAttachments(context.Context, *ListAttachmentsRequest) (*ListAttachmentsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListAttachments not implemented")
|
||||
}
|
||||
|
|
@ -197,6 +221,24 @@ func _AttachmentService_CreateAttachment_Handler(srv interface{}, ctx context.Co
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AttachmentService_UploadAttachment_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UploadAttachmentRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(AttachmentServiceServer).UploadAttachment(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: AttachmentService_UploadAttachment_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(AttachmentServiceServer).UploadAttachment(ctx, req.(*UploadAttachmentRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _AttachmentService_ListAttachments_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListAttachmentsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
|
|
@ -298,6 +340,10 @@ var AttachmentService_ServiceDesc = grpc.ServiceDesc{
|
|||
MethodName: "CreateAttachment",
|
||||
Handler: _AttachmentService_CreateAttachment_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UploadAttachment",
|
||||
Handler: _AttachmentService_UploadAttachment_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListAttachments",
|
||||
Handler: _AttachmentService_ListAttachments_Handler,
|
||||
|
|
|
|||
|
|
@ -246,8 +246,9 @@ type Memo struct {
|
|||
Reactions []*Reaction `protobuf:"bytes,14,rep,name=reactions,proto3" json:"reactions,omitempty"`
|
||||
// Output only. The computed properties of the memo.
|
||||
Property *Memo_Property `protobuf:"bytes,15,opt,name=property,proto3" json:"property,omitempty"`
|
||||
// Output only. The readable context memo of this COMMENT relation, if any.
|
||||
// This is omitted unless the caller may independently read both memos.
|
||||
// Output only. The context memo of this COMMENT relation, if any.
|
||||
// Its identity is returned even when the caller cannot read the parent.
|
||||
// Fetch the parent independently; this field does not grant read access.
|
||||
// Format: memos/{memo}
|
||||
Parent *string `protobuf:"bytes,16,opt,name=parent,proto3,oneof" json:"parent,omitempty"`
|
||||
// Output only. The snippet of the memo content. Plain text only.
|
||||
|
|
|
|||
|
|
@ -1,498 +0,0 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.12
|
||||
// protoc (unknown)
|
||||
// source: api/v1/memo_view_service.proto
|
||||
|
||||
package apiv1
|
||||
|
||||
import (
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
fieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type MemoView struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The resource name of the memo view.
|
||||
// Format: users/{user}/views/{view}
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
// The title of the memo view.
|
||||
Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`
|
||||
// The CEL filter expression for the memo view, using the same grammar as the
|
||||
// ListMemos `filter` argument. Reuse it by passing this value to ListMemos.
|
||||
Filter string `protobuf:"bytes,3,opt,name=filter,proto3" json:"filter,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *MemoView) Reset() {
|
||||
*x = MemoView{}
|
||||
mi := &file_api_v1_memo_view_service_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *MemoView) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*MemoView) ProtoMessage() {}
|
||||
|
||||
func (x *MemoView) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_memo_view_service_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use MemoView.ProtoReflect.Descriptor instead.
|
||||
func (*MemoView) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_memo_view_service_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *MemoView) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MemoView) GetTitle() string {
|
||||
if x != nil {
|
||||
return x.Title
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MemoView) GetFilter() string {
|
||||
if x != nil {
|
||||
return x.Filter
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type ListMemoViewsRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Required. The parent resource where memo views are listed.
|
||||
// Format: users/{user}
|
||||
Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ListMemoViewsRequest) Reset() {
|
||||
*x = ListMemoViewsRequest{}
|
||||
mi := &file_api_v1_memo_view_service_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ListMemoViewsRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListMemoViewsRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ListMemoViewsRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_memo_view_service_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListMemoViewsRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ListMemoViewsRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_memo_view_service_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *ListMemoViewsRequest) GetParent() string {
|
||||
if x != nil {
|
||||
return x.Parent
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type ListMemoViewsResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The list of memo views.
|
||||
MemoViews []*MemoView `protobuf:"bytes,1,rep,name=memo_views,json=memoViews,proto3" json:"memo_views,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *ListMemoViewsResponse) Reset() {
|
||||
*x = ListMemoViewsResponse{}
|
||||
mi := &file_api_v1_memo_view_service_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *ListMemoViewsResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*ListMemoViewsResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ListMemoViewsResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_memo_view_service_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use ListMemoViewsResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ListMemoViewsResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_memo_view_service_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *ListMemoViewsResponse) GetMemoViews() []*MemoView {
|
||||
if x != nil {
|
||||
return x.MemoViews
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type GetMemoViewRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Required. The resource name of the memo view to retrieve.
|
||||
// Format: users/{user}/views/{view}
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GetMemoViewRequest) Reset() {
|
||||
*x = GetMemoViewRequest{}
|
||||
mi := &file_api_v1_memo_view_service_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *GetMemoViewRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*GetMemoViewRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetMemoViewRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_memo_view_service_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use GetMemoViewRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetMemoViewRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_memo_view_service_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *GetMemoViewRequest) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type CreateMemoViewRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Required. The parent resource where this memo view will be created.
|
||||
// Format: users/{user}
|
||||
Parent string `protobuf:"bytes,1,opt,name=parent,proto3" json:"parent,omitempty"`
|
||||
// Required. The memo view to create.
|
||||
MemoView *MemoView `protobuf:"bytes,2,opt,name=memo_view,json=memoView,proto3" json:"memo_view,omitempty"`
|
||||
// Optional. If set, validate the request, but do not actually create the memo view.
|
||||
ValidateOnly bool `protobuf:"varint,3,opt,name=validate_only,json=validateOnly,proto3" json:"validate_only,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *CreateMemoViewRequest) Reset() {
|
||||
*x = CreateMemoViewRequest{}
|
||||
mi := &file_api_v1_memo_view_service_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *CreateMemoViewRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*CreateMemoViewRequest) ProtoMessage() {}
|
||||
|
||||
func (x *CreateMemoViewRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_memo_view_service_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use CreateMemoViewRequest.ProtoReflect.Descriptor instead.
|
||||
func (*CreateMemoViewRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_memo_view_service_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *CreateMemoViewRequest) GetParent() string {
|
||||
if x != nil {
|
||||
return x.Parent
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *CreateMemoViewRequest) GetMemoView() *MemoView {
|
||||
if x != nil {
|
||||
return x.MemoView
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *CreateMemoViewRequest) GetValidateOnly() bool {
|
||||
if x != nil {
|
||||
return x.ValidateOnly
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type UpdateMemoViewRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Required. The memo view resource which replaces the resource on the server.
|
||||
MemoView *MemoView `protobuf:"bytes,1,opt,name=memo_view,json=memoView,proto3" json:"memo_view,omitempty"`
|
||||
// Optional. The list of fields to update.
|
||||
UpdateMask *fieldmaskpb.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *UpdateMemoViewRequest) Reset() {
|
||||
*x = UpdateMemoViewRequest{}
|
||||
mi := &file_api_v1_memo_view_service_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *UpdateMemoViewRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UpdateMemoViewRequest) ProtoMessage() {}
|
||||
|
||||
func (x *UpdateMemoViewRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_memo_view_service_proto_msgTypes[5]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UpdateMemoViewRequest.ProtoReflect.Descriptor instead.
|
||||
func (*UpdateMemoViewRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_memo_view_service_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *UpdateMemoViewRequest) GetMemoView() *MemoView {
|
||||
if x != nil {
|
||||
return x.MemoView
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *UpdateMemoViewRequest) GetUpdateMask() *fieldmaskpb.FieldMask {
|
||||
if x != nil {
|
||||
return x.UpdateMask
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DeleteMemoViewRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Required. The resource name of the memo view to delete.
|
||||
// Format: users/{user}/views/{view}
|
||||
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *DeleteMemoViewRequest) Reset() {
|
||||
*x = DeleteMemoViewRequest{}
|
||||
mi := &file_api_v1_memo_view_service_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *DeleteMemoViewRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DeleteMemoViewRequest) ProtoMessage() {}
|
||||
|
||||
func (x *DeleteMemoViewRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_memo_view_service_proto_msgTypes[6]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DeleteMemoViewRequest.ProtoReflect.Descriptor instead.
|
||||
func (*DeleteMemoViewRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_memo_view_service_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *DeleteMemoViewRequest) GetName() string {
|
||||
if x != nil {
|
||||
return x.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_api_v1_memo_view_service_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_api_v1_memo_view_service_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x1eapi/v1/memo_view_service.proto\x12\fmemos.api.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\"\x9f\x01\n" +
|
||||
"\bMemoView\x12\x17\n" +
|
||||
"\x04name\x18\x01 \x01(\tB\x03\xe0A\bR\x04name\x12\x19\n" +
|
||||
"\x05title\x18\x02 \x01(\tB\x03\xe0A\x02R\x05title\x12\x1b\n" +
|
||||
"\x06filter\x18\x03 \x01(\tB\x03\xe0A\x02R\x06filter:B\xeaA?\n" +
|
||||
"\x15memos.api.v1/MemoView\x12\x19users/{user}/views/{view}*\x05views2\x04view\"M\n" +
|
||||
"\x14ListMemoViewsRequest\x125\n" +
|
||||
"\x06parent\x18\x01 \x01(\tB\x1d\xe0A\x02\xfaA\x17\x12\x15memos.api.v1/MemoViewR\x06parent\"N\n" +
|
||||
"\x15ListMemoViewsResponse\x125\n" +
|
||||
"\n" +
|
||||
"memo_views\x18\x01 \x03(\v2\x16.memos.api.v1.MemoViewR\tmemoViews\"G\n" +
|
||||
"\x12GetMemoViewRequest\x121\n" +
|
||||
"\x04name\x18\x01 \x01(\tB\x1d\xe0A\x02\xfaA\x17\n" +
|
||||
"\x15memos.api.v1/MemoViewR\x04name\"\xb2\x01\n" +
|
||||
"\x15CreateMemoViewRequest\x125\n" +
|
||||
"\x06parent\x18\x01 \x01(\tB\x1d\xe0A\x02\xfaA\x17\x12\x15memos.api.v1/MemoViewR\x06parent\x128\n" +
|
||||
"\tmemo_view\x18\x02 \x01(\v2\x16.memos.api.v1.MemoViewB\x03\xe0A\x02R\bmemoView\x12(\n" +
|
||||
"\rvalidate_only\x18\x03 \x01(\bB\x03\xe0A\x01R\fvalidateOnly\"\x93\x01\n" +
|
||||
"\x15UpdateMemoViewRequest\x128\n" +
|
||||
"\tmemo_view\x18\x01 \x01(\v2\x16.memos.api.v1.MemoViewB\x03\xe0A\x02R\bmemoView\x12@\n" +
|
||||
"\vupdate_mask\x18\x02 \x01(\v2\x1a.google.protobuf.FieldMaskB\x03\xe0A\x01R\n" +
|
||||
"updateMask\"J\n" +
|
||||
"\x15DeleteMemoViewRequest\x121\n" +
|
||||
"\x04name\x18\x01 \x01(\tB\x1d\xe0A\x02\xfaA\x17\n" +
|
||||
"\x15memos.api.v1/MemoViewR\x04name2\xce\x05\n" +
|
||||
"\x0fMemoViewService\x12\x89\x01\n" +
|
||||
"\rListMemoViews\x12\".memos.api.v1.ListMemoViewsRequest\x1a#.memos.api.v1.ListMemoViewsResponse\"/\xdaA\x06parent\x82\xd3\xe4\x93\x02 \x12\x1e/api/v1/{parent=users/*}/views\x12v\n" +
|
||||
"\vGetMemoView\x12 .memos.api.v1.GetMemoViewRequest\x1a\x16.memos.api.v1.MemoView\"-\xdaA\x04name\x82\xd3\xe4\x93\x02 \x12\x1e/api/v1/{name=users/*/views/*}\x12\x93\x01\n" +
|
||||
"\x0eCreateMemoView\x12#.memos.api.v1.CreateMemoViewRequest\x1a\x16.memos.api.v1.MemoView\"D\xdaA\x10parent,memo_view\x82\xd3\xe4\x93\x02+:\tmemo_view\"\x1e/api/v1/{parent=users/*}/views\x12\xa2\x01\n" +
|
||||
"\x0eUpdateMemoView\x12#.memos.api.v1.UpdateMemoViewRequest\x1a\x16.memos.api.v1.MemoView\"S\xdaA\x15memo_view,update_mask\x82\xd3\xe4\x93\x025:\tmemo_view2(/api/v1/{memo_view.name=users/*/views/*}\x12|\n" +
|
||||
"\x0eDeleteMemoView\x12#.memos.api.v1.DeleteMemoViewRequest\x1a\x16.google.protobuf.Empty\"-\xdaA\x04name\x82\xd3\xe4\x93\x02 *\x1e/api/v1/{name=users/*/views/*}B\xac\x01\n" +
|
||||
"\x10com.memos.api.v1B\x14MemoViewServiceProtoP\x01Z0github.com/usememos/memos/proto/gen/api/v1;apiv1\xa2\x02\x03MAX\xaa\x02\fMemos.Api.V1\xca\x02\fMemos\\Api\\V1\xe2\x02\x18Memos\\Api\\V1\\GPBMetadata\xea\x02\x0eMemos::Api::V1b\x06proto3"
|
||||
|
||||
var (
|
||||
file_api_v1_memo_view_service_proto_rawDescOnce sync.Once
|
||||
file_api_v1_memo_view_service_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_api_v1_memo_view_service_proto_rawDescGZIP() []byte {
|
||||
file_api_v1_memo_view_service_proto_rawDescOnce.Do(func() {
|
||||
file_api_v1_memo_view_service_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_api_v1_memo_view_service_proto_rawDesc), len(file_api_v1_memo_view_service_proto_rawDesc)))
|
||||
})
|
||||
return file_api_v1_memo_view_service_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_api_v1_memo_view_service_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
|
||||
var file_api_v1_memo_view_service_proto_goTypes = []any{
|
||||
(*MemoView)(nil), // 0: memos.api.v1.MemoView
|
||||
(*ListMemoViewsRequest)(nil), // 1: memos.api.v1.ListMemoViewsRequest
|
||||
(*ListMemoViewsResponse)(nil), // 2: memos.api.v1.ListMemoViewsResponse
|
||||
(*GetMemoViewRequest)(nil), // 3: memos.api.v1.GetMemoViewRequest
|
||||
(*CreateMemoViewRequest)(nil), // 4: memos.api.v1.CreateMemoViewRequest
|
||||
(*UpdateMemoViewRequest)(nil), // 5: memos.api.v1.UpdateMemoViewRequest
|
||||
(*DeleteMemoViewRequest)(nil), // 6: memos.api.v1.DeleteMemoViewRequest
|
||||
(*fieldmaskpb.FieldMask)(nil), // 7: google.protobuf.FieldMask
|
||||
(*emptypb.Empty)(nil), // 8: google.protobuf.Empty
|
||||
}
|
||||
var file_api_v1_memo_view_service_proto_depIdxs = []int32{
|
||||
0, // 0: memos.api.v1.ListMemoViewsResponse.memo_views:type_name -> memos.api.v1.MemoView
|
||||
0, // 1: memos.api.v1.CreateMemoViewRequest.memo_view:type_name -> memos.api.v1.MemoView
|
||||
0, // 2: memos.api.v1.UpdateMemoViewRequest.memo_view:type_name -> memos.api.v1.MemoView
|
||||
7, // 3: memos.api.v1.UpdateMemoViewRequest.update_mask:type_name -> google.protobuf.FieldMask
|
||||
1, // 4: memos.api.v1.MemoViewService.ListMemoViews:input_type -> memos.api.v1.ListMemoViewsRequest
|
||||
3, // 5: memos.api.v1.MemoViewService.GetMemoView:input_type -> memos.api.v1.GetMemoViewRequest
|
||||
4, // 6: memos.api.v1.MemoViewService.CreateMemoView:input_type -> memos.api.v1.CreateMemoViewRequest
|
||||
5, // 7: memos.api.v1.MemoViewService.UpdateMemoView:input_type -> memos.api.v1.UpdateMemoViewRequest
|
||||
6, // 8: memos.api.v1.MemoViewService.DeleteMemoView:input_type -> memos.api.v1.DeleteMemoViewRequest
|
||||
2, // 9: memos.api.v1.MemoViewService.ListMemoViews:output_type -> memos.api.v1.ListMemoViewsResponse
|
||||
0, // 10: memos.api.v1.MemoViewService.GetMemoView:output_type -> memos.api.v1.MemoView
|
||||
0, // 11: memos.api.v1.MemoViewService.CreateMemoView:output_type -> memos.api.v1.MemoView
|
||||
0, // 12: memos.api.v1.MemoViewService.UpdateMemoView:output_type -> memos.api.v1.MemoView
|
||||
8, // 13: memos.api.v1.MemoViewService.DeleteMemoView:output_type -> google.protobuf.Empty
|
||||
9, // [9:14] is the sub-list for method output_type
|
||||
4, // [4:9] is the sub-list for method input_type
|
||||
4, // [4:4] is the sub-list for extension type_name
|
||||
4, // [4:4] is the sub-list for extension extendee
|
||||
0, // [0:4] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_v1_memo_view_service_proto_init() }
|
||||
func file_api_v1_memo_view_service_proto_init() {
|
||||
if File_api_v1_memo_view_service_proto != nil {
|
||||
return
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_v1_memo_view_service_proto_rawDesc), len(file_api_v1_memo_view_service_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 7,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_api_v1_memo_view_service_proto_goTypes,
|
||||
DependencyIndexes: file_api_v1_memo_view_service_proto_depIdxs,
|
||||
MessageInfos: file_api_v1_memo_view_service_proto_msgTypes,
|
||||
}.Build()
|
||||
File_api_v1_memo_view_service_proto = out.File
|
||||
file_api_v1_memo_view_service_proto_goTypes = nil
|
||||
file_api_v1_memo_view_service_proto_depIdxs = nil
|
||||
}
|
||||
|
|
@ -1,543 +0,0 @@
|
|||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: api/v1/memo_view_service.proto
|
||||
|
||||
/*
|
||||
Package apiv1 is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package apiv1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// Suppress "imported and not used" errors
|
||||
var (
|
||||
_ codes.Code
|
||||
_ io.Reader
|
||||
_ status.Status
|
||||
_ = errors.New
|
||||
_ = runtime.String
|
||||
_ = utilities.NewDoubleArray
|
||||
_ = metadata.Join
|
||||
)
|
||||
|
||||
func request_MemoViewService_ListMemoViews_0(ctx context.Context, marshaler runtime.Marshaler, client MemoViewServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq ListMemoViewsRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
val, ok := pathParams["parent"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent")
|
||||
}
|
||||
protoReq.Parent, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err)
|
||||
}
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.ListMemoViews(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_MemoViewService_ListMemoViews_0(ctx context.Context, marshaler runtime.Marshaler, server MemoViewServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq ListMemoViewsRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
val, ok := pathParams["parent"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent")
|
||||
}
|
||||
protoReq.Parent, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err)
|
||||
}
|
||||
msg, err := server.ListMemoViews(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func request_MemoViewService_GetMemoView_0(ctx context.Context, marshaler runtime.Marshaler, client MemoViewServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq GetMemoViewRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
val, ok := pathParams["name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
|
||||
}
|
||||
protoReq.Name, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
|
||||
}
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.GetMemoView(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_MemoViewService_GetMemoView_0(ctx context.Context, marshaler runtime.Marshaler, server MemoViewServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq GetMemoViewRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
val, ok := pathParams["name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
|
||||
}
|
||||
protoReq.Name, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
|
||||
}
|
||||
msg, err := server.GetMemoView(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
var filter_MemoViewService_CreateMemoView_0 = &utilities.DoubleArray{Encoding: map[string]int{"memo_view": 0, "parent": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}}
|
||||
|
||||
func request_MemoViewService_CreateMemoView_0(ctx context.Context, marshaler runtime.Marshaler, client MemoViewServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq CreateMemoViewRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.MemoView); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
val, ok := pathParams["parent"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent")
|
||||
}
|
||||
protoReq.Parent, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MemoViewService_CreateMemoView_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.CreateMemoView(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_MemoViewService_CreateMemoView_0(ctx context.Context, marshaler runtime.Marshaler, server MemoViewServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq CreateMemoViewRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.MemoView); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
val, ok := pathParams["parent"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent")
|
||||
}
|
||||
protoReq.Parent, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MemoViewService_CreateMemoView_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
msg, err := server.CreateMemoView(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
var filter_MemoViewService_UpdateMemoView_0 = &utilities.DoubleArray{Encoding: map[string]int{"memo_view": 0, "name": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}}
|
||||
|
||||
func request_MemoViewService_UpdateMemoView_0(ctx context.Context, marshaler runtime.Marshaler, client MemoViewServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq UpdateMemoViewRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.MemoView); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {
|
||||
if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.MemoView); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
} else {
|
||||
protoReq.UpdateMask = fieldMask
|
||||
}
|
||||
}
|
||||
val, ok := pathParams["memo_view.name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "memo_view.name")
|
||||
}
|
||||
err = runtime.PopulateFieldFromPath(&protoReq, "memo_view.name", val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "memo_view.name", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MemoViewService_UpdateMemoView_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.UpdateMemoView(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_MemoViewService_UpdateMemoView_0(ctx context.Context, marshaler runtime.Marshaler, server MemoViewServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq UpdateMemoViewRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.MemoView); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {
|
||||
if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.MemoView); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
} else {
|
||||
protoReq.UpdateMask = fieldMask
|
||||
}
|
||||
}
|
||||
val, ok := pathParams["memo_view.name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "memo_view.name")
|
||||
}
|
||||
err = runtime.PopulateFieldFromPath(&protoReq, "memo_view.name", val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "memo_view.name", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_MemoViewService_UpdateMemoView_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
msg, err := server.UpdateMemoView(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func request_MemoViewService_DeleteMemoView_0(ctx context.Context, marshaler runtime.Marshaler, client MemoViewServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq DeleteMemoViewRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
val, ok := pathParams["name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
|
||||
}
|
||||
protoReq.Name, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
|
||||
}
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.DeleteMemoView(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_MemoViewService_DeleteMemoView_0(ctx context.Context, marshaler runtime.Marshaler, server MemoViewServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq DeleteMemoViewRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
val, ok := pathParams["name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
|
||||
}
|
||||
protoReq.Name, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
|
||||
}
|
||||
msg, err := server.DeleteMemoView(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
// RegisterMemoViewServiceHandlerServer registers the http handlers for service MemoViewService to "mux".
|
||||
// UnaryRPC :call MemoViewServiceServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMemoViewServiceHandlerFromEndpoint instead.
|
||||
// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
|
||||
func RegisterMemoViewServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MemoViewServiceServer) error {
|
||||
mux.Handle(http.MethodGet, pattern_MemoViewService_ListMemoViews_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MemoViewService/ListMemoViews", runtime.WithHTTPPathPattern("/api/v1/{parent=users/*}/views"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_MemoViewService_ListMemoViews_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_MemoViewService_ListMemoViews_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodGet, pattern_MemoViewService_GetMemoView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MemoViewService/GetMemoView", runtime.WithHTTPPathPattern("/api/v1/{name=users/*/views/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_MemoViewService_GetMemoView_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_MemoViewService_GetMemoView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_MemoViewService_CreateMemoView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MemoViewService/CreateMemoView", runtime.WithHTTPPathPattern("/api/v1/{parent=users/*}/views"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_MemoViewService_CreateMemoView_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_MemoViewService_CreateMemoView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPatch, pattern_MemoViewService_UpdateMemoView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MemoViewService/UpdateMemoView", runtime.WithHTTPPathPattern("/api/v1/{memo_view.name=users/*/views/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_MemoViewService_UpdateMemoView_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_MemoViewService_UpdateMemoView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodDelete, pattern_MemoViewService_DeleteMemoView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MemoViewService/DeleteMemoView", runtime.WithHTTPPathPattern("/api/v1/{name=users/*/views/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_MemoViewService_DeleteMemoView_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_MemoViewService_DeleteMemoView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterMemoViewServiceHandlerFromEndpoint is same as RegisterMemoViewServiceHandler but
|
||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||
func RegisterMemoViewServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
||||
conn, err := grpc.NewClient(endpoint, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
}()
|
||||
}()
|
||||
return RegisterMemoViewServiceHandler(ctx, mux, conn)
|
||||
}
|
||||
|
||||
// RegisterMemoViewServiceHandler registers the http handlers for service MemoViewService to "mux".
|
||||
// The handlers forward requests to the grpc endpoint over "conn".
|
||||
func RegisterMemoViewServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||
return RegisterMemoViewServiceHandlerClient(ctx, mux, NewMemoViewServiceClient(conn))
|
||||
}
|
||||
|
||||
// RegisterMemoViewServiceHandlerClient registers the http handlers for service MemoViewService
|
||||
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MemoViewServiceClient".
|
||||
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MemoViewServiceClient"
|
||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
||||
// "MemoViewServiceClient" to call the correct interceptors. This client ignores the HTTP middlewares.
|
||||
func RegisterMemoViewServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MemoViewServiceClient) error {
|
||||
mux.Handle(http.MethodGet, pattern_MemoViewService_ListMemoViews_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MemoViewService/ListMemoViews", runtime.WithHTTPPathPattern("/api/v1/{parent=users/*}/views"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_MemoViewService_ListMemoViews_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_MemoViewService_ListMemoViews_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodGet, pattern_MemoViewService_GetMemoView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MemoViewService/GetMemoView", runtime.WithHTTPPathPattern("/api/v1/{name=users/*/views/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_MemoViewService_GetMemoView_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_MemoViewService_GetMemoView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_MemoViewService_CreateMemoView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MemoViewService/CreateMemoView", runtime.WithHTTPPathPattern("/api/v1/{parent=users/*}/views"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_MemoViewService_CreateMemoView_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_MemoViewService_CreateMemoView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPatch, pattern_MemoViewService_UpdateMemoView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MemoViewService/UpdateMemoView", runtime.WithHTTPPathPattern("/api/v1/{memo_view.name=users/*/views/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_MemoViewService_UpdateMemoView_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_MemoViewService_UpdateMemoView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodDelete, pattern_MemoViewService_DeleteMemoView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MemoViewService/DeleteMemoView", runtime.WithHTTPPathPattern("/api/v1/{name=users/*/views/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_MemoViewService_DeleteMemoView_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_MemoViewService_DeleteMemoView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_MemoViewService_ListMemoViews_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3, 2, 4}, []string{"api", "v1", "users", "parent", "views"}, ""))
|
||||
pattern_MemoViewService_GetMemoView_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 2, 3, 1, 0, 4, 4, 5, 4}, []string{"api", "v1", "users", "views", "name"}, ""))
|
||||
pattern_MemoViewService_CreateMemoView_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3, 2, 4}, []string{"api", "v1", "users", "parent", "views"}, ""))
|
||||
pattern_MemoViewService_UpdateMemoView_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 2, 3, 1, 0, 4, 4, 5, 4}, []string{"api", "v1", "users", "views", "memo_view.name"}, ""))
|
||||
pattern_MemoViewService_DeleteMemoView_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 2, 3, 1, 0, 4, 4, 5, 4}, []string{"api", "v1", "users", "views", "name"}, ""))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_MemoViewService_ListMemoViews_0 = runtime.ForwardResponseMessage
|
||||
forward_MemoViewService_GetMemoView_0 = runtime.ForwardResponseMessage
|
||||
forward_MemoViewService_CreateMemoView_0 = runtime.ForwardResponseMessage
|
||||
forward_MemoViewService_UpdateMemoView_0 = runtime.ForwardResponseMessage
|
||||
forward_MemoViewService_DeleteMemoView_0 = runtime.ForwardResponseMessage
|
||||
)
|
||||
|
|
@ -1,288 +0,0 @@
|
|||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.6.2
|
||||
// - protoc (unknown)
|
||||
// source: api/v1/memo_view_service.proto
|
||||
|
||||
package apiv1
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
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
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.64.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion9
|
||||
|
||||
const (
|
||||
MemoViewService_ListMemoViews_FullMethodName = "/memos.api.v1.MemoViewService/ListMemoViews"
|
||||
MemoViewService_GetMemoView_FullMethodName = "/memos.api.v1.MemoViewService/GetMemoView"
|
||||
MemoViewService_CreateMemoView_FullMethodName = "/memos.api.v1.MemoViewService/CreateMemoView"
|
||||
MemoViewService_UpdateMemoView_FullMethodName = "/memos.api.v1.MemoViewService/UpdateMemoView"
|
||||
MemoViewService_DeleteMemoView_FullMethodName = "/memos.api.v1.MemoViewService/DeleteMemoView"
|
||||
)
|
||||
|
||||
// MemoViewServiceClient is the client API for MemoViewService service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type MemoViewServiceClient interface {
|
||||
// ListMemoViews returns a user's memo views. Each view is a named, reusable
|
||||
// CEL filter (see MemoView.filter); pass its filter string directly to the
|
||||
// ListMemos `filter` argument.
|
||||
ListMemoViews(ctx context.Context, in *ListMemoViewsRequest, opts ...grpc.CallOption) (*ListMemoViewsResponse, error)
|
||||
// GetMemoView gets a memo view by name.
|
||||
GetMemoView(ctx context.Context, in *GetMemoViewRequest, opts ...grpc.CallOption) (*MemoView, error)
|
||||
// CreateMemoView creates a new memo view for a user.
|
||||
CreateMemoView(ctx context.Context, in *CreateMemoViewRequest, opts ...grpc.CallOption) (*MemoView, error)
|
||||
// UpdateMemoView updates a memo view for a user.
|
||||
UpdateMemoView(ctx context.Context, in *UpdateMemoViewRequest, opts ...grpc.CallOption) (*MemoView, error)
|
||||
// DeleteMemoView deletes a memo view for a user.
|
||||
DeleteMemoView(ctx context.Context, in *DeleteMemoViewRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
}
|
||||
|
||||
type memoViewServiceClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewMemoViewServiceClient(cc grpc.ClientConnInterface) MemoViewServiceClient {
|
||||
return &memoViewServiceClient{cc}
|
||||
}
|
||||
|
||||
func (c *memoViewServiceClient) ListMemoViews(ctx context.Context, in *ListMemoViewsRequest, opts ...grpc.CallOption) (*ListMemoViewsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListMemoViewsResponse)
|
||||
err := c.cc.Invoke(ctx, MemoViewService_ListMemoViews_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *memoViewServiceClient) GetMemoView(ctx context.Context, in *GetMemoViewRequest, opts ...grpc.CallOption) (*MemoView, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(MemoView)
|
||||
err := c.cc.Invoke(ctx, MemoViewService_GetMemoView_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *memoViewServiceClient) CreateMemoView(ctx context.Context, in *CreateMemoViewRequest, opts ...grpc.CallOption) (*MemoView, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(MemoView)
|
||||
err := c.cc.Invoke(ctx, MemoViewService_CreateMemoView_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *memoViewServiceClient) UpdateMemoView(ctx context.Context, in *UpdateMemoViewRequest, opts ...grpc.CallOption) (*MemoView, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(MemoView)
|
||||
err := c.cc.Invoke(ctx, MemoViewService_UpdateMemoView_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *memoViewServiceClient) DeleteMemoView(ctx context.Context, in *DeleteMemoViewRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, MemoViewService_DeleteMemoView_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// MemoViewServiceServer is the server API for MemoViewService service.
|
||||
// All implementations must embed UnimplementedMemoViewServiceServer
|
||||
// for forward compatibility.
|
||||
type MemoViewServiceServer interface {
|
||||
// ListMemoViews returns a user's memo views. Each view is a named, reusable
|
||||
// CEL filter (see MemoView.filter); pass its filter string directly to the
|
||||
// ListMemos `filter` argument.
|
||||
ListMemoViews(context.Context, *ListMemoViewsRequest) (*ListMemoViewsResponse, error)
|
||||
// GetMemoView gets a memo view by name.
|
||||
GetMemoView(context.Context, *GetMemoViewRequest) (*MemoView, error)
|
||||
// CreateMemoView creates a new memo view for a user.
|
||||
CreateMemoView(context.Context, *CreateMemoViewRequest) (*MemoView, error)
|
||||
// UpdateMemoView updates a memo view for a user.
|
||||
UpdateMemoView(context.Context, *UpdateMemoViewRequest) (*MemoView, error)
|
||||
// DeleteMemoView deletes a memo view for a user.
|
||||
DeleteMemoView(context.Context, *DeleteMemoViewRequest) (*emptypb.Empty, error)
|
||||
mustEmbedUnimplementedMemoViewServiceServer()
|
||||
}
|
||||
|
||||
// UnimplementedMemoViewServiceServer must be embedded to have
|
||||
// forward compatible implementations.
|
||||
//
|
||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
||||
// pointer dereference when methods are called.
|
||||
type UnimplementedMemoViewServiceServer struct{}
|
||||
|
||||
func (UnimplementedMemoViewServiceServer) ListMemoViews(context.Context, *ListMemoViewsRequest) (*ListMemoViewsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListMemoViews not implemented")
|
||||
}
|
||||
func (UnimplementedMemoViewServiceServer) GetMemoView(context.Context, *GetMemoViewRequest) (*MemoView, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetMemoView not implemented")
|
||||
}
|
||||
func (UnimplementedMemoViewServiceServer) CreateMemoView(context.Context, *CreateMemoViewRequest) (*MemoView, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateMemoView not implemented")
|
||||
}
|
||||
func (UnimplementedMemoViewServiceServer) UpdateMemoView(context.Context, *UpdateMemoViewRequest) (*MemoView, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method UpdateMemoView not implemented")
|
||||
}
|
||||
func (UnimplementedMemoViewServiceServer) DeleteMemoView(context.Context, *DeleteMemoViewRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method DeleteMemoView not implemented")
|
||||
}
|
||||
func (UnimplementedMemoViewServiceServer) mustEmbedUnimplementedMemoViewServiceServer() {}
|
||||
func (UnimplementedMemoViewServiceServer) testEmbeddedByValue() {}
|
||||
|
||||
// UnsafeMemoViewServiceServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to MemoViewServiceServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeMemoViewServiceServer interface {
|
||||
mustEmbedUnimplementedMemoViewServiceServer()
|
||||
}
|
||||
|
||||
func RegisterMemoViewServiceServer(s grpc.ServiceRegistrar, srv MemoViewServiceServer) {
|
||||
// If the following call panics, it indicates UnimplementedMemoViewServiceServer was
|
||||
// embedded by pointer and is nil. This will cause panics if an
|
||||
// unimplemented method is ever invoked, so we test this at initialization
|
||||
// time to prevent it from happening at runtime later due to I/O.
|
||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
||||
t.testEmbeddedByValue()
|
||||
}
|
||||
s.RegisterService(&MemoViewService_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _MemoViewService_ListMemoViews_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListMemoViewsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MemoViewServiceServer).ListMemoViews(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: MemoViewService_ListMemoViews_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MemoViewServiceServer).ListMemoViews(ctx, req.(*ListMemoViewsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoViewService_GetMemoView_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetMemoViewRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MemoViewServiceServer).GetMemoView(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: MemoViewService_GetMemoView_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MemoViewServiceServer).GetMemoView(ctx, req.(*GetMemoViewRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoViewService_CreateMemoView_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateMemoViewRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MemoViewServiceServer).CreateMemoView(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: MemoViewService_CreateMemoView_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MemoViewServiceServer).CreateMemoView(ctx, req.(*CreateMemoViewRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoViewService_UpdateMemoView_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateMemoViewRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MemoViewServiceServer).UpdateMemoView(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: MemoViewService_UpdateMemoView_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MemoViewServiceServer).UpdateMemoView(ctx, req.(*UpdateMemoViewRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _MemoViewService_DeleteMemoView_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteMemoViewRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(MemoViewServiceServer).DeleteMemoView(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: MemoViewService_DeleteMemoView_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(MemoViewServiceServer).DeleteMemoView(ctx, req.(*DeleteMemoViewRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// MemoViewService_ServiceDesc is the grpc.ServiceDesc for MemoViewService service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var MemoViewService_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "memos.api.v1.MemoViewService",
|
||||
HandlerType: (*MemoViewServiceServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "ListMemoViews",
|
||||
Handler: _MemoViewService_ListMemoViews_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetMemoView",
|
||||
Handler: _MemoViewService_GetMemoView_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreateMemoView",
|
||||
Handler: _MemoViewService_CreateMemoView_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateMemoView",
|
||||
Handler: _MemoViewService_UpdateMemoView_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeleteMemoView",
|
||||
Handler: _MemoViewService_DeleteMemoView_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "api/v1/memo_view_service.proto",
|
||||
}
|
||||
|
|
@ -87,7 +87,10 @@ type Space struct {
|
|||
CurrentUserRole SpaceMember_Role `protobuf:"varint,4,opt,name=current_user_role,json=currentUserRole,proto3,enum=memos.api.v1.SpaceMember_Role" json:"current_user_role,omitempty"`
|
||||
// Output only. The number of accepted members in this space. Pending
|
||||
// invitations are excluded. Zero when this Space is exposed as metadata-only.
|
||||
MemberCount int32 `protobuf:"varint,5,opt,name=member_count,json=memberCount,proto3" json:"member_count,omitempty"`
|
||||
MemberCount int32 `protobuf:"varint,5,opt,name=member_count,json=memberCount,proto3" json:"member_count,omitempty"`
|
||||
// Optional. Display icon. Omit when updating with the "icon" mask to reset
|
||||
// to the default Space mark.
|
||||
Icon *Space_Icon `protobuf:"bytes,6,opt,name=icon,proto3" json:"icon,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
|
@ -157,6 +160,13 @@ func (x *Space) GetMemberCount() int32 {
|
|||
return 0
|
||||
}
|
||||
|
||||
func (x *Space) GetIcon() *Space_Icon {
|
||||
if x != nil {
|
||||
return x.Icon
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SpaceMember is a user's membership and governance role in a space.
|
||||
type SpaceMember struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
|
|
@ -1324,17 +1334,106 @@ func (x *DeleteSpaceMemberRequest) GetName() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
type Space_Icon struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Types that are valid to be assigned to Value:
|
||||
//
|
||||
// *Space_Icon_Emoji
|
||||
// *Space_Icon_Lucide
|
||||
Value isSpace_Icon_Value `protobuf_oneof:"value"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Space_Icon) Reset() {
|
||||
*x = Space_Icon{}
|
||||
mi := &file_api_v1_space_service_proto_msgTypes[23]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Space_Icon) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Space_Icon) ProtoMessage() {}
|
||||
|
||||
func (x *Space_Icon) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_space_service_proto_msgTypes[23]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Space_Icon.ProtoReflect.Descriptor instead.
|
||||
func (*Space_Icon) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_space_service_proto_rawDescGZIP(), []int{0, 0}
|
||||
}
|
||||
|
||||
func (x *Space_Icon) GetValue() isSpace_Icon_Value {
|
||||
if x != nil {
|
||||
return x.Value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Space_Icon) GetEmoji() string {
|
||||
if x != nil {
|
||||
if x, ok := x.Value.(*Space_Icon_Emoji); ok {
|
||||
return x.Emoji
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *Space_Icon) GetLucide() string {
|
||||
if x != nil {
|
||||
if x, ok := x.Value.(*Space_Icon_Lucide); ok {
|
||||
return x.Lucide
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type isSpace_Icon_Value interface {
|
||||
isSpace_Icon_Value()
|
||||
}
|
||||
|
||||
type Space_Icon_Emoji struct {
|
||||
// A Unicode emoji sequence.
|
||||
Emoji string `protobuf:"bytes,1,opt,name=emoji,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Space_Icon_Lucide struct {
|
||||
// A canonical Lucide icon name, such as "leaf".
|
||||
Lucide string `protobuf:"bytes,2,opt,name=lucide,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*Space_Icon_Emoji) isSpace_Icon_Value() {}
|
||||
|
||||
func (*Space_Icon_Lucide) isSpace_Icon_Value() {}
|
||||
|
||||
var File_api_v1_space_service_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_api_v1_space_service_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x1aapi/v1/space_service.proto\x12\fmemos.api.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\"\x99\x02\n" +
|
||||
"\x1aapi/v1/space_service.proto\x12\fmemos.api.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\"\x8f\x03\n" +
|
||||
"\x05Space\x12\x17\n" +
|
||||
"\x04name\x18\x01 \x01(\tB\x03\xe0A\bR\x04name\x12\x19\n" +
|
||||
"\x05title\x18\x02 \x01(\tB\x03\xe0A\x02R\x05title\x12%\n" +
|
||||
"\vdescription\x18\x03 \x01(\tB\x03\xe0A\x01R\vdescription\x12O\n" +
|
||||
"\x11current_user_role\x18\x04 \x01(\x0e2\x1e.memos.api.v1.SpaceMember.RoleB\x03\xe0A\x03R\x0fcurrentUserRole\x12&\n" +
|
||||
"\fmember_count\x18\x05 \x01(\x05B\x03\xe0A\x03R\vmemberCount:<\xeaA9\n" +
|
||||
"\fmember_count\x18\x05 \x01(\x05B\x03\xe0A\x03R\vmemberCount\x121\n" +
|
||||
"\x04icon\x18\x06 \x01(\v2\x18.memos.api.v1.Space.IconB\x03\xe0A\x01R\x04icon\x1aA\n" +
|
||||
"\x04Icon\x12\x16\n" +
|
||||
"\x05emoji\x18\x01 \x01(\tH\x00R\x05emoji\x12\x18\n" +
|
||||
"\x06lucide\x18\x02 \x01(\tH\x00R\x06lucideB\a\n" +
|
||||
"\x05value:<\xeaA9\n" +
|
||||
"\x12memos.api.v1/Space\x12\x0espaces/{space}\x1a\x04name*\x06spaces2\x05space\"\xa2\x02\n" +
|
||||
"\vSpaceMember\x12\x17\n" +
|
||||
"\x04name\x18\x01 \x01(\tB\x03\xe0A\bR\x04name\x12-\n" +
|
||||
|
|
@ -1456,7 +1555,7 @@ func file_api_v1_space_service_proto_rawDescGZIP() []byte {
|
|||
}
|
||||
|
||||
var file_api_v1_space_service_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_api_v1_space_service_proto_msgTypes = make([]protoimpl.MessageInfo, 23)
|
||||
var file_api_v1_space_service_proto_msgTypes = make([]protoimpl.MessageInfo, 24)
|
||||
var file_api_v1_space_service_proto_goTypes = []any{
|
||||
(SpaceMember_Role)(0), // 0: memos.api.v1.SpaceMember.Role
|
||||
(*Space)(nil), // 1: memos.api.v1.Space
|
||||
|
|
@ -1482,61 +1581,63 @@ var file_api_v1_space_service_proto_goTypes = []any{
|
|||
(*GetSpaceMemberRequest)(nil), // 21: memos.api.v1.GetSpaceMemberRequest
|
||||
(*UpdateSpaceMemberRequest)(nil), // 22: memos.api.v1.UpdateSpaceMemberRequest
|
||||
(*DeleteSpaceMemberRequest)(nil), // 23: memos.api.v1.DeleteSpaceMemberRequest
|
||||
(*fieldmaskpb.FieldMask)(nil), // 24: google.protobuf.FieldMask
|
||||
(*emptypb.Empty)(nil), // 25: google.protobuf.Empty
|
||||
(*Space_Icon)(nil), // 24: memos.api.v1.Space.Icon
|
||||
(*fieldmaskpb.FieldMask)(nil), // 25: google.protobuf.FieldMask
|
||||
(*emptypb.Empty)(nil), // 26: google.protobuf.Empty
|
||||
}
|
||||
var file_api_v1_space_service_proto_depIdxs = []int32{
|
||||
0, // 0: memos.api.v1.Space.current_user_role:type_name -> memos.api.v1.SpaceMember.Role
|
||||
0, // 1: memos.api.v1.SpaceMember.role:type_name -> memos.api.v1.SpaceMember.Role
|
||||
0, // 2: memos.api.v1.SpaceInvitation.role:type_name -> memos.api.v1.SpaceMember.Role
|
||||
1, // 3: memos.api.v1.SpaceInvitation.space:type_name -> memos.api.v1.Space
|
||||
1, // 4: memos.api.v1.CreateSpaceRequest.space:type_name -> memos.api.v1.Space
|
||||
1, // 5: memos.api.v1.ListSpacesResponse.spaces:type_name -> memos.api.v1.Space
|
||||
1, // 6: memos.api.v1.UpdateSpaceRequest.space:type_name -> memos.api.v1.Space
|
||||
24, // 7: memos.api.v1.UpdateSpaceRequest.update_mask:type_name -> google.protobuf.FieldMask
|
||||
3, // 8: memos.api.v1.CreateSpaceInvitationRequest.space_invitation:type_name -> memos.api.v1.SpaceInvitation
|
||||
3, // 9: memos.api.v1.ListSpaceInvitationsResponse.space_invitations:type_name -> memos.api.v1.SpaceInvitation
|
||||
3, // 10: memos.api.v1.ListUserSpaceInvitationsResponse.space_invitations:type_name -> memos.api.v1.SpaceInvitation
|
||||
2, // 11: memos.api.v1.ListSpaceMembersResponse.space_members:type_name -> memos.api.v1.SpaceMember
|
||||
2, // 12: memos.api.v1.UpdateSpaceMemberRequest.space_member:type_name -> memos.api.v1.SpaceMember
|
||||
24, // 13: memos.api.v1.UpdateSpaceMemberRequest.update_mask:type_name -> google.protobuf.FieldMask
|
||||
4, // 14: memos.api.v1.SpaceService.CreateSpace:input_type -> memos.api.v1.CreateSpaceRequest
|
||||
5, // 15: memos.api.v1.SpaceService.ListSpaces:input_type -> memos.api.v1.ListSpacesRequest
|
||||
7, // 16: memos.api.v1.SpaceService.GetSpace:input_type -> memos.api.v1.GetSpaceRequest
|
||||
8, // 17: memos.api.v1.SpaceService.UpdateSpace:input_type -> memos.api.v1.UpdateSpaceRequest
|
||||
9, // 18: memos.api.v1.SpaceService.DeleteSpace:input_type -> memos.api.v1.DeleteSpaceRequest
|
||||
10, // 19: memos.api.v1.SpaceService.CreateSpaceInvitation:input_type -> memos.api.v1.CreateSpaceInvitationRequest
|
||||
11, // 20: memos.api.v1.SpaceService.ListSpaceInvitations:input_type -> memos.api.v1.ListSpaceInvitationsRequest
|
||||
13, // 21: memos.api.v1.SpaceService.ListUserSpaceInvitations:input_type -> memos.api.v1.ListUserSpaceInvitationsRequest
|
||||
15, // 22: memos.api.v1.SpaceService.GetSpaceInvitation:input_type -> memos.api.v1.GetSpaceInvitationRequest
|
||||
16, // 23: memos.api.v1.SpaceService.DeleteSpaceInvitation:input_type -> memos.api.v1.DeleteSpaceInvitationRequest
|
||||
17, // 24: memos.api.v1.SpaceService.AcceptSpaceInvitation:input_type -> memos.api.v1.AcceptSpaceInvitationRequest
|
||||
18, // 25: memos.api.v1.SpaceService.DeclineSpaceInvitation:input_type -> memos.api.v1.DeclineSpaceInvitationRequest
|
||||
19, // 26: memos.api.v1.SpaceService.ListSpaceMembers:input_type -> memos.api.v1.ListSpaceMembersRequest
|
||||
21, // 27: memos.api.v1.SpaceService.GetSpaceMember:input_type -> memos.api.v1.GetSpaceMemberRequest
|
||||
22, // 28: memos.api.v1.SpaceService.UpdateSpaceMember:input_type -> memos.api.v1.UpdateSpaceMemberRequest
|
||||
23, // 29: memos.api.v1.SpaceService.DeleteSpaceMember:input_type -> memos.api.v1.DeleteSpaceMemberRequest
|
||||
1, // 30: memos.api.v1.SpaceService.CreateSpace:output_type -> memos.api.v1.Space
|
||||
6, // 31: memos.api.v1.SpaceService.ListSpaces:output_type -> memos.api.v1.ListSpacesResponse
|
||||
1, // 32: memos.api.v1.SpaceService.GetSpace:output_type -> memos.api.v1.Space
|
||||
1, // 33: memos.api.v1.SpaceService.UpdateSpace:output_type -> memos.api.v1.Space
|
||||
25, // 34: memos.api.v1.SpaceService.DeleteSpace:output_type -> google.protobuf.Empty
|
||||
3, // 35: memos.api.v1.SpaceService.CreateSpaceInvitation:output_type -> memos.api.v1.SpaceInvitation
|
||||
12, // 36: memos.api.v1.SpaceService.ListSpaceInvitations:output_type -> memos.api.v1.ListSpaceInvitationsResponse
|
||||
14, // 37: memos.api.v1.SpaceService.ListUserSpaceInvitations:output_type -> memos.api.v1.ListUserSpaceInvitationsResponse
|
||||
3, // 38: memos.api.v1.SpaceService.GetSpaceInvitation:output_type -> memos.api.v1.SpaceInvitation
|
||||
25, // 39: memos.api.v1.SpaceService.DeleteSpaceInvitation:output_type -> google.protobuf.Empty
|
||||
2, // 40: memos.api.v1.SpaceService.AcceptSpaceInvitation:output_type -> memos.api.v1.SpaceMember
|
||||
25, // 41: memos.api.v1.SpaceService.DeclineSpaceInvitation:output_type -> google.protobuf.Empty
|
||||
20, // 42: memos.api.v1.SpaceService.ListSpaceMembers:output_type -> memos.api.v1.ListSpaceMembersResponse
|
||||
2, // 43: memos.api.v1.SpaceService.GetSpaceMember:output_type -> memos.api.v1.SpaceMember
|
||||
2, // 44: memos.api.v1.SpaceService.UpdateSpaceMember:output_type -> memos.api.v1.SpaceMember
|
||||
25, // 45: memos.api.v1.SpaceService.DeleteSpaceMember:output_type -> google.protobuf.Empty
|
||||
30, // [30:46] is the sub-list for method output_type
|
||||
14, // [14:30] is the sub-list for method input_type
|
||||
14, // [14:14] is the sub-list for extension type_name
|
||||
14, // [14:14] is the sub-list for extension extendee
|
||||
0, // [0:14] is the sub-list for field type_name
|
||||
24, // 1: memos.api.v1.Space.icon:type_name -> memos.api.v1.Space.Icon
|
||||
0, // 2: memos.api.v1.SpaceMember.role:type_name -> memos.api.v1.SpaceMember.Role
|
||||
0, // 3: memos.api.v1.SpaceInvitation.role:type_name -> memos.api.v1.SpaceMember.Role
|
||||
1, // 4: memos.api.v1.SpaceInvitation.space:type_name -> memos.api.v1.Space
|
||||
1, // 5: memos.api.v1.CreateSpaceRequest.space:type_name -> memos.api.v1.Space
|
||||
1, // 6: memos.api.v1.ListSpacesResponse.spaces:type_name -> memos.api.v1.Space
|
||||
1, // 7: memos.api.v1.UpdateSpaceRequest.space:type_name -> memos.api.v1.Space
|
||||
25, // 8: memos.api.v1.UpdateSpaceRequest.update_mask:type_name -> google.protobuf.FieldMask
|
||||
3, // 9: memos.api.v1.CreateSpaceInvitationRequest.space_invitation:type_name -> memos.api.v1.SpaceInvitation
|
||||
3, // 10: memos.api.v1.ListSpaceInvitationsResponse.space_invitations:type_name -> memos.api.v1.SpaceInvitation
|
||||
3, // 11: memos.api.v1.ListUserSpaceInvitationsResponse.space_invitations:type_name -> memos.api.v1.SpaceInvitation
|
||||
2, // 12: memos.api.v1.ListSpaceMembersResponse.space_members:type_name -> memos.api.v1.SpaceMember
|
||||
2, // 13: memos.api.v1.UpdateSpaceMemberRequest.space_member:type_name -> memos.api.v1.SpaceMember
|
||||
25, // 14: memos.api.v1.UpdateSpaceMemberRequest.update_mask:type_name -> google.protobuf.FieldMask
|
||||
4, // 15: memos.api.v1.SpaceService.CreateSpace:input_type -> memos.api.v1.CreateSpaceRequest
|
||||
5, // 16: memos.api.v1.SpaceService.ListSpaces:input_type -> memos.api.v1.ListSpacesRequest
|
||||
7, // 17: memos.api.v1.SpaceService.GetSpace:input_type -> memos.api.v1.GetSpaceRequest
|
||||
8, // 18: memos.api.v1.SpaceService.UpdateSpace:input_type -> memos.api.v1.UpdateSpaceRequest
|
||||
9, // 19: memos.api.v1.SpaceService.DeleteSpace:input_type -> memos.api.v1.DeleteSpaceRequest
|
||||
10, // 20: memos.api.v1.SpaceService.CreateSpaceInvitation:input_type -> memos.api.v1.CreateSpaceInvitationRequest
|
||||
11, // 21: memos.api.v1.SpaceService.ListSpaceInvitations:input_type -> memos.api.v1.ListSpaceInvitationsRequest
|
||||
13, // 22: memos.api.v1.SpaceService.ListUserSpaceInvitations:input_type -> memos.api.v1.ListUserSpaceInvitationsRequest
|
||||
15, // 23: memos.api.v1.SpaceService.GetSpaceInvitation:input_type -> memos.api.v1.GetSpaceInvitationRequest
|
||||
16, // 24: memos.api.v1.SpaceService.DeleteSpaceInvitation:input_type -> memos.api.v1.DeleteSpaceInvitationRequest
|
||||
17, // 25: memos.api.v1.SpaceService.AcceptSpaceInvitation:input_type -> memos.api.v1.AcceptSpaceInvitationRequest
|
||||
18, // 26: memos.api.v1.SpaceService.DeclineSpaceInvitation:input_type -> memos.api.v1.DeclineSpaceInvitationRequest
|
||||
19, // 27: memos.api.v1.SpaceService.ListSpaceMembers:input_type -> memos.api.v1.ListSpaceMembersRequest
|
||||
21, // 28: memos.api.v1.SpaceService.GetSpaceMember:input_type -> memos.api.v1.GetSpaceMemberRequest
|
||||
22, // 29: memos.api.v1.SpaceService.UpdateSpaceMember:input_type -> memos.api.v1.UpdateSpaceMemberRequest
|
||||
23, // 30: memos.api.v1.SpaceService.DeleteSpaceMember:input_type -> memos.api.v1.DeleteSpaceMemberRequest
|
||||
1, // 31: memos.api.v1.SpaceService.CreateSpace:output_type -> memos.api.v1.Space
|
||||
6, // 32: memos.api.v1.SpaceService.ListSpaces:output_type -> memos.api.v1.ListSpacesResponse
|
||||
1, // 33: memos.api.v1.SpaceService.GetSpace:output_type -> memos.api.v1.Space
|
||||
1, // 34: memos.api.v1.SpaceService.UpdateSpace:output_type -> memos.api.v1.Space
|
||||
26, // 35: memos.api.v1.SpaceService.DeleteSpace:output_type -> google.protobuf.Empty
|
||||
3, // 36: memos.api.v1.SpaceService.CreateSpaceInvitation:output_type -> memos.api.v1.SpaceInvitation
|
||||
12, // 37: memos.api.v1.SpaceService.ListSpaceInvitations:output_type -> memos.api.v1.ListSpaceInvitationsResponse
|
||||
14, // 38: memos.api.v1.SpaceService.ListUserSpaceInvitations:output_type -> memos.api.v1.ListUserSpaceInvitationsResponse
|
||||
3, // 39: memos.api.v1.SpaceService.GetSpaceInvitation:output_type -> memos.api.v1.SpaceInvitation
|
||||
26, // 40: memos.api.v1.SpaceService.DeleteSpaceInvitation:output_type -> google.protobuf.Empty
|
||||
2, // 41: memos.api.v1.SpaceService.AcceptSpaceInvitation:output_type -> memos.api.v1.SpaceMember
|
||||
26, // 42: memos.api.v1.SpaceService.DeclineSpaceInvitation:output_type -> google.protobuf.Empty
|
||||
20, // 43: memos.api.v1.SpaceService.ListSpaceMembers:output_type -> memos.api.v1.ListSpaceMembersResponse
|
||||
2, // 44: memos.api.v1.SpaceService.GetSpaceMember:output_type -> memos.api.v1.SpaceMember
|
||||
2, // 45: memos.api.v1.SpaceService.UpdateSpaceMember:output_type -> memos.api.v1.SpaceMember
|
||||
26, // 46: memos.api.v1.SpaceService.DeleteSpaceMember:output_type -> google.protobuf.Empty
|
||||
31, // [31:47] is the sub-list for method output_type
|
||||
15, // [15:31] is the sub-list for method input_type
|
||||
15, // [15:15] is the sub-list for extension type_name
|
||||
15, // [15:15] is the sub-list for extension extendee
|
||||
0, // [0:15] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_v1_space_service_proto_init() }
|
||||
|
|
@ -1544,13 +1645,17 @@ func file_api_v1_space_service_proto_init() {
|
|||
if File_api_v1_space_service_proto != nil {
|
||||
return
|
||||
}
|
||||
file_api_v1_space_service_proto_msgTypes[23].OneofWrappers = []any{
|
||||
(*Space_Icon_Emoji)(nil),
|
||||
(*Space_Icon_Lucide)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_v1_space_service_proto_rawDesc), len(file_api_v1_space_service_proto_rawDesc)),
|
||||
NumEnums: 1,
|
||||
NumMessages: 23,
|
||||
NumMessages: 24,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -586,6 +586,263 @@ func local_request_UserService_ListUserSettings_0(ctx context.Context, marshaler
|
|||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func request_UserService_ListMemoViews_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq ListMemoViewsRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
val, ok := pathParams["parent"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent")
|
||||
}
|
||||
protoReq.Parent, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err)
|
||||
}
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.ListMemoViews(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_UserService_ListMemoViews_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq ListMemoViewsRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
val, ok := pathParams["parent"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent")
|
||||
}
|
||||
protoReq.Parent, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err)
|
||||
}
|
||||
msg, err := server.ListMemoViews(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func request_UserService_GetMemoView_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq GetMemoViewRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
val, ok := pathParams["name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
|
||||
}
|
||||
protoReq.Name, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
|
||||
}
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.GetMemoView(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_UserService_GetMemoView_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq GetMemoViewRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
val, ok := pathParams["name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
|
||||
}
|
||||
protoReq.Name, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
|
||||
}
|
||||
msg, err := server.GetMemoView(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
var filter_UserService_CreateMemoView_0 = &utilities.DoubleArray{Encoding: map[string]int{"memo_view": 0, "parent": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}}
|
||||
|
||||
func request_UserService_CreateMemoView_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq CreateMemoViewRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.MemoView); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
val, ok := pathParams["parent"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent")
|
||||
}
|
||||
protoReq.Parent, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_CreateMemoView_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.CreateMemoView(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_UserService_CreateMemoView_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq CreateMemoViewRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq.MemoView); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
val, ok := pathParams["parent"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent")
|
||||
}
|
||||
protoReq.Parent, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_CreateMemoView_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
msg, err := server.CreateMemoView(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
var filter_UserService_UpdateMemoView_0 = &utilities.DoubleArray{Encoding: map[string]int{"memo_view": 0, "name": 1}, Base: []int{1, 2, 1, 0, 0}, Check: []int{0, 1, 2, 3, 2}}
|
||||
|
||||
func request_UserService_UpdateMemoView_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq UpdateMemoViewRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.MemoView); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {
|
||||
if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.MemoView); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
} else {
|
||||
protoReq.UpdateMask = fieldMask
|
||||
}
|
||||
}
|
||||
val, ok := pathParams["memo_view.name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "memo_view.name")
|
||||
}
|
||||
err = runtime.PopulateFieldFromPath(&protoReq, "memo_view.name", val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "memo_view.name", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_UpdateMemoView_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.UpdateMemoView(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_UserService_UpdateMemoView_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq UpdateMemoViewRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
newReader, berr := utilities.IOReaderFactory(req.Body)
|
||||
if berr != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
|
||||
}
|
||||
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq.MemoView); err != nil && !errors.Is(err, io.EOF) {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if protoReq.UpdateMask == nil || len(protoReq.UpdateMask.GetPaths()) == 0 {
|
||||
if fieldMask, err := runtime.FieldMaskFromRequestBody(newReader(), protoReq.MemoView); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
} else {
|
||||
protoReq.UpdateMask = fieldMask
|
||||
}
|
||||
}
|
||||
val, ok := pathParams["memo_view.name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "memo_view.name")
|
||||
}
|
||||
err = runtime.PopulateFieldFromPath(&protoReq, "memo_view.name", val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "memo_view.name", err)
|
||||
}
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_UserService_UpdateMemoView_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
msg, err := server.UpdateMemoView(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func request_UserService_DeleteMemoView_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq DeleteMemoViewRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
val, ok := pathParams["name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
|
||||
}
|
||||
protoReq.Name, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
|
||||
}
|
||||
if req.Body != nil {
|
||||
_, _ = io.Copy(io.Discard, req.Body)
|
||||
}
|
||||
msg, err := client.DeleteMemoView(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func local_request_UserService_DeleteMemoView_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq DeleteMemoViewRequest
|
||||
metadata runtime.ServerMetadata
|
||||
err error
|
||||
)
|
||||
val, ok := pathParams["name"]
|
||||
if !ok {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
|
||||
}
|
||||
protoReq.Name, err = runtime.String(val)
|
||||
if err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
|
||||
}
|
||||
msg, err := server.DeleteMemoView(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
}
|
||||
|
||||
func request_UserService_ListLinkedIdentities_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var (
|
||||
protoReq ListLinkedIdentitiesRequest
|
||||
|
|
@ -1527,6 +1784,106 @@ func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux
|
|||
}
|
||||
forward_UserService_ListUserSettings_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodGet, pattern_UserService_ListMemoViews_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.UserService/ListMemoViews", runtime.WithHTTPPathPattern("/api/v1/{parent=users/*}/views"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_UserService_ListMemoViews_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_UserService_ListMemoViews_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodGet, pattern_UserService_GetMemoView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.UserService/GetMemoView", runtime.WithHTTPPathPattern("/api/v1/{name=users/*/views/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_UserService_GetMemoView_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_UserService_GetMemoView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_UserService_CreateMemoView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.UserService/CreateMemoView", runtime.WithHTTPPathPattern("/api/v1/{parent=users/*}/views"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_UserService_CreateMemoView_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_UserService_CreateMemoView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPatch, pattern_UserService_UpdateMemoView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.UserService/UpdateMemoView", runtime.WithHTTPPathPattern("/api/v1/{memo_view.name=users/*/views/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_UserService_UpdateMemoView_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_UserService_UpdateMemoView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodDelete, pattern_UserService_DeleteMemoView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.UserService/DeleteMemoView", runtime.WithHTTPPathPattern("/api/v1/{name=users/*/views/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_UserService_DeleteMemoView_0(annotatedContext, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_UserService_DeleteMemoView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodGet, pattern_UserService_ListLinkedIdentities_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
|
|
@ -2054,6 +2411,91 @@ func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
|
|||
}
|
||||
forward_UserService_ListUserSettings_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodGet, pattern_UserService_ListMemoViews_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.UserService/ListMemoViews", runtime.WithHTTPPathPattern("/api/v1/{parent=users/*}/views"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_UserService_ListMemoViews_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_UserService_ListMemoViews_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodGet, pattern_UserService_GetMemoView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.UserService/GetMemoView", runtime.WithHTTPPathPattern("/api/v1/{name=users/*/views/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_UserService_GetMemoView_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_UserService_GetMemoView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPost, pattern_UserService_CreateMemoView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.UserService/CreateMemoView", runtime.WithHTTPPathPattern("/api/v1/{parent=users/*}/views"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_UserService_CreateMemoView_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_UserService_CreateMemoView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodPatch, pattern_UserService_UpdateMemoView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.UserService/UpdateMemoView", runtime.WithHTTPPathPattern("/api/v1/{memo_view.name=users/*/views/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_UserService_UpdateMemoView_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_UserService_UpdateMemoView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodDelete, pattern_UserService_DeleteMemoView_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.UserService/DeleteMemoView", runtime.WithHTTPPathPattern("/api/v1/{name=users/*/views/*}"))
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_UserService_DeleteMemoView_0(annotatedContext, inboundMarshaler, client, req, pathParams)
|
||||
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
forward_UserService_DeleteMemoView_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
})
|
||||
mux.Handle(http.MethodGet, pattern_UserService_ListLinkedIdentities_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
|
|
@ -2324,6 +2766,11 @@ var (
|
|||
pattern_UserService_GetUserSetting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 2, 3, 1, 0, 4, 4, 5, 4}, []string{"api", "v1", "users", "settings", "name"}, ""))
|
||||
pattern_UserService_UpdateUserSetting_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 2, 3, 1, 0, 4, 4, 5, 4}, []string{"api", "v1", "users", "settings", "setting.name"}, ""))
|
||||
pattern_UserService_ListUserSettings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3, 2, 4}, []string{"api", "v1", "users", "parent", "settings"}, ""))
|
||||
pattern_UserService_ListMemoViews_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3, 2, 4}, []string{"api", "v1", "users", "parent", "views"}, ""))
|
||||
pattern_UserService_GetMemoView_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 2, 3, 1, 0, 4, 4, 5, 4}, []string{"api", "v1", "users", "views", "name"}, ""))
|
||||
pattern_UserService_CreateMemoView_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3, 2, 4}, []string{"api", "v1", "users", "parent", "views"}, ""))
|
||||
pattern_UserService_UpdateMemoView_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 2, 3, 1, 0, 4, 4, 5, 4}, []string{"api", "v1", "users", "views", "memo_view.name"}, ""))
|
||||
pattern_UserService_DeleteMemoView_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 2, 3, 1, 0, 4, 4, 5, 4}, []string{"api", "v1", "users", "views", "name"}, ""))
|
||||
pattern_UserService_ListLinkedIdentities_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3, 2, 4}, []string{"api", "v1", "users", "parent", "linkedIdentities"}, ""))
|
||||
pattern_UserService_CreateLinkedIdentity_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3, 2, 4}, []string{"api", "v1", "users", "parent", "linkedIdentities"}, ""))
|
||||
pattern_UserService_GetLinkedIdentity_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 2, 3, 1, 0, 4, 4, 5, 4}, []string{"api", "v1", "users", "linkedIdentities", "name"}, ""))
|
||||
|
|
@ -2353,6 +2800,11 @@ var (
|
|||
forward_UserService_GetUserSetting_0 = runtime.ForwardResponseMessage
|
||||
forward_UserService_UpdateUserSetting_0 = runtime.ForwardResponseMessage
|
||||
forward_UserService_ListUserSettings_0 = runtime.ForwardResponseMessage
|
||||
forward_UserService_ListMemoViews_0 = runtime.ForwardResponseMessage
|
||||
forward_UserService_GetMemoView_0 = runtime.ForwardResponseMessage
|
||||
forward_UserService_CreateMemoView_0 = runtime.ForwardResponseMessage
|
||||
forward_UserService_UpdateMemoView_0 = runtime.ForwardResponseMessage
|
||||
forward_UserService_DeleteMemoView_0 = runtime.ForwardResponseMessage
|
||||
forward_UserService_ListLinkedIdentities_0 = runtime.ForwardResponseMessage
|
||||
forward_UserService_CreateLinkedIdentity_0 = runtime.ForwardResponseMessage
|
||||
forward_UserService_GetLinkedIdentity_0 = runtime.ForwardResponseMessage
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@ const (
|
|||
UserService_GetUserSetting_FullMethodName = "/memos.api.v1.UserService/GetUserSetting"
|
||||
UserService_UpdateUserSetting_FullMethodName = "/memos.api.v1.UserService/UpdateUserSetting"
|
||||
UserService_ListUserSettings_FullMethodName = "/memos.api.v1.UserService/ListUserSettings"
|
||||
UserService_ListMemoViews_FullMethodName = "/memos.api.v1.UserService/ListMemoViews"
|
||||
UserService_GetMemoView_FullMethodName = "/memos.api.v1.UserService/GetMemoView"
|
||||
UserService_CreateMemoView_FullMethodName = "/memos.api.v1.UserService/CreateMemoView"
|
||||
UserService_UpdateMemoView_FullMethodName = "/memos.api.v1.UserService/UpdateMemoView"
|
||||
UserService_DeleteMemoView_FullMethodName = "/memos.api.v1.UserService/DeleteMemoView"
|
||||
UserService_ListLinkedIdentities_FullMethodName = "/memos.api.v1.UserService/ListLinkedIdentities"
|
||||
UserService_CreateLinkedIdentity_FullMethodName = "/memos.api.v1.UserService/CreateLinkedIdentity"
|
||||
UserService_GetLinkedIdentity_FullMethodName = "/memos.api.v1.UserService/GetLinkedIdentity"
|
||||
|
|
@ -75,6 +80,18 @@ type UserServiceClient interface {
|
|||
UpdateUserSetting(ctx context.Context, in *UpdateUserSettingRequest, opts ...grpc.CallOption) (*UserSetting, error)
|
||||
// ListUserSettings returns a list of user settings.
|
||||
ListUserSettings(ctx context.Context, in *ListUserSettingsRequest, opts ...grpc.CallOption) (*ListUserSettingsResponse, error)
|
||||
// ListMemoViews returns a user's memo views. Each view is a named, reusable
|
||||
// CEL filter (see MemoView.filter); pass its filter string directly to the
|
||||
// ListMemos `filter` argument.
|
||||
ListMemoViews(ctx context.Context, in *ListMemoViewsRequest, opts ...grpc.CallOption) (*ListMemoViewsResponse, error)
|
||||
// GetMemoView gets a memo view by name.
|
||||
GetMemoView(ctx context.Context, in *GetMemoViewRequest, opts ...grpc.CallOption) (*MemoView, error)
|
||||
// CreateMemoView creates a new memo view for a user.
|
||||
CreateMemoView(ctx context.Context, in *CreateMemoViewRequest, opts ...grpc.CallOption) (*MemoView, error)
|
||||
// UpdateMemoView updates a memo view for a user.
|
||||
UpdateMemoView(ctx context.Context, in *UpdateMemoViewRequest, opts ...grpc.CallOption) (*MemoView, error)
|
||||
// DeleteMemoView deletes a memo view for a user.
|
||||
DeleteMemoView(ctx context.Context, in *DeleteMemoViewRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
|
||||
// ListLinkedIdentities returns a list of linked SSO identities for a user.
|
||||
ListLinkedIdentities(ctx context.Context, in *ListLinkedIdentitiesRequest, opts ...grpc.CallOption) (*ListLinkedIdentitiesResponse, error)
|
||||
// CreateLinkedIdentity links an SSO identity to the authenticated user.
|
||||
|
|
@ -229,6 +246,56 @@ func (c *userServiceClient) ListUserSettings(ctx context.Context, in *ListUserSe
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userServiceClient) ListMemoViews(ctx context.Context, in *ListMemoViewsRequest, opts ...grpc.CallOption) (*ListMemoViewsResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListMemoViewsResponse)
|
||||
err := c.cc.Invoke(ctx, UserService_ListMemoViews_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userServiceClient) GetMemoView(ctx context.Context, in *GetMemoViewRequest, opts ...grpc.CallOption) (*MemoView, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(MemoView)
|
||||
err := c.cc.Invoke(ctx, UserService_GetMemoView_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userServiceClient) CreateMemoView(ctx context.Context, in *CreateMemoViewRequest, opts ...grpc.CallOption) (*MemoView, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(MemoView)
|
||||
err := c.cc.Invoke(ctx, UserService_CreateMemoView_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userServiceClient) UpdateMemoView(ctx context.Context, in *UpdateMemoViewRequest, opts ...grpc.CallOption) (*MemoView, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(MemoView)
|
||||
err := c.cc.Invoke(ctx, UserService_UpdateMemoView_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userServiceClient) DeleteMemoView(ctx context.Context, in *DeleteMemoViewRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(emptypb.Empty)
|
||||
err := c.cc.Invoke(ctx, UserService_DeleteMemoView_FullMethodName, in, out, cOpts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *userServiceClient) ListLinkedIdentities(ctx context.Context, in *ListLinkedIdentitiesRequest, opts ...grpc.CallOption) (*ListLinkedIdentitiesResponse, error) {
|
||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||
out := new(ListLinkedIdentitiesResponse)
|
||||
|
|
@ -406,6 +473,18 @@ type UserServiceServer interface {
|
|||
UpdateUserSetting(context.Context, *UpdateUserSettingRequest) (*UserSetting, error)
|
||||
// ListUserSettings returns a list of user settings.
|
||||
ListUserSettings(context.Context, *ListUserSettingsRequest) (*ListUserSettingsResponse, error)
|
||||
// ListMemoViews returns a user's memo views. Each view is a named, reusable
|
||||
// CEL filter (see MemoView.filter); pass its filter string directly to the
|
||||
// ListMemos `filter` argument.
|
||||
ListMemoViews(context.Context, *ListMemoViewsRequest) (*ListMemoViewsResponse, error)
|
||||
// GetMemoView gets a memo view by name.
|
||||
GetMemoView(context.Context, *GetMemoViewRequest) (*MemoView, error)
|
||||
// CreateMemoView creates a new memo view for a user.
|
||||
CreateMemoView(context.Context, *CreateMemoViewRequest) (*MemoView, error)
|
||||
// UpdateMemoView updates a memo view for a user.
|
||||
UpdateMemoView(context.Context, *UpdateMemoViewRequest) (*MemoView, error)
|
||||
// DeleteMemoView deletes a memo view for a user.
|
||||
DeleteMemoView(context.Context, *DeleteMemoViewRequest) (*emptypb.Empty, error)
|
||||
// ListLinkedIdentities returns a list of linked SSO identities for a user.
|
||||
ListLinkedIdentities(context.Context, *ListLinkedIdentitiesRequest) (*ListLinkedIdentitiesResponse, error)
|
||||
// CreateLinkedIdentity links an SSO identity to the authenticated user.
|
||||
|
|
@ -483,6 +562,21 @@ func (UnimplementedUserServiceServer) UpdateUserSetting(context.Context, *Update
|
|||
func (UnimplementedUserServiceServer) ListUserSettings(context.Context, *ListUserSettingsRequest) (*ListUserSettingsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListUserSettings not implemented")
|
||||
}
|
||||
func (UnimplementedUserServiceServer) ListMemoViews(context.Context, *ListMemoViewsRequest) (*ListMemoViewsResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListMemoViews not implemented")
|
||||
}
|
||||
func (UnimplementedUserServiceServer) GetMemoView(context.Context, *GetMemoViewRequest) (*MemoView, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method GetMemoView not implemented")
|
||||
}
|
||||
func (UnimplementedUserServiceServer) CreateMemoView(context.Context, *CreateMemoViewRequest) (*MemoView, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method CreateMemoView not implemented")
|
||||
}
|
||||
func (UnimplementedUserServiceServer) UpdateMemoView(context.Context, *UpdateMemoViewRequest) (*MemoView, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method UpdateMemoView not implemented")
|
||||
}
|
||||
func (UnimplementedUserServiceServer) DeleteMemoView(context.Context, *DeleteMemoViewRequest) (*emptypb.Empty, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method DeleteMemoView not implemented")
|
||||
}
|
||||
func (UnimplementedUserServiceServer) ListLinkedIdentities(context.Context, *ListLinkedIdentitiesRequest) (*ListLinkedIdentitiesResponse, error) {
|
||||
return nil, status.Error(codes.Unimplemented, "method ListLinkedIdentities not implemented")
|
||||
}
|
||||
|
|
@ -747,6 +841,96 @@ func _UserService_ListUserSettings_Handler(srv interface{}, ctx context.Context,
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserService_ListMemoViews_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListMemoViewsRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserServiceServer).ListMemoViews(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserService_ListMemoViews_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserServiceServer).ListMemoViews(ctx, req.(*ListMemoViewsRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserService_GetMemoView_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetMemoViewRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserServiceServer).GetMemoView(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserService_GetMemoView_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserServiceServer).GetMemoView(ctx, req.(*GetMemoViewRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserService_CreateMemoView_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(CreateMemoViewRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserServiceServer).CreateMemoView(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserService_CreateMemoView_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserServiceServer).CreateMemoView(ctx, req.(*CreateMemoViewRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserService_UpdateMemoView_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(UpdateMemoViewRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserServiceServer).UpdateMemoView(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserService_UpdateMemoView_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserServiceServer).UpdateMemoView(ctx, req.(*UpdateMemoViewRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserService_DeleteMemoView_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteMemoViewRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(UserServiceServer).DeleteMemoView(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: UserService_DeleteMemoView_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(UserServiceServer).DeleteMemoView(ctx, req.(*DeleteMemoViewRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _UserService_ListLinkedIdentities_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ListLinkedIdentitiesRequest)
|
||||
if err := dec(in); err != nil {
|
||||
|
|
@ -1068,6 +1252,26 @@ var UserService_ServiceDesc = grpc.ServiceDesc{
|
|||
MethodName: "ListUserSettings",
|
||||
Handler: _UserService_ListUserSettings_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListMemoViews",
|
||||
Handler: _UserService_ListMemoViews_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetMemoView",
|
||||
Handler: _UserService_GetMemoView_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreateMemoView",
|
||||
Handler: _UserService_CreateMemoView_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateMemoView",
|
||||
Handler: _UserService_UpdateMemoView_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeleteMemoView",
|
||||
Handler: _UserService_DeleteMemoView_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ListLinkedIdentities",
|
||||
Handler: _UserService_ListLinkedIdentities_Handler,
|
||||
|
|
|
|||
|
|
@ -228,6 +228,35 @@ paths:
|
|||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Status'
|
||||
/api/v1/attachments:upload:
|
||||
post:
|
||||
tags:
|
||||
- AttachmentService
|
||||
description: |-
|
||||
UploadAttachment uploads a file in bounded chunks. The first call carries
|
||||
the spec and returns an upload_id; later calls carry that upload_id.
|
||||
Uploads are bound to the authenticated user, expire after 30 minutes of
|
||||
inactivity, and do not survive a server restart.
|
||||
operationId: AttachmentService_UploadAttachment
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UploadAttachmentRequest'
|
||||
required: true
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/UploadAttachmentResponse'
|
||||
default:
|
||||
description: Default error response
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Status'
|
||||
/api/v1/auth/me:
|
||||
get:
|
||||
tags:
|
||||
|
|
@ -2489,12 +2518,12 @@ paths:
|
|||
/api/v1/users/{user}/views:
|
||||
get:
|
||||
tags:
|
||||
- MemoViewService
|
||||
- UserService
|
||||
description: |-
|
||||
ListMemoViews returns a user's memo views. Each view is a named, reusable
|
||||
CEL filter (see MemoView.filter); pass its filter string directly to the
|
||||
ListMemos `filter` argument.
|
||||
operationId: MemoViewService_ListMemoViews
|
||||
operationId: UserService_ListMemoViews
|
||||
parameters:
|
||||
- name: user
|
||||
in: path
|
||||
|
|
@ -2517,9 +2546,9 @@ paths:
|
|||
$ref: '#/components/schemas/Status'
|
||||
post:
|
||||
tags:
|
||||
- MemoViewService
|
||||
- UserService
|
||||
description: CreateMemoView creates a new memo view for a user.
|
||||
operationId: MemoViewService_CreateMemoView
|
||||
operationId: UserService_CreateMemoView
|
||||
parameters:
|
||||
- name: user
|
||||
in: path
|
||||
|
|
@ -2554,9 +2583,9 @@ paths:
|
|||
/api/v1/users/{user}/views/{view}:
|
||||
get:
|
||||
tags:
|
||||
- MemoViewService
|
||||
- UserService
|
||||
description: GetMemoView gets a memo view by name.
|
||||
operationId: MemoViewService_GetMemoView
|
||||
operationId: UserService_GetMemoView
|
||||
parameters:
|
||||
- name: user
|
||||
in: path
|
||||
|
|
@ -2585,9 +2614,9 @@ paths:
|
|||
$ref: '#/components/schemas/Status'
|
||||
delete:
|
||||
tags:
|
||||
- MemoViewService
|
||||
- UserService
|
||||
description: DeleteMemoView deletes a memo view for a user.
|
||||
operationId: MemoViewService_DeleteMemoView
|
||||
operationId: UserService_DeleteMemoView
|
||||
parameters:
|
||||
- name: user
|
||||
in: path
|
||||
|
|
@ -2613,9 +2642,9 @@ paths:
|
|||
$ref: '#/components/schemas/Status'
|
||||
patch:
|
||||
tags:
|
||||
- MemoViewService
|
||||
- UserService
|
||||
description: UpdateMemoView updates a memo view for a user.
|
||||
operationId: MemoViewService_UpdateMemoView
|
||||
operationId: UserService_UpdateMemoView
|
||||
parameters:
|
||||
- name: user
|
||||
in: path
|
||||
|
|
@ -3997,8 +4026,9 @@ components:
|
|||
readOnly: true
|
||||
type: string
|
||||
description: |-
|
||||
Output only. The readable context memo of this COMMENT relation, if any.
|
||||
This is omitted unless the caller may independently read both memos.
|
||||
Output only. The context memo of this COMMENT relation, if any.
|
||||
Its identity is returned even when the caller cannot read the parent.
|
||||
Fetch the parent independently; this field does not grant read access.
|
||||
Format: memos/{memo}
|
||||
snippet:
|
||||
readOnly: true
|
||||
|
|
@ -4089,6 +4119,22 @@ components:
|
|||
description: |-
|
||||
The CEL filter expression for the memo view, using the same grammar as the
|
||||
ListMemos `filter` argument. Reuse it by passing this value to ListMemos.
|
||||
icon:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/MemoView_Icon'
|
||||
description: |-
|
||||
Optional. Display icon. Omit when updating with the "icon" mask to reset
|
||||
to the default view icon.
|
||||
description: Saved memo view messages
|
||||
MemoView_Icon:
|
||||
type: object
|
||||
properties:
|
||||
emoji:
|
||||
type: string
|
||||
description: A Unicode emoji sequence.
|
||||
lucide:
|
||||
type: string
|
||||
description: A canonical Lucide icon name, such as "leaf".
|
||||
Memo_Property:
|
||||
type: object
|
||||
properties:
|
||||
|
|
@ -4398,6 +4444,12 @@ components:
|
|||
Output only. The number of accepted members in this space. Pending
|
||||
invitations are excluded. Zero when this Space is exposed as metadata-only.
|
||||
format: int32
|
||||
icon:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Space_Icon'
|
||||
description: |-
|
||||
Optional. Display icon. Omit when updating with the "icon" mask to reset
|
||||
to the default Space mark.
|
||||
description: Space is a collaboration boundary for placed memos.
|
||||
SpaceInvitation:
|
||||
required:
|
||||
|
|
@ -4448,6 +4500,15 @@ components:
|
|||
description: Required. The member's role within this space.
|
||||
format: enum
|
||||
description: SpaceMember is a user's membership and governance role in a space.
|
||||
Space_Icon:
|
||||
type: object
|
||||
properties:
|
||||
emoji:
|
||||
type: string
|
||||
description: A Unicode emoji sequence.
|
||||
lucide:
|
||||
type: string
|
||||
description: A canonical Lucide icon name, such as "leaf".
|
||||
Status:
|
||||
type: object
|
||||
properties:
|
||||
|
|
@ -4557,6 +4618,76 @@ components:
|
|||
contentType:
|
||||
type: string
|
||||
description: Optional. The MIME type of the input audio.
|
||||
UploadAttachmentRequest:
|
||||
required:
|
||||
- writeOffset
|
||||
type: object
|
||||
properties:
|
||||
spec:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/UploadAttachmentSpec'
|
||||
description: Starts a new upload. The same call may also carry data and finish_write.
|
||||
uploadId:
|
||||
type: string
|
||||
description: Continues the upload identified by a previous response.
|
||||
writeOffset:
|
||||
type: string
|
||||
description: |-
|
||||
Required. Zero-based byte offset at which data is written. Must equal the
|
||||
committed size, except when retrying the most recently accepted chunk
|
||||
with identical bytes and offset, which is accepted without writing again.
|
||||
data:
|
||||
type: string
|
||||
description: |-
|
||||
Optional. File bytes, at most max_chunk_size long. With no data and
|
||||
finish_write false, the call reports progress without writing, and
|
||||
write_offset is ignored.
|
||||
format: bytes
|
||||
finishWrite:
|
||||
type: boolean
|
||||
description: |-
|
||||
Optional. Finalize the upload after writing data. The committed size must
|
||||
then equal total_size. Any later call for the same upload_id returns the
|
||||
created attachment.
|
||||
UploadAttachmentResponse:
|
||||
type: object
|
||||
properties:
|
||||
uploadId:
|
||||
type: string
|
||||
description: Opaque ID for subsequent calls. This is not a resource name.
|
||||
committedSize:
|
||||
type: string
|
||||
description: Number of file bytes committed so far.
|
||||
attachment:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Attachment'
|
||||
description: Set once the upload has been finalized.
|
||||
maxChunkSize:
|
||||
type: integer
|
||||
description: Maximum number of data bytes accepted in one call.
|
||||
format: int32
|
||||
UploadAttachmentSpec:
|
||||
required:
|
||||
- attachment
|
||||
type: object
|
||||
properties:
|
||||
attachment:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/Attachment'
|
||||
description: |-
|
||||
Required. Metadata for the attachment to create. content must be empty;
|
||||
file bytes are sent in data.
|
||||
attachmentId:
|
||||
type: string
|
||||
description: |-
|
||||
Optional. The attachment ID to use for this attachment.
|
||||
If empty, a unique ID will be generated.
|
||||
Format: ^[a-zA-Z0-9]([a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?$
|
||||
totalSize:
|
||||
type: string
|
||||
description: |-
|
||||
Optional. Total size of the file in bytes before media processing.
|
||||
Zero represents an empty file.
|
||||
UpsertMemoReactionRequest:
|
||||
required:
|
||||
- name
|
||||
|
|
@ -4925,7 +5056,6 @@ tags:
|
|||
- name: IdentityProviderService
|
||||
- name: InstanceService
|
||||
- name: MemoService
|
||||
- name: MemoViewService
|
||||
- name: SpaceService
|
||||
description: SpaceService manages collaborative spaces and their memberships.
|
||||
- name: UserService
|
||||
|
|
|
|||
219
proto/gen/store/space.pb.go
Normal file
219
proto/gen/store/space.pb.go
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.36.12
|
||||
// protoc (unknown)
|
||||
// source: store/space.proto
|
||||
|
||||
package store
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
unsafe "unsafe"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// SpacePayload stores optional Space display metadata.
|
||||
type SpacePayload struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Icon *SpacePayload_Icon `protobuf:"bytes,1,opt,name=icon,proto3" json:"icon,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *SpacePayload) Reset() {
|
||||
*x = SpacePayload{}
|
||||
mi := &file_store_space_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *SpacePayload) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SpacePayload) ProtoMessage() {}
|
||||
|
||||
func (x *SpacePayload) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_store_space_proto_msgTypes[0]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SpacePayload.ProtoReflect.Descriptor instead.
|
||||
func (*SpacePayload) Descriptor() ([]byte, []int) {
|
||||
return file_store_space_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *SpacePayload) GetIcon() *SpacePayload_Icon {
|
||||
if x != nil {
|
||||
return x.Icon
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type SpacePayload_Icon struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Types that are valid to be assigned to Value:
|
||||
//
|
||||
// *SpacePayload_Icon_Emoji
|
||||
// *SpacePayload_Icon_Lucide
|
||||
Value isSpacePayload_Icon_Value `protobuf_oneof:"value"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *SpacePayload_Icon) Reset() {
|
||||
*x = SpacePayload_Icon{}
|
||||
mi := &file_store_space_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *SpacePayload_Icon) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SpacePayload_Icon) ProtoMessage() {}
|
||||
|
||||
func (x *SpacePayload_Icon) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_store_space_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SpacePayload_Icon.ProtoReflect.Descriptor instead.
|
||||
func (*SpacePayload_Icon) Descriptor() ([]byte, []int) {
|
||||
return file_store_space_proto_rawDescGZIP(), []int{0, 0}
|
||||
}
|
||||
|
||||
func (x *SpacePayload_Icon) GetValue() isSpacePayload_Icon_Value {
|
||||
if x != nil {
|
||||
return x.Value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *SpacePayload_Icon) GetEmoji() string {
|
||||
if x != nil {
|
||||
if x, ok := x.Value.(*SpacePayload_Icon_Emoji); ok {
|
||||
return x.Emoji
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *SpacePayload_Icon) GetLucide() string {
|
||||
if x != nil {
|
||||
if x, ok := x.Value.(*SpacePayload_Icon_Lucide); ok {
|
||||
return x.Lucide
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type isSpacePayload_Icon_Value interface {
|
||||
isSpacePayload_Icon_Value()
|
||||
}
|
||||
|
||||
type SpacePayload_Icon_Emoji struct {
|
||||
// A Unicode emoji sequence.
|
||||
Emoji string `protobuf:"bytes,1,opt,name=emoji,proto3,oneof"`
|
||||
}
|
||||
|
||||
type SpacePayload_Icon_Lucide struct {
|
||||
// A canonical Lucide icon name, such as "leaf".
|
||||
Lucide string `protobuf:"bytes,2,opt,name=lucide,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*SpacePayload_Icon_Emoji) isSpacePayload_Icon_Value() {}
|
||||
|
||||
func (*SpacePayload_Icon_Lucide) isSpacePayload_Icon_Value() {}
|
||||
|
||||
var File_store_space_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_store_space_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
"\x11store/space.proto\x12\vmemos.store\"\x85\x01\n" +
|
||||
"\fSpacePayload\x122\n" +
|
||||
"\x04icon\x18\x01 \x01(\v2\x1e.memos.store.SpacePayload.IconR\x04icon\x1aA\n" +
|
||||
"\x04Icon\x12\x16\n" +
|
||||
"\x05emoji\x18\x01 \x01(\tH\x00R\x05emoji\x12\x18\n" +
|
||||
"\x06lucide\x18\x02 \x01(\tH\x00R\x06lucideB\a\n" +
|
||||
"\x05valueB\x95\x01\n" +
|
||||
"\x0fcom.memos.storeB\n" +
|
||||
"SpaceProtoP\x01Z)github.com/usememos/memos/proto/gen/store\xa2\x02\x03MSX\xaa\x02\vMemos.Store\xca\x02\vMemos\\Store\xe2\x02\x17Memos\\Store\\GPBMetadata\xea\x02\fMemos::Storeb\x06proto3"
|
||||
|
||||
var (
|
||||
file_store_space_proto_rawDescOnce sync.Once
|
||||
file_store_space_proto_rawDescData []byte
|
||||
)
|
||||
|
||||
func file_store_space_proto_rawDescGZIP() []byte {
|
||||
file_store_space_proto_rawDescOnce.Do(func() {
|
||||
file_store_space_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_store_space_proto_rawDesc), len(file_store_space_proto_rawDesc)))
|
||||
})
|
||||
return file_store_space_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_store_space_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_store_space_proto_goTypes = []any{
|
||||
(*SpacePayload)(nil), // 0: memos.store.SpacePayload
|
||||
(*SpacePayload_Icon)(nil), // 1: memos.store.SpacePayload.Icon
|
||||
}
|
||||
var file_store_space_proto_depIdxs = []int32{
|
||||
1, // 0: memos.store.SpacePayload.icon:type_name -> memos.store.SpacePayload.Icon
|
||||
1, // [1:1] is the sub-list for method output_type
|
||||
1, // [1:1] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_store_space_proto_init() }
|
||||
func file_store_space_proto_init() {
|
||||
if File_store_space_proto != nil {
|
||||
return
|
||||
}
|
||||
file_store_space_proto_msgTypes[1].OneofWrappers = []any{
|
||||
(*SpacePayload_Icon_Emoji)(nil),
|
||||
(*SpacePayload_Icon_Lucide)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_store_space_proto_rawDesc), len(file_store_space_proto_rawDesc)),
|
||||
NumEnums: 0,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_store_space_proto_goTypes,
|
||||
DependencyIndexes: file_store_space_proto_depIdxs,
|
||||
MessageInfos: file_store_space_proto_msgTypes,
|
||||
}.Build()
|
||||
File_store_space_proto = out.File
|
||||
file_store_space_proto_goTypes = nil
|
||||
file_store_space_proto_depIdxs = nil
|
||||
}
|
||||
|
|
@ -857,10 +857,11 @@ func (x *PersonalAccessTokensUserSetting_PersonalAccessToken) GetLastUsedAt() *t
|
|||
}
|
||||
|
||||
type MemoViewsUserSetting_MemoView struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`
|
||||
Filter string `protobuf:"bytes,3,opt,name=filter,proto3" json:"filter,omitempty"`
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`
|
||||
Filter string `protobuf:"bytes,3,opt,name=filter,proto3" json:"filter,omitempty"`
|
||||
Icon *MemoViewsUserSetting_MemoView_Icon `protobuf:"bytes,4,opt,name=icon,proto3" json:"icon,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
|
@ -916,6 +917,97 @@ func (x *MemoViewsUserSetting_MemoView) GetFilter() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (x *MemoViewsUserSetting_MemoView) GetIcon() *MemoViewsUserSetting_MemoView_Icon {
|
||||
if x != nil {
|
||||
return x.Icon
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type MemoViewsUserSetting_MemoView_Icon struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Types that are valid to be assigned to Value:
|
||||
//
|
||||
// *MemoViewsUserSetting_MemoView_Icon_Emoji
|
||||
// *MemoViewsUserSetting_MemoView_Icon_Lucide
|
||||
Value isMemoViewsUserSetting_MemoView_Icon_Value `protobuf_oneof:"value"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *MemoViewsUserSetting_MemoView_Icon) Reset() {
|
||||
*x = MemoViewsUserSetting_MemoView_Icon{}
|
||||
mi := &file_store_user_setting_proto_msgTypes[13]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *MemoViewsUserSetting_MemoView_Icon) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*MemoViewsUserSetting_MemoView_Icon) ProtoMessage() {}
|
||||
|
||||
func (x *MemoViewsUserSetting_MemoView_Icon) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_store_user_setting_proto_msgTypes[13]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use MemoViewsUserSetting_MemoView_Icon.ProtoReflect.Descriptor instead.
|
||||
func (*MemoViewsUserSetting_MemoView_Icon) Descriptor() ([]byte, []int) {
|
||||
return file_store_user_setting_proto_rawDescGZIP(), []int{6, 0, 0}
|
||||
}
|
||||
|
||||
func (x *MemoViewsUserSetting_MemoView_Icon) GetValue() isMemoViewsUserSetting_MemoView_Icon_Value {
|
||||
if x != nil {
|
||||
return x.Value
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *MemoViewsUserSetting_MemoView_Icon) GetEmoji() string {
|
||||
if x != nil {
|
||||
if x, ok := x.Value.(*MemoViewsUserSetting_MemoView_Icon_Emoji); ok {
|
||||
return x.Emoji
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MemoViewsUserSetting_MemoView_Icon) GetLucide() string {
|
||||
if x != nil {
|
||||
if x, ok := x.Value.(*MemoViewsUserSetting_MemoView_Icon_Lucide); ok {
|
||||
return x.Lucide
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type isMemoViewsUserSetting_MemoView_Icon_Value interface {
|
||||
isMemoViewsUserSetting_MemoView_Icon_Value()
|
||||
}
|
||||
|
||||
type MemoViewsUserSetting_MemoView_Icon_Emoji struct {
|
||||
// A Unicode emoji sequence.
|
||||
Emoji string `protobuf:"bytes,1,opt,name=emoji,proto3,oneof"`
|
||||
}
|
||||
|
||||
type MemoViewsUserSetting_MemoView_Icon_Lucide struct {
|
||||
// A canonical Lucide icon name, such as "leaf".
|
||||
Lucide string `protobuf:"bytes,2,opt,name=lucide,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*MemoViewsUserSetting_MemoView_Icon_Emoji) isMemoViewsUserSetting_MemoView_Icon_Value() {}
|
||||
|
||||
func (*MemoViewsUserSetting_MemoView_Icon_Lucide) isMemoViewsUserSetting_MemoView_Icon_Value() {}
|
||||
|
||||
type WebhooksUserSetting_Webhook struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Unique identifier for the webhook
|
||||
|
|
@ -932,7 +1024,7 @@ type WebhooksUserSetting_Webhook struct {
|
|||
|
||||
func (x *WebhooksUserSetting_Webhook) Reset() {
|
||||
*x = WebhooksUserSetting_Webhook{}
|
||||
mi := &file_store_user_setting_proto_msgTypes[13]
|
||||
mi := &file_store_user_setting_proto_msgTypes[14]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -944,7 +1036,7 @@ func (x *WebhooksUserSetting_Webhook) String() string {
|
|||
func (*WebhooksUserSetting_Webhook) ProtoMessage() {}
|
||||
|
||||
func (x *WebhooksUserSetting_Webhook) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_store_user_setting_proto_msgTypes[13]
|
||||
mi := &file_store_user_setting_proto_msgTypes[14]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -1060,14 +1152,19 @@ const file_store_user_setting_proto_rawDesc = "" +
|
|||
"\n" +
|
||||
"created_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x12<\n" +
|
||||
"\flast_used_at\x18\x06 \x01(\v2\x1a.google.protobuf.TimestampR\n" +
|
||||
"lastUsedAt\"\xab\x01\n" +
|
||||
"lastUsedAt\"\xb4\x02\n" +
|
||||
"\x14MemoViewsUserSetting\x12I\n" +
|
||||
"\n" +
|
||||
"memo_views\x18\x01 \x03(\v2*.memos.store.MemoViewsUserSetting.MemoViewR\tmemoViews\x1aH\n" +
|
||||
"memo_views\x18\x01 \x03(\v2*.memos.store.MemoViewsUserSetting.MemoViewR\tmemoViews\x1a\xd0\x01\n" +
|
||||
"\bMemoView\x12\x0e\n" +
|
||||
"\x02id\x18\x01 \x01(\tR\x02id\x12\x14\n" +
|
||||
"\x05title\x18\x02 \x01(\tR\x05title\x12\x16\n" +
|
||||
"\x06filter\x18\x03 \x01(\tR\x06filter\"\xc5\x01\n" +
|
||||
"\x06filter\x18\x03 \x01(\tR\x06filter\x12C\n" +
|
||||
"\x04icon\x18\x04 \x01(\v2/.memos.store.MemoViewsUserSetting.MemoView.IconR\x04icon\x1aA\n" +
|
||||
"\x04Icon\x12\x16\n" +
|
||||
"\x05emoji\x18\x01 \x01(\tH\x00R\x05emoji\x12\x18\n" +
|
||||
"\x06lucide\x18\x02 \x01(\tH\x00R\x06lucideB\a\n" +
|
||||
"\x05value\"\xc5\x01\n" +
|
||||
"\x13WebhooksUserSetting\x12D\n" +
|
||||
"\bwebhooks\x18\x01 \x03(\v2(.memos.store.WebhooksUserSetting.WebhookR\bwebhooks\x1ah\n" +
|
||||
"\aWebhook\x12\x0e\n" +
|
||||
|
|
@ -1090,7 +1187,7 @@ func file_store_user_setting_proto_rawDescGZIP() []byte {
|
|||
}
|
||||
|
||||
var file_store_user_setting_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_store_user_setting_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
|
||||
var file_store_user_setting_proto_msgTypes = make([]protoimpl.MessageInfo, 15)
|
||||
var file_store_user_setting_proto_goTypes = []any{
|
||||
(UserSetting_Key)(0), // 0: memos.store.UserSetting.Key
|
||||
(*UserSetting)(nil), // 1: memos.store.UserSetting
|
||||
|
|
@ -1106,9 +1203,10 @@ var file_store_user_setting_proto_goTypes = []any{
|
|||
(*RefreshTokensUserSetting_ClientInfo)(nil), // 11: memos.store.RefreshTokensUserSetting.ClientInfo
|
||||
(*PersonalAccessTokensUserSetting_PersonalAccessToken)(nil), // 12: memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken
|
||||
(*MemoViewsUserSetting_MemoView)(nil), // 13: memos.store.MemoViewsUserSetting.MemoView
|
||||
(*WebhooksUserSetting_Webhook)(nil), // 14: memos.store.WebhooksUserSetting.Webhook
|
||||
(*color.Color)(nil), // 15: google.type.Color
|
||||
(*timestamppb.Timestamp)(nil), // 16: google.protobuf.Timestamp
|
||||
(*MemoViewsUserSetting_MemoView_Icon)(nil), // 14: memos.store.MemoViewsUserSetting.MemoView.Icon
|
||||
(*WebhooksUserSetting_Webhook)(nil), // 15: memos.store.WebhooksUserSetting.Webhook
|
||||
(*color.Color)(nil), // 16: google.type.Color
|
||||
(*timestamppb.Timestamp)(nil), // 17: google.protobuf.Timestamp
|
||||
}
|
||||
var file_store_user_setting_proto_depIdxs = []int32{
|
||||
0, // 0: memos.store.UserSetting.key:type_name -> memos.store.UserSetting.Key
|
||||
|
|
@ -1118,24 +1216,25 @@ var file_store_user_setting_proto_depIdxs = []int32{
|
|||
5, // 4: memos.store.UserSetting.refresh_tokens:type_name -> memos.store.RefreshTokensUserSetting
|
||||
6, // 5: memos.store.UserSetting.personal_access_tokens:type_name -> memos.store.PersonalAccessTokensUserSetting
|
||||
4, // 6: memos.store.UserSetting.tags:type_name -> memos.store.TagsUserSetting
|
||||
15, // 7: memos.store.UserTagMetadata.background_color:type_name -> google.type.Color
|
||||
16, // 7: memos.store.UserTagMetadata.background_color:type_name -> google.type.Color
|
||||
9, // 8: memos.store.TagsUserSetting.tags:type_name -> memos.store.TagsUserSetting.TagsEntry
|
||||
10, // 9: memos.store.RefreshTokensUserSetting.refresh_tokens:type_name -> memos.store.RefreshTokensUserSetting.RefreshToken
|
||||
12, // 10: memos.store.PersonalAccessTokensUserSetting.tokens:type_name -> memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken
|
||||
13, // 11: memos.store.MemoViewsUserSetting.memo_views:type_name -> memos.store.MemoViewsUserSetting.MemoView
|
||||
14, // 12: memos.store.WebhooksUserSetting.webhooks:type_name -> memos.store.WebhooksUserSetting.Webhook
|
||||
15, // 12: memos.store.WebhooksUserSetting.webhooks:type_name -> memos.store.WebhooksUserSetting.Webhook
|
||||
3, // 13: memos.store.TagsUserSetting.TagsEntry.value:type_name -> memos.store.UserTagMetadata
|
||||
16, // 14: memos.store.RefreshTokensUserSetting.RefreshToken.expires_at:type_name -> google.protobuf.Timestamp
|
||||
16, // 15: memos.store.RefreshTokensUserSetting.RefreshToken.created_at:type_name -> google.protobuf.Timestamp
|
||||
17, // 14: memos.store.RefreshTokensUserSetting.RefreshToken.expires_at:type_name -> google.protobuf.Timestamp
|
||||
17, // 15: memos.store.RefreshTokensUserSetting.RefreshToken.created_at:type_name -> google.protobuf.Timestamp
|
||||
11, // 16: memos.store.RefreshTokensUserSetting.RefreshToken.client_info:type_name -> memos.store.RefreshTokensUserSetting.ClientInfo
|
||||
16, // 17: memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken.expires_at:type_name -> google.protobuf.Timestamp
|
||||
16, // 18: memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken.created_at:type_name -> google.protobuf.Timestamp
|
||||
16, // 19: memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken.last_used_at:type_name -> google.protobuf.Timestamp
|
||||
20, // [20:20] is the sub-list for method output_type
|
||||
20, // [20:20] is the sub-list for method input_type
|
||||
20, // [20:20] is the sub-list for extension type_name
|
||||
20, // [20:20] is the sub-list for extension extendee
|
||||
0, // [0:20] is the sub-list for field type_name
|
||||
17, // 17: memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken.expires_at:type_name -> google.protobuf.Timestamp
|
||||
17, // 18: memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken.created_at:type_name -> google.protobuf.Timestamp
|
||||
17, // 19: memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken.last_used_at:type_name -> google.protobuf.Timestamp
|
||||
14, // 20: memos.store.MemoViewsUserSetting.MemoView.icon:type_name -> memos.store.MemoViewsUserSetting.MemoView.Icon
|
||||
21, // [21:21] is the sub-list for method output_type
|
||||
21, // [21:21] is the sub-list for method input_type
|
||||
21, // [21:21] is the sub-list for extension type_name
|
||||
21, // [21:21] is the sub-list for extension extendee
|
||||
0, // [0:21] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_store_user_setting_proto_init() }
|
||||
|
|
@ -1151,13 +1250,17 @@ func file_store_user_setting_proto_init() {
|
|||
(*UserSetting_PersonalAccessTokens)(nil),
|
||||
(*UserSetting_Tags)(nil),
|
||||
}
|
||||
file_store_user_setting_proto_msgTypes[13].OneofWrappers = []any{
|
||||
(*MemoViewsUserSetting_MemoView_Icon_Emoji)(nil),
|
||||
(*MemoViewsUserSetting_MemoView_Icon_Lucide)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_store_user_setting_proto_rawDesc), len(file_store_user_setting_proto_rawDesc)),
|
||||
NumEnums: 1,
|
||||
NumMessages: 14,
|
||||
NumMessages: 15,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
|
|
|||
19
proto/store/space.proto
Normal file
19
proto/store/space.proto
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
syntax = "proto3";
|
||||
|
||||
package memos.store;
|
||||
|
||||
option go_package = "gen/store";
|
||||
|
||||
// SpacePayload stores optional Space display metadata.
|
||||
message SpacePayload {
|
||||
Icon icon = 1;
|
||||
|
||||
message Icon {
|
||||
oneof value {
|
||||
// A Unicode emoji sequence.
|
||||
string emoji = 1;
|
||||
// A canonical Lucide icon name, such as "leaf".
|
||||
string lucide = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -118,6 +118,16 @@ message MemoViewsUserSetting {
|
|||
string id = 1;
|
||||
string title = 2;
|
||||
string filter = 3;
|
||||
Icon icon = 4;
|
||||
|
||||
message Icon {
|
||||
oneof value {
|
||||
// A Unicode emoji sequence.
|
||||
string emoji = 1;
|
||||
// A canonical Lucide icon name, such as "leaf".
|
||||
string lucide = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
repeated MemoView memo_views = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ func TestPublicMethodsArePublic(t *testing.T) {
|
|||
// TestProtectedMethodsRequireAuth verifies that non-public methods are recognized as protected.
|
||||
func TestProtectedMethodsRequireAuth(t *testing.T) {
|
||||
protectedMethods := []string{
|
||||
"/memos.api.v1.AttachmentService/UploadAttachment",
|
||||
// Auth Service - logout and get current user require auth
|
||||
"/memos.api.v1.AuthService/SignOut",
|
||||
"/memos.api.v1.AuthService/GetCurrentUser",
|
||||
|
|
@ -82,12 +83,12 @@ func TestProtectedMethodsRequireAuth(t *testing.T) {
|
|||
// Attachment Service - write operations
|
||||
"/memos.api.v1.AttachmentService/CreateAttachment",
|
||||
"/memos.api.v1.AttachmentService/DeleteAttachment",
|
||||
// Memo View Service
|
||||
"/memos.api.v1.MemoViewService/CreateMemoView",
|
||||
"/memos.api.v1.MemoViewService/GetMemoView",
|
||||
"/memos.api.v1.MemoViewService/ListMemoViews",
|
||||
"/memos.api.v1.MemoViewService/UpdateMemoView",
|
||||
"/memos.api.v1.MemoViewService/DeleteMemoView",
|
||||
// User Service - saved memo views
|
||||
"/memos.api.v1.UserService/CreateMemoView",
|
||||
"/memos.api.v1.UserService/GetMemoView",
|
||||
"/memos.api.v1.UserService/ListMemoViews",
|
||||
"/memos.api.v1.UserService/UpdateMemoView",
|
||||
"/memos.api.v1.UserService/DeleteMemoView",
|
||||
}
|
||||
|
||||
for _, method := range protectedMethods {
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ func TestStripImageExif(t *testing.T) {
|
|||
t.Run("strip JPEG metadata", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
strippedData, err := stripImageExif(originalData, "image/jpeg")
|
||||
strippedData, err := stripImageExif(bytes.NewReader(originalData), "image/jpeg")
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, strippedData)
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ func TestStripImageExif(t *testing.T) {
|
|||
t.Run("strip JPG metadata (alternate extension)", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
strippedData, err := stripImageExif(originalData, "image/jpg")
|
||||
strippedData, err := stripImageExif(bytes.NewReader(originalData), "image/jpg")
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, strippedData)
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ func TestStripImageExif(t *testing.T) {
|
|||
err := imaging.Encode(&pngBuf, img, imaging.PNG)
|
||||
require.NoError(t, err)
|
||||
|
||||
strippedData, err := stripImageExif(pngBuf.Bytes(), "image/png")
|
||||
strippedData, err := stripImageExif(bytes.NewReader(pngBuf.Bytes()), "image/png")
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, strippedData)
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ func TestStripImageExif(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
// WebP format will be converted to JPEG
|
||||
strippedData, err := stripImageExif(originalData, "image/webp")
|
||||
strippedData, err := stripImageExif(bytes.NewReader(originalData), "image/webp")
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, strippedData)
|
||||
|
||||
|
|
@ -164,7 +164,7 @@ func TestStripImageExif(t *testing.T) {
|
|||
t.Run("handle HEIC format by converting to JPEG", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
strippedData, err := stripImageExif(originalData, "image/heic")
|
||||
strippedData, err := stripImageExif(bytes.NewReader(originalData), "image/heic")
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, strippedData)
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ func TestStripImageExif(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
invalidData := []byte("not an image")
|
||||
_, err := stripImageExif(invalidData, "image/jpeg")
|
||||
_, err := stripImageExif(bytes.NewReader(invalidData), "image/jpeg")
|
||||
assert.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "failed to decode image")
|
||||
})
|
||||
|
|
@ -187,7 +187,7 @@ func TestStripImageExif(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
emptyData := []byte{}
|
||||
_, err := stripImageExif(emptyData, "image/jpeg")
|
||||
_, err := stripImageExif(bytes.NewReader(emptyData), "image/jpeg")
|
||||
assert.Error(t, err)
|
||||
})
|
||||
}
|
||||
|
|
@ -195,7 +195,7 @@ func TestStripImageExif(t *testing.T) {
|
|||
func TestValidateImagePixelCountRejectsOversizedDimensions(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
err := validateImagePixelCount(testPNGHeaderWithDimensions(100_000, 100_000))
|
||||
err := validateImageReaderPixelCount(bytes.NewReader(testPNGHeaderWithDimensions(100_000, 100_000)))
|
||||
require.Error(t, err)
|
||||
require.Contains(t, err.Error(), "image dimensions exceed maximum")
|
||||
}
|
||||
|
|
@ -203,7 +203,7 @@ func TestValidateImagePixelCountRejectsOversizedDimensions(t *testing.T) {
|
|||
func TestStripImageExifRejectsOversizedDimensionsBeforeDecode(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
_, err := stripImageExif(testPNGHeaderWithDimensions(100_000, 100_000), "image/png")
|
||||
_, err := stripImageExif(bytes.NewReader(testPNGHeaderWithDimensions(100_000, 100_000)), "image/png")
|
||||
require.Error(t, err)
|
||||
require.Contains(t, err.Error(), "image dimensions exceed maximum")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"math"
|
||||
"mime"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
|
|
@ -15,16 +17,16 @@ import (
|
|||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
|
||||
"github.com/usememos/memos/internal/motionphoto"
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
const (
|
||||
// The upload memory buffer is 32 MiB.
|
||||
// It should be kept low, so RAM usage doesn't get out of control.
|
||||
// This is unrelated to maximum upload size limit, which is now set through system setting.
|
||||
MaxUploadBufferSizeBytes = 32 << 20
|
||||
MebiByte = 1024 * 1024
|
||||
// DefaultUploadSizeLimitBytes applies when no upload size limit is configured.
|
||||
DefaultUploadSizeLimitBytes = 32 << 20
|
||||
MebiByte = 1024 * 1024
|
||||
|
||||
// defaultJPEGQuality is the JPEG quality used when re-encoding images for EXIF stripping.
|
||||
// Quality 95 maintains visual quality while ensuring metadata is removed.
|
||||
|
|
@ -71,7 +73,7 @@ func detectAttachmentMimeType(filename string, content []byte) string {
|
|||
return http.DetectContentType(content)
|
||||
}
|
||||
|
||||
func (s *APIV1Service) CreateAttachment(ctx context.Context, request *v1pb.CreateAttachmentRequest) (*v1pb.Attachment, error) {
|
||||
func (s *APIV1Service) prepareAttachment(ctx context.Context, request *v1pb.CreateAttachmentRequest) (*store.Attachment, error) {
|
||||
user, err := s.fetchCurrentUser(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get current user: %v", err)
|
||||
|
|
@ -135,21 +137,6 @@ func (s *APIV1Service) CreateAttachment(ctx context.Context, request *v1pb.Creat
|
|||
create.Payload.MediaMetadata = inputMediaMetadata
|
||||
}
|
||||
|
||||
instanceStorageSetting, err := s.Store.GetInstanceStorageSetting(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get instance storage setting: %v", err)
|
||||
}
|
||||
size := binary.Size(request.Attachment.Content)
|
||||
uploadSizeLimit := int(instanceStorageSetting.UploadSizeLimitMb) * MebiByte
|
||||
if uploadSizeLimit == 0 {
|
||||
uploadSizeLimit = MaxUploadBufferSizeBytes
|
||||
}
|
||||
if size > uploadSizeLimit {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "file size exceeds the limit")
|
||||
}
|
||||
create.Size = int64(size)
|
||||
create.Blob = request.Attachment.Content
|
||||
|
||||
if request.Attachment.Memo != nil {
|
||||
memoUID, err := ExtractMemoUIDFromName(*request.Attachment.Memo)
|
||||
if err != nil {
|
||||
|
|
@ -172,21 +159,77 @@ func (s *APIV1Service) CreateAttachment(ctx context.Context, request *v1pb.Creat
|
|||
create.Policy = memoWritePolicy(user.ID, false)
|
||||
}
|
||||
|
||||
if create.Payload == nil || create.Payload.MotionMedia == nil {
|
||||
if detectedMotion := detectAndroidMotionMedia(create.Blob, create.Type, attachmentUID); detectedMotion != nil {
|
||||
return create, nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) CreateAttachment(ctx context.Context, request *v1pb.CreateAttachmentRequest) (*v1pb.Attachment, error) {
|
||||
create, err := s.prepareAttachment(ctx, request)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
instanceStorageSetting, err := s.Store.GetInstanceStorageSetting(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get instance storage setting: %v", err)
|
||||
}
|
||||
content := request.Attachment.Content
|
||||
if err := checkUploadSize(instanceStorageSetting, int64(len(content))); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
create.Size = int64(len(content))
|
||||
return s.processAndSaveAttachment(ctx, create, instanceStorageSetting, bytes.NewReader(content))
|
||||
}
|
||||
|
||||
func attachmentUploadLimit(setting *storepb.InstanceStorageSetting) int64 {
|
||||
if setting.UploadSizeLimitMb <= 0 {
|
||||
return DefaultUploadSizeLimitBytes
|
||||
}
|
||||
return min(setting.UploadSizeLimitMb, math.MaxInt64/MebiByte) * MebiByte
|
||||
}
|
||||
|
||||
func checkUploadSize(setting *storepb.InstanceStorageSetting, size int64) error {
|
||||
if size > attachmentUploadLimit(setting) {
|
||||
return status.Errorf(codes.ResourceExhausted, "file size exceeds the limit")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// attachmentSource is the file content handed to the processing pipeline: a
|
||||
// bytes.Reader for the one-shot RPC, an *os.File for a chunked upload.
|
||||
type attachmentSource interface {
|
||||
io.ReadSeeker
|
||||
io.ReaderAt
|
||||
}
|
||||
|
||||
// processAndSaveAttachment detects motion photos, strips EXIF metadata, stores
|
||||
// the content, and creates the database row. create.Size must hold the source
|
||||
// length on entry; it is updated when stripping re-encodes the image.
|
||||
func (s *APIV1Service) processAndSaveAttachment(ctx context.Context, create *store.Attachment, instanceStorageSetting *storepb.InstanceStorageSetting, source attachmentSource) (*v1pb.Attachment, error) {
|
||||
if create.Payload.GetMotionMedia() == nil && (create.Type == "image/jpeg" || create.Type == "image/jpg") {
|
||||
detected, err := motionphoto.DetectJPEGReader(source, create.Size)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to inspect motion photo: %v", err)
|
||||
}
|
||||
if detected != nil {
|
||||
create.Payload = ensureAttachmentPayload(create.Payload)
|
||||
create.Payload.MotionMedia = detectedMotion
|
||||
create.Payload.MotionMedia = &storepb.MotionMedia{
|
||||
Family: storepb.MotionMediaFamily_ANDROID_MOTION_PHOTO,
|
||||
Role: storepb.MotionMediaRole_CONTAINER,
|
||||
GroupId: create.UID,
|
||||
PresentationTimestampUs: detected.PresentationTimestampUs,
|
||||
HasEmbeddedVideo: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Strip EXIF metadata from images for privacy protection.
|
||||
// This removes sensitive information like GPS location, device details, etc.
|
||||
content := io.ReadSeeker(source)
|
||||
// Strip EXIF metadata from images for privacy protection. Motion photo
|
||||
// containers are kept intact because re-encoding would drop the video.
|
||||
if shouldStripExif(create.Type) && !isAndroidMotionContainer(create.Payload.GetMotionMedia()) {
|
||||
release, err := s.acquireImageProcessingSlot(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.ResourceExhausted, "too many image processing requests")
|
||||
}
|
||||
strippedBlob, stripErr := stripImageExif(create.Blob, create.Type)
|
||||
stripped, stripErr := stripImageExif(source, create.Type)
|
||||
release()
|
||||
if stripErr != nil {
|
||||
// Log warning but continue with original image to ensure uploads don't fail.
|
||||
|
|
@ -195,15 +238,21 @@ func (s *APIV1Service) CreateAttachment(ctx context.Context, request *v1pb.Creat
|
|||
slog.String("filename", create.Filename),
|
||||
slog.String("error", stripErr.Error()))
|
||||
} else {
|
||||
create.Blob = strippedBlob
|
||||
create.Size = int64(len(strippedBlob))
|
||||
content = bytes.NewReader(stripped)
|
||||
create.Size = int64(len(stripped))
|
||||
}
|
||||
}
|
||||
|
||||
if err := saveAttachmentBlobWithInstanceStorageSetting(ctx, s.Profile, s.Store, create, instanceStorageSetting); err != nil {
|
||||
if _, err := content.Seek(0, io.SeekStart); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to rewind attachment content: %v", err)
|
||||
}
|
||||
if err := saveAttachmentContent(ctx, s.Profile, s.Store, create, instanceStorageSetting, content); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to save attachment blob: %v", err)
|
||||
}
|
||||
return s.persistAttachment(ctx, create, instanceStorageSetting)
|
||||
}
|
||||
|
||||
func (s *APIV1Service) persistAttachment(ctx context.Context, create *store.Attachment, instanceStorageSetting *storepb.InstanceStorageSetting) (*v1pb.Attachment, error) {
|
||||
attachment, err := s.Store.CreateAttachment(ctx, create)
|
||||
if err != nil {
|
||||
createErr := mapMemoWriteError(err, "failed to create attachment")
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ import (
|
|||
"bytes"
|
||||
"context"
|
||||
"image"
|
||||
"io"
|
||||
|
||||
"github.com/disintegration/imaging"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/usememos/memos/internal/motionphoto"
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
)
|
||||
|
|
@ -38,25 +38,6 @@ func validateClientMotionMedia(motion *v1pb.MotionMedia, attachmentUID string) (
|
|||
return storeMotion, nil
|
||||
}
|
||||
|
||||
func detectAndroidMotionMedia(blob []byte, mimeType, attachmentUID string) *storepb.MotionMedia {
|
||||
if mimeType != "image/jpeg" && mimeType != "image/jpg" {
|
||||
return nil
|
||||
}
|
||||
|
||||
detection := motionphoto.DetectJPEG(blob)
|
||||
if detection == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return &storepb.MotionMedia{
|
||||
Family: storepb.MotionMediaFamily_ANDROID_MOTION_PHOTO,
|
||||
Role: storepb.MotionMediaRole_CONTAINER,
|
||||
GroupId: attachmentUID,
|
||||
PresentationTimestampUs: detection.PresentationTimestampUs,
|
||||
HasEmbeddedVideo: true,
|
||||
}
|
||||
}
|
||||
|
||||
// shouldStripExif checks if the MIME type is an image format that may contain EXIF metadata.
|
||||
// Returns true for formats like JPEG, TIFF, WebP, HEIC, and HEIF which commonly contain
|
||||
// privacy-sensitive metadata such as GPS coordinates, camera settings, and device information.
|
||||
|
|
@ -76,8 +57,8 @@ func (s *APIV1Service) acquireImageProcessingSlot(ctx context.Context) (func(),
|
|||
}, nil
|
||||
}
|
||||
|
||||
func validateImagePixelCount(imageData []byte) error {
|
||||
config, _, err := image.DecodeConfig(bytes.NewReader(imageData))
|
||||
func validateImageReaderPixelCount(reader io.Reader) error {
|
||||
config, _, err := image.DecodeConfig(reader)
|
||||
if err != nil {
|
||||
// Some formats supported by imaging do not expose dimensions through
|
||||
// the standard image registry. Let the full decoder handle those.
|
||||
|
|
@ -97,7 +78,8 @@ func validateImagePixelCount(imageData []byte) error {
|
|||
//
|
||||
// The function preserves the correct image orientation by applying EXIF orientation tags
|
||||
// during decoding before stripping all metadata. Images are re-encoded with high quality
|
||||
// to minimize visual degradation.
|
||||
// to minimize visual degradation. The re-encoded output is returned in memory; its size
|
||||
// is bounded by maxImagePixels, which the decoder already has to hold.
|
||||
//
|
||||
// Supported formats:
|
||||
// - JPEG/JPG: Re-encoded as JPEG with quality 95
|
||||
|
|
@ -105,34 +87,28 @@ func validateImagePixelCount(imageData []byte) error {
|
|||
// - TIFF/WebP/HEIC/HEIF: Re-encoded as JPEG with quality 95
|
||||
//
|
||||
// Returns the cleaned image data without any EXIF metadata, or an error if processing fails.
|
||||
func stripImageExif(imageData []byte, mimeType string) ([]byte, error) {
|
||||
if err := validateImagePixelCount(imageData); err != nil {
|
||||
func stripImageExif(source io.ReadSeeker, mimeType string) ([]byte, error) {
|
||||
if _, err := source.Seek(0, io.SeekStart); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to rewind image")
|
||||
}
|
||||
if err := validateImageReaderPixelCount(source); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Decode image with automatic EXIF orientation correction.
|
||||
// This ensures the image displays correctly after metadata removal.
|
||||
img, err := imaging.Decode(bytes.NewReader(imageData), imaging.AutoOrientation(true))
|
||||
if _, err := source.Seek(0, io.SeekStart); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to rewind image")
|
||||
}
|
||||
img, err := imaging.Decode(source, imaging.AutoOrientation(true))
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to decode image")
|
||||
}
|
||||
|
||||
// Re-encode the image without EXIF metadata.
|
||||
var buf bytes.Buffer
|
||||
var encodeErr error
|
||||
|
||||
if mimeType == "image/png" {
|
||||
// Preserve PNG format for lossless encoding
|
||||
encodeErr = imaging.Encode(&buf, img, imaging.PNG)
|
||||
err = imaging.Encode(&buf, img, imaging.PNG)
|
||||
} else {
|
||||
// For JPEG, TIFF, WebP, HEIC, HEIF - re-encode as JPEG.
|
||||
// This ensures EXIF is stripped and provides good compression.
|
||||
encodeErr = imaging.Encode(&buf, img, imaging.JPEG, imaging.JPEGQuality(defaultJPEGQuality))
|
||||
err = imaging.Encode(&buf, img, imaging.JPEG, imaging.JPEGQuality(defaultJPEGQuality))
|
||||
}
|
||||
|
||||
if encodeErr != nil {
|
||||
return nil, errors.Wrap(encodeErr, "failed to encode image")
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to encode image")
|
||||
}
|
||||
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
|
|
@ -46,21 +45,29 @@ func convertAttachmentFromStore(attachment *store.Attachment) *v1pb.Attachment {
|
|||
return attachmentMessage
|
||||
}
|
||||
|
||||
// SaveAttachmentBlob saves the blob of attachment based on the storage config.
|
||||
func SaveAttachmentBlob(ctx context.Context, profile *profile.Profile, stores *store.Store, create *store.Attachment) error {
|
||||
instanceStorageSetting, err := stores.GetInstanceStorageSetting(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to find instance storage setting")
|
||||
}
|
||||
return saveAttachmentBlobWithInstanceStorageSetting(ctx, profile, stores, create, instanceStorageSetting)
|
||||
// attachmentContextReader stops a long local copy once the request context is
|
||||
// canceled; io.Copy has no context of its own, unlike the S3 client.
|
||||
type attachmentContextReader struct {
|
||||
ctx context.Context
|
||||
reader io.Reader
|
||||
}
|
||||
|
||||
func saveAttachmentBlobWithInstanceStorageSetting(
|
||||
func (r *attachmentContextReader) Read(p []byte) (int, error) {
|
||||
if err := r.ctx.Err(); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return r.reader.Read(p)
|
||||
}
|
||||
|
||||
// saveAttachmentContent writes content to the default storage and records
|
||||
// where it went on create. Database storage keeps the bytes on create.Blob.
|
||||
func saveAttachmentContent(
|
||||
ctx context.Context,
|
||||
profile *profile.Profile,
|
||||
stores *store.Store,
|
||||
create *store.Attachment,
|
||||
instanceStorageSetting *storepb.InstanceStorageSetting,
|
||||
content io.Reader,
|
||||
) error {
|
||||
defaultStorage := store.GetDefaultStorage(instanceStorageSetting)
|
||||
if defaultStorage == nil {
|
||||
|
|
@ -99,9 +106,24 @@ func saveAttachmentBlobWithInstanceStorageSetting(
|
|||
return errors.Wrap(err, "Failed to create directory")
|
||||
}
|
||||
|
||||
// Write the blob to the file.
|
||||
if err := os.WriteFile(osPath, create.Blob, 0644); err != nil {
|
||||
return errors.Wrap(err, "Failed to write file")
|
||||
// Stage in a temp file so partial content never appears at the final path.
|
||||
file, err := os.CreateTemp(dir, ".memos-upload-*")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to create attachment file")
|
||||
}
|
||||
defer os.Remove(file.Name())
|
||||
defer file.Close()
|
||||
if _, err := io.Copy(file, &attachmentContextReader{ctx: ctx, reader: content}); err != nil {
|
||||
return errors.Wrap(err, "failed to write attachment file")
|
||||
}
|
||||
if err := file.Chmod(0644); err != nil {
|
||||
return errors.Wrap(err, "failed to set attachment permissions")
|
||||
}
|
||||
if err := file.Close(); err != nil {
|
||||
return errors.Wrap(err, "failed to close attachment file")
|
||||
}
|
||||
if err := os.Rename(file.Name(), osPath); err != nil {
|
||||
return errors.Wrap(err, "failed to finalize attachment file")
|
||||
}
|
||||
create.Reference = internalPath
|
||||
create.Blob = nil
|
||||
|
|
@ -117,7 +139,7 @@ func saveAttachmentBlobWithInstanceStorageSetting(
|
|||
filepathTemplate = filepath.Join(filepathTemplate, "{filename}")
|
||||
}
|
||||
filepathTemplate = replaceFilenameWithPathTemplate(filepathTemplate, create.Filename)
|
||||
key, err := driver.UploadObject(ctx, filepathTemplate, create.Type, bytes.NewReader(create.Blob))
|
||||
key, err := driver.UploadObject(ctx, filepathTemplate, create.Type, content)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to upload via storage driver")
|
||||
}
|
||||
|
|
@ -133,6 +155,12 @@ func saveAttachmentBlobWithInstanceStorageSetting(
|
|||
},
|
||||
}
|
||||
create.Payload = payload
|
||||
} else {
|
||||
blob, err := io.ReadAll(content)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to read attachment content")
|
||||
}
|
||||
create.Blob = blob
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
214
server/router/api/v1/attachment_upload.go
Normal file
214
server/router/api/v1/attachment_upload.go
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"io"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
// UploadAttachment accepts bounded unary chunks. A call carrying a spec opens
|
||||
// a new upload; a call carrying an upload ID continues one. Either kind may
|
||||
// write data and finalize.
|
||||
func (s *APIV1Service) UploadAttachment(ctx context.Context, request *v1pb.UploadAttachmentRequest) (*v1pb.UploadAttachmentResponse, error) {
|
||||
user, err := s.requireCurrentSpaceUser(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(request.Data) > attachmentUploadChunkSize {
|
||||
return nil, status.Errorf(codes.ResourceExhausted, "upload chunk exceeds the limit")
|
||||
}
|
||||
var id string
|
||||
var upload *attachmentUpload
|
||||
switch u := request.Upload.(type) {
|
||||
case *v1pb.UploadAttachmentRequest_Spec:
|
||||
id, upload, err = s.startAttachmentUpload(ctx, request, u.Spec, user.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
upload.mu.Lock()
|
||||
case *v1pb.UploadAttachmentRequest_UploadId:
|
||||
id = u.UploadId
|
||||
upload, err = s.attachmentUploads.get(id, user.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
upload.mu.Lock()
|
||||
if !time.Now().Before(upload.expireTime) {
|
||||
upload.mu.Unlock()
|
||||
return nil, status.Errorf(codes.NotFound, "upload not found or expired")
|
||||
}
|
||||
default:
|
||||
return nil, status.Errorf(codes.InvalidArgument, "spec or upload_id is required")
|
||||
}
|
||||
defer upload.mu.Unlock()
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, status.FromContextError(err).Err()
|
||||
}
|
||||
if err := upload.write(ctx, request); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var attachment *v1pb.Attachment
|
||||
if upload.complete {
|
||||
// Recheck access and existence; a completed upload must not resurrect a
|
||||
// deleted attachment or disclose metadata after access is revoked.
|
||||
attachment, err = s.GetAttachment(ctx, &v1pb.GetAttachmentRequest{Name: "attachments/" + upload.uid})
|
||||
} else if request.FinishWrite {
|
||||
if upload.committedSize != upload.totalSize {
|
||||
return nil, status.Errorf(codes.FailedPrecondition, "upload is incomplete")
|
||||
}
|
||||
attachment, err = s.finishAttachmentUpload(ctx, upload)
|
||||
if err == nil {
|
||||
upload.complete = true
|
||||
os.Remove(upload.path)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
upload.expireTime = time.Now().Add(attachmentUploadTTL)
|
||||
return &v1pb.UploadAttachmentResponse{
|
||||
UploadId: id, CommittedSize: upload.committedSize, Attachment: attachment, MaxChunkSize: attachmentUploadChunkSize,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// startAttachmentUpload validates the spec and registers a new upload. Every
|
||||
// check that can fail on the accompanying data runs first, so a rejected call
|
||||
// never leaves an orphaned upload behind.
|
||||
func (s *APIV1Service) startAttachmentUpload(ctx context.Context, request *v1pb.UploadAttachmentRequest, spec *v1pb.UploadAttachmentSpec, ownerID int32) (string, *attachmentUpload, error) {
|
||||
if spec.Attachment == nil {
|
||||
return "", nil, status.Errorf(codes.InvalidArgument, "spec.attachment is required")
|
||||
}
|
||||
if len(spec.Attachment.Content) != 0 {
|
||||
return "", nil, status.Errorf(codes.InvalidArgument, "spec.attachment.content must be empty; send file bytes in data")
|
||||
}
|
||||
if proto.Size(spec) > attachmentUploadMetadataLimit || spec.TotalSize < 0 {
|
||||
return "", nil, status.Errorf(codes.InvalidArgument, "invalid attachment metadata or total_size")
|
||||
}
|
||||
if request.WriteOffset != 0 {
|
||||
return "", nil, status.Errorf(codes.OutOfRange, "write_offset must be 0 for a new upload")
|
||||
}
|
||||
if int64(len(request.Data)) > spec.TotalSize {
|
||||
return "", nil, status.Errorf(codes.InvalidArgument, "data exceeds total_size")
|
||||
}
|
||||
setting, err := s.Store.GetInstanceStorageSetting(ctx)
|
||||
if err != nil {
|
||||
return "", nil, status.Errorf(codes.Internal, "failed to get storage setting: %v", err)
|
||||
}
|
||||
if err := checkUploadSize(setting, spec.TotalSize); err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
// Validate before allocating a temporary file. Keep the original MIME type
|
||||
// so an omitted type can be sniffed from real bytes at finalization.
|
||||
metadata := proto.CloneOf(spec.Attachment)
|
||||
validationMetadata := proto.CloneOf(metadata)
|
||||
if validationMetadata.Type == "" {
|
||||
// Type-dependent metadata validation must wait for content sniffing.
|
||||
validationMetadata.MediaMetadata = nil
|
||||
}
|
||||
create, err := s.prepareAttachment(ctx, &v1pb.CreateAttachmentRequest{Attachment: validationMetadata, AttachmentId: spec.AttachmentId})
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
upload := &attachmentUpload{ownerID: ownerID, metadata: metadata, uid: create.UID, totalSize: spec.TotalSize}
|
||||
id, err := s.attachmentUploads.create(s.Profile.Data, upload)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
return id, upload, nil
|
||||
}
|
||||
|
||||
func (u *attachmentUpload) write(ctx context.Context, request *v1pb.UploadAttachmentRequest) error {
|
||||
if len(request.Data) == 0 {
|
||||
if request.FinishWrite && request.WriteOffset != u.committedSize {
|
||||
return status.Errorf(codes.OutOfRange, "write_offset must equal committed_size")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
digest := sha256.Sum256(request.Data)
|
||||
if u.committedSize > 0 && request.WriteOffset+int64(len(request.Data)) == u.committedSize && digest == u.lastDigest {
|
||||
return nil // A lost response can be retried without appending bytes twice.
|
||||
}
|
||||
if u.complete {
|
||||
return status.Errorf(codes.FailedPrecondition, "upload is already complete")
|
||||
}
|
||||
if request.WriteOffset != u.committedSize {
|
||||
return status.Errorf(codes.OutOfRange, "write_offset must equal committed_size")
|
||||
}
|
||||
if int64(len(request.Data)) > u.totalSize-u.committedSize {
|
||||
return status.Errorf(codes.InvalidArgument, "data exceeds total_size")
|
||||
}
|
||||
file, err := os.OpenFile(u.path, os.O_WRONLY, 0600)
|
||||
if err != nil {
|
||||
return status.Errorf(codes.Internal, "failed to open upload file: %v", err)
|
||||
}
|
||||
defer file.Close()
|
||||
n, err := file.WriteAt(request.Data, u.committedSize)
|
||||
if err == nil && n != len(request.Data) {
|
||||
err = io.ErrShortWrite
|
||||
}
|
||||
if err == nil {
|
||||
err = ctx.Err()
|
||||
}
|
||||
if err != nil {
|
||||
if truncateErr := file.Truncate(u.committedSize); truncateErr != nil {
|
||||
// The file no longer matches committedSize; revoke the upload.
|
||||
u.expireTime = time.Time{}
|
||||
os.Remove(u.path)
|
||||
}
|
||||
return status.Errorf(codes.Internal, "failed to write upload chunk: %v", err)
|
||||
}
|
||||
u.lastDigest = digest
|
||||
u.committedSize += int64(n)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *APIV1Service) finishAttachmentUpload(ctx context.Context, upload *attachmentUpload) (*v1pb.Attachment, error) {
|
||||
if upload.finalizeAttempted {
|
||||
// A database operation may commit before returning an error. Resolve that
|
||||
// outcome before saving another object under the upload's stable UID.
|
||||
persisted, err := s.Store.GetAttachment(ctx, &store.FindAttachment{UID: &upload.uid})
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to resolve previous finalization: %v", err)
|
||||
}
|
||||
if persisted != nil {
|
||||
if persisted.CreatorID != upload.ownerID {
|
||||
return nil, status.Errorf(codes.AlreadyExists, "attachment ID already exists")
|
||||
}
|
||||
return s.GetAttachment(ctx, &v1pb.GetAttachmentRequest{Name: "attachments/" + upload.uid})
|
||||
}
|
||||
}
|
||||
setting, err := s.Store.GetInstanceStorageSetting(ctx)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get storage setting: %v", err)
|
||||
}
|
||||
if err := checkUploadSize(setting, upload.totalSize); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
file, err := os.Open(upload.path)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to open upload file: %v", err)
|
||||
}
|
||||
defer file.Close()
|
||||
metadata := proto.CloneOf(upload.metadata)
|
||||
metadata.Content = make([]byte, min(upload.totalSize, 512))
|
||||
if _, err := io.ReadFull(file, metadata.Content); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to read attachment header: %v", err)
|
||||
}
|
||||
// Revalidate memo permissions and media metadata with the actual MIME type.
|
||||
create, err := s.prepareAttachment(ctx, &v1pb.CreateAttachmentRequest{Attachment: metadata, AttachmentId: upload.uid})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
create.Size = upload.totalSize
|
||||
upload.finalizeAttempted = true
|
||||
return s.processAndSaveAttachment(ctx, create, setting, file)
|
||||
}
|
||||
194
server/router/api/v1/attachment_upload_state.go
Normal file
194
server/router/api/v1/attachment_upload_state.go
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
attachmentUploadChunkSize = 2 << 20
|
||||
attachmentUploadRequestLimit = 4 << 20
|
||||
attachmentUploadMetadataLimit = 64 << 10
|
||||
attachmentUploadTTL = 30 * time.Minute
|
||||
attachmentUploadMaxSessions = 1024
|
||||
attachmentUploadMaxActive = 128
|
||||
attachmentUploadMaxActivePerUser = 8
|
||||
attachmentUploadTempPrefix = ".memos-rpc-upload-"
|
||||
attachmentUploadProcedure = "/memos.api.v1.AttachmentService/UploadAttachment"
|
||||
)
|
||||
|
||||
// Upload state is private to the process; only Attachment is an API resource.
|
||||
// Each upload holds metadata and the last chunk's digest, never its contents.
|
||||
type attachmentUpload struct {
|
||||
mu sync.Mutex
|
||||
ownerID int32
|
||||
metadata *v1pb.Attachment
|
||||
uid string
|
||||
path string
|
||||
totalSize int64
|
||||
committedSize int64
|
||||
// expireTime is zeroed to revoke an upload before its TTL elapses.
|
||||
expireTime time.Time
|
||||
// lastDigest identifies the most recently accepted chunk so a client can
|
||||
// safely resend it after losing the response.
|
||||
lastDigest [sha256.Size]byte
|
||||
finalizeAttempted bool
|
||||
complete bool
|
||||
}
|
||||
|
||||
type attachmentUploads struct {
|
||||
mu sync.Mutex
|
||||
entries map[string]*attachmentUpload
|
||||
stop chan struct{}
|
||||
done chan struct{}
|
||||
closed bool
|
||||
}
|
||||
|
||||
func (m *attachmentUploads) startLocked(dir string) {
|
||||
if m.entries != nil {
|
||||
return
|
||||
}
|
||||
m.entries = make(map[string]*attachmentUpload)
|
||||
m.stop = make(chan struct{})
|
||||
m.done = make(chan struct{})
|
||||
go func() {
|
||||
defer close(m.done)
|
||||
ticker := time.NewTicker(time.Minute)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-m.stop:
|
||||
return
|
||||
case now := <-ticker.C:
|
||||
m.mu.Lock()
|
||||
m.sweepLocked(now, 0)
|
||||
m.removeOrphansLocked(dir, now)
|
||||
m.mu.Unlock()
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// sweepLocked drops expired uploads and counts the unfinished ones, both in
|
||||
// total and for ownerID. An upload locked by an in-flight request is
|
||||
// unfinished by definition.
|
||||
func (m *attachmentUploads) sweepLocked(now time.Time, ownerID int32) (owned, total int) {
|
||||
count := func(upload *attachmentUpload) {
|
||||
total++
|
||||
if upload.ownerID == ownerID {
|
||||
owned++
|
||||
}
|
||||
}
|
||||
for id, upload := range m.entries {
|
||||
// Never hold the manager lock while waiting for a file write or finalize.
|
||||
if !upload.mu.TryLock() {
|
||||
count(upload)
|
||||
continue
|
||||
}
|
||||
if !now.Before(upload.expireTime) {
|
||||
os.Remove(upload.path)
|
||||
delete(m.entries, id)
|
||||
} else if !upload.complete {
|
||||
count(upload)
|
||||
}
|
||||
upload.mu.Unlock()
|
||||
}
|
||||
return owned, total
|
||||
}
|
||||
|
||||
func (m *attachmentUploads) removeOrphansLocked(dir string, now time.Time) {
|
||||
tracked := make(map[string]bool, len(m.entries))
|
||||
for _, upload := range m.entries {
|
||||
tracked[upload.path] = true // path is immutable after insertion.
|
||||
}
|
||||
paths, _ := filepath.Glob(filepath.Join(dir, attachmentUploadTempPrefix+"*"))
|
||||
for _, path := range paths {
|
||||
if tracked[path] {
|
||||
continue
|
||||
}
|
||||
if info, err := os.Stat(path); err == nil && info.Mode().IsRegular() && now.Sub(info.ModTime()) >= attachmentUploadTTL {
|
||||
os.Remove(path)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (m *attachmentUploads) create(dir string, upload *attachmentUpload) (string, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
if m.closed {
|
||||
return "", status.Errorf(codes.Unavailable, "server is shutting down")
|
||||
}
|
||||
m.startLocked(dir)
|
||||
owned, total := m.sweepLocked(time.Now(), upload.ownerID)
|
||||
if owned >= attachmentUploadMaxActivePerUser {
|
||||
return "", status.Errorf(codes.ResourceExhausted, "too many active uploads")
|
||||
}
|
||||
if len(m.entries) >= attachmentUploadMaxSessions || total >= attachmentUploadMaxActive {
|
||||
return "", status.Errorf(codes.ResourceExhausted, "too many uploads")
|
||||
}
|
||||
file, err := os.CreateTemp(dir, attachmentUploadTempPrefix+"*")
|
||||
if err != nil {
|
||||
return "", status.Errorf(codes.Internal, "failed to create upload file: %v", err)
|
||||
}
|
||||
if err := file.Close(); err != nil {
|
||||
os.Remove(file.Name())
|
||||
return "", status.Errorf(codes.Internal, "failed to close upload file: %v", err)
|
||||
}
|
||||
upload.path = file.Name()
|
||||
upload.expireTime = time.Now().Add(attachmentUploadTTL)
|
||||
id := rand.Text()
|
||||
m.entries[id] = upload
|
||||
return id, nil
|
||||
}
|
||||
|
||||
func (m *attachmentUploads) get(id string, ownerID int32) (*attachmentUpload, error) {
|
||||
m.mu.Lock()
|
||||
upload := m.entries[id]
|
||||
closed := m.closed
|
||||
m.mu.Unlock()
|
||||
if closed {
|
||||
return nil, status.Errorf(codes.Unavailable, "server is shutting down")
|
||||
}
|
||||
if upload == nil || upload.ownerID != ownerID {
|
||||
return nil, status.Errorf(codes.NotFound, "upload not found or expired")
|
||||
}
|
||||
return upload, nil
|
||||
}
|
||||
|
||||
// CloseAttachmentUploads stops expiration work and removes pending upload files.
|
||||
// Call it after draining HTTP requests during server shutdown.
|
||||
func (s *APIV1Service) CloseAttachmentUploads() {
|
||||
m := &s.attachmentUploads
|
||||
m.mu.Lock()
|
||||
if m.closed {
|
||||
m.mu.Unlock()
|
||||
return
|
||||
}
|
||||
m.closed = true
|
||||
if m.stop != nil {
|
||||
close(m.stop)
|
||||
}
|
||||
done := m.done
|
||||
m.mu.Unlock()
|
||||
if done != nil {
|
||||
<-done
|
||||
}
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
for id, upload := range m.entries {
|
||||
upload.mu.Lock()
|
||||
upload.expireTime = time.Time{}
|
||||
os.Remove(upload.path)
|
||||
upload.mu.Unlock()
|
||||
delete(m.entries, id)
|
||||
}
|
||||
}
|
||||
357
server/router/api/v1/attachment_upload_test.go
Normal file
357
server/router/api/v1/attachment_upload_test.go
Normal file
|
|
@ -0,0 +1,357 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/usememos/memos/internal/testutil"
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
func newUploadTestService(t *testing.T) (*APIV1Service, context.Context) {
|
||||
t.Helper()
|
||||
svc := newIntegrationService(t)
|
||||
t.Cleanup(svc.CloseAttachmentUploads)
|
||||
user := createSpaceTestUser(context.Background(), t, svc, "uploader", store.RoleUser)
|
||||
return svc, userCtx(context.Background(), user.ID)
|
||||
}
|
||||
|
||||
func uploadSpec(filename string, size int64) *v1pb.UploadAttachmentRequest_Spec {
|
||||
return &v1pb.UploadAttachmentRequest_Spec{Spec: &v1pb.UploadAttachmentSpec{Attachment: &v1pb.Attachment{Filename: filename}, TotalSize: size}}
|
||||
}
|
||||
|
||||
func uploadID(id string) *v1pb.UploadAttachmentRequest_UploadId {
|
||||
return &v1pb.UploadAttachmentRequest_UploadId{UploadId: id}
|
||||
}
|
||||
|
||||
func startTestUpload(ctx context.Context, t *testing.T, svc *APIV1Service, size int64) string {
|
||||
t.Helper()
|
||||
spec := uploadSpec("file.bin", size)
|
||||
spec.Spec.Attachment.Type = "application/octet-stream"
|
||||
response, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: spec})
|
||||
require.NoError(t, err)
|
||||
require.NotEmpty(t, response.UploadId)
|
||||
require.EqualValues(t, attachmentUploadChunkSize, response.MaxChunkSize)
|
||||
require.Zero(t, response.CommittedSize)
|
||||
require.Nil(t, response.Attachment)
|
||||
return response.UploadId
|
||||
}
|
||||
|
||||
func TestUploadAttachmentChunksAndRetries(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
id := startTestUpload(ctx, t, svc, 6)
|
||||
first := &v1pb.UploadAttachmentRequest{Upload: uploadID(id), Data: []byte("abc")}
|
||||
for range 2 {
|
||||
response, err := svc.UploadAttachment(ctx, first)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, id, response.UploadId)
|
||||
require.EqualValues(t, 3, response.CommittedSize)
|
||||
}
|
||||
for _, request := range []*v1pb.UploadAttachmentRequest{
|
||||
{Upload: uploadID(id), Data: []byte("xyz")},
|
||||
{Upload: uploadID(id), WriteOffset: 4, Data: []byte("d")},
|
||||
{Upload: uploadID(id), WriteOffset: -1, Data: []byte("d")},
|
||||
} {
|
||||
_, err := svc.UploadAttachment(ctx, request)
|
||||
require.Equal(t, codes.OutOfRange, status.Code(err))
|
||||
}
|
||||
progress, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(id), WriteOffset: -1})
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, 3, progress.CommittedSize)
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(id), WriteOffset: 3, FinishWrite: true})
|
||||
require.Equal(t, codes.FailedPrecondition, status.Code(err))
|
||||
|
||||
last := &v1pb.UploadAttachmentRequest{Upload: uploadID(id), WriteOffset: 3, Data: []byte("def"), FinishWrite: true}
|
||||
result, err := svc.UploadAttachment(ctx, last)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, 6, result.Attachment.Size)
|
||||
for _, request := range []*v1pb.UploadAttachmentRequest{last, {Upload: uploadID(id)}, {Upload: uploadID(id), WriteOffset: 6, FinishWrite: true}} {
|
||||
repeated, err := svc.UploadAttachment(ctx, request)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, result.Attachment.Name, repeated.Attachment.Name)
|
||||
}
|
||||
rows, err := svc.Store.ListAttachments(ctx, &store.FindAttachment{})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, rows, 1)
|
||||
content, err := os.ReadFile(rows[0].Reference)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "abcdef", string(content))
|
||||
require.NoFileExists(t, svc.attachmentUploads.entries[id].path)
|
||||
|
||||
_, err = svc.DeleteAttachment(ctx, &v1pb.DeleteAttachmentRequest{Name: result.Attachment.Name})
|
||||
require.NoError(t, err)
|
||||
_, err = svc.UploadAttachment(ctx, last)
|
||||
require.Equal(t, codes.NotFound, status.Code(err))
|
||||
}
|
||||
|
||||
func TestUploadAttachmentSingleCall(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
spec := uploadSpec("note.txt", 3)
|
||||
spec.Spec.AttachmentId = "chosen-id"
|
||||
result, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: spec, Data: []byte("abc"), FinishWrite: true})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "attachments/chosen-id", result.Attachment.Name)
|
||||
require.EqualValues(t, 3, result.Attachment.Size)
|
||||
require.EqualValues(t, 3, result.CommittedSize)
|
||||
|
||||
empty, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadSpec("empty.txt", 0), FinishWrite: true})
|
||||
require.NoError(t, err)
|
||||
require.Zero(t, empty.Attachment.Size)
|
||||
|
||||
// A spec call may carry the first chunk without finishing.
|
||||
partial, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadSpec("two.bin", 4), Data: []byte("ab")})
|
||||
require.NoError(t, err)
|
||||
require.Nil(t, partial.Attachment)
|
||||
require.EqualValues(t, 2, partial.CommittedSize)
|
||||
done, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(partial.UploadId), WriteOffset: 2, Data: []byte("cd"), FinishWrite: true})
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, 4, done.Attachment.Size)
|
||||
|
||||
rows, err := svc.Store.ListAttachments(ctx, &store.FindAttachment{})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, rows, 3)
|
||||
}
|
||||
|
||||
func TestUploadAttachmentValidation(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
_, err := svc.UploadAttachment(context.Background(), &v1pb.UploadAttachmentRequest{})
|
||||
require.Equal(t, codes.Unauthenticated, status.Code(err))
|
||||
badID := uploadSpec("file", 0)
|
||||
badID.Spec.AttachmentId = "bad id!"
|
||||
withContent := uploadSpec("file", 0)
|
||||
withContent.Spec.Attachment.Content = []byte("not metadata")
|
||||
for _, request := range []*v1pb.UploadAttachmentRequest{
|
||||
{},
|
||||
{Upload: &v1pb.UploadAttachmentRequest_Spec{Spec: &v1pb.UploadAttachmentSpec{}}},
|
||||
{Upload: uploadSpec("file", -1)},
|
||||
{Upload: uploadSpec("../file", 0)},
|
||||
{Upload: withContent},
|
||||
{Upload: badID},
|
||||
{Upload: uploadSpec(strings.Repeat("x", attachmentUploadMetadataLimit+1), 0)},
|
||||
{Upload: uploadSpec("file", 3), Data: []byte("four")},
|
||||
} {
|
||||
_, err := svc.UploadAttachment(ctx, request)
|
||||
require.Equal(t, codes.InvalidArgument, status.Code(err), request.String())
|
||||
}
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadSpec("file", 3), WriteOffset: 1, Data: []byte("abc")})
|
||||
require.Equal(t, codes.OutOfRange, status.Code(err))
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadSpec("file", 1<<60)})
|
||||
require.Equal(t, codes.ResourceExhausted, status.Code(err))
|
||||
require.Empty(t, svc.attachmentUploads.entries, "rejected spec calls must not register uploads")
|
||||
|
||||
id := startTestUpload(ctx, t, svc, 3)
|
||||
other := createSpaceTestUser(context.Background(), t, svc, "other-uploader", store.RoleUser)
|
||||
_, err = svc.UploadAttachment(userCtx(context.Background(), other.ID), &v1pb.UploadAttachmentRequest{Upload: uploadID(id)})
|
||||
require.Equal(t, codes.NotFound, status.Code(err))
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID("unknown")})
|
||||
require.Equal(t, codes.NotFound, status.Code(err))
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(id), Data: make([]byte, attachmentUploadChunkSize+1)})
|
||||
require.Equal(t, codes.ResourceExhausted, status.Code(err))
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(id), Data: []byte("four")})
|
||||
require.Equal(t, codes.InvalidArgument, status.Code(err))
|
||||
canceled, cancel := context.WithCancel(ctx)
|
||||
cancel()
|
||||
_, err = svc.UploadAttachment(canceled, &v1pb.UploadAttachmentRequest{Upload: uploadID(id), Data: []byte("abc")})
|
||||
require.Error(t, err)
|
||||
progress, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(id)})
|
||||
require.NoError(t, err)
|
||||
require.Zero(t, progress.CommittedSize)
|
||||
}
|
||||
|
||||
func TestUploadAttachmentEmptyAndConcurrentFinish(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
id := startTestUpload(ctx, t, svc, 0)
|
||||
var wg sync.WaitGroup
|
||||
results := make(chan *v1pb.UploadAttachmentResponse, 8)
|
||||
errs := make(chan error, 8)
|
||||
for range 8 {
|
||||
wg.Go(func() {
|
||||
response, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(id), FinishWrite: true})
|
||||
results <- response
|
||||
errs <- err
|
||||
})
|
||||
}
|
||||
wg.Wait()
|
||||
close(results)
|
||||
close(errs)
|
||||
for err := range errs {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
name := ""
|
||||
for response := range results {
|
||||
if name == "" {
|
||||
name = response.Attachment.Name
|
||||
}
|
||||
require.Equal(t, name, response.Attachment.Name)
|
||||
require.Zero(t, response.Attachment.Size)
|
||||
}
|
||||
rows, err := svc.Store.ListAttachments(ctx, &store.FindAttachment{})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, rows, 1)
|
||||
}
|
||||
|
||||
func TestUploadAttachmentFinalizationRecovery(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
id := startTestUpload(ctx, t, svc, 3)
|
||||
last := &v1pb.UploadAttachmentRequest{Upload: uploadID(id), Data: []byte("abc"), FinishWrite: true}
|
||||
_, err := svc.UploadAttachment(store.WithCreateAttachmentPostCommitFailpoint(ctx), last)
|
||||
require.Equal(t, codes.Internal, status.Code(err))
|
||||
result, err := svc.UploadAttachment(ctx, last)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, result.Attachment)
|
||||
rows, err := svc.Store.ListAttachments(ctx, &store.FindAttachment{})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, rows, 1)
|
||||
content, err := os.ReadFile(rows[0].Reference)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "abc", string(content))
|
||||
}
|
||||
|
||||
func TestUploadAttachmentRechecksMemoAndSize(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
memo, err := svc.CreateMemo(ctx, &v1pb.CreateMemoRequest{Memo: &v1pb.Memo{Content: "upload target"}})
|
||||
require.NoError(t, err)
|
||||
spec := uploadSpec("file.txt", 3)
|
||||
spec.Spec.Attachment.Memo = &memo.Name
|
||||
initial, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: spec})
|
||||
require.NoError(t, err)
|
||||
_, err = svc.DeleteMemo(ctx, &v1pb.DeleteMemoRequest{Name: memo.Name, Force: true})
|
||||
require.NoError(t, err)
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(initial.UploadId), Data: []byte("abc"), FinishWrite: true})
|
||||
require.Equal(t, codes.NotFound, status.Code(err))
|
||||
|
||||
id := startTestUpload(ctx, t, svc, 2*MebiByte)
|
||||
_, err = svc.Store.UpsertInstanceSetting(ctx, &storepb.InstanceSetting{Key: storepb.InstanceSettingKey_STORAGE,
|
||||
Value: &storepb.InstanceSetting_StorageSetting{StorageSetting: &storepb.InstanceStorageSetting{UploadSizeLimitMb: 1}},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(id), Data: make([]byte, 2*MebiByte), FinishWrite: true})
|
||||
require.Equal(t, codes.ResourceExhausted, status.Code(err))
|
||||
rows, err := svc.Store.ListAttachments(ctx, &store.FindAttachment{})
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, rows)
|
||||
}
|
||||
|
||||
func TestUploadAttachmentExpiryAndLimits(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
ids := make([]string, attachmentUploadMaxActivePerUser)
|
||||
for i := range ids {
|
||||
ids[i] = startTestUpload(ctx, t, svc, 0)
|
||||
}
|
||||
_, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadSpec("too-many", 0)})
|
||||
require.Equal(t, codes.ResourceExhausted, status.Code(err))
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(ids[0]), FinishWrite: true})
|
||||
require.NoError(t, err)
|
||||
startTestUpload(ctx, t, svc, 0) // Completed uploads do not consume an active slot.
|
||||
upload := svc.attachmentUploads.entries[ids[1]]
|
||||
upload.mu.Lock()
|
||||
upload.expireTime = time.Now().Add(-time.Second)
|
||||
upload.mu.Unlock()
|
||||
_, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(ids[1])})
|
||||
require.Equal(t, codes.NotFound, status.Code(err))
|
||||
|
||||
orphan := filepath.Join(svc.Profile.Data, attachmentUploadTempPrefix+"orphan")
|
||||
recent := filepath.Join(svc.Profile.Data, attachmentUploadTempPrefix+"recent")
|
||||
unrelated := filepath.Join(svc.Profile.Data, "keep.txt")
|
||||
for _, path := range []string{orphan, recent, unrelated} {
|
||||
require.NoError(t, os.WriteFile(path, []byte("x"), 0600))
|
||||
}
|
||||
old := time.Now().Add(-2 * attachmentUploadTTL)
|
||||
require.NoError(t, os.Chtimes(orphan, old, old))
|
||||
require.NoError(t, os.Chtimes(unrelated, old, old))
|
||||
svc.attachmentUploads.mu.Lock()
|
||||
svc.attachmentUploads.sweepLocked(time.Now(), 0)
|
||||
svc.attachmentUploads.removeOrphansLocked(svc.Profile.Data, time.Now())
|
||||
svc.attachmentUploads.mu.Unlock()
|
||||
require.NoFileExists(t, upload.path)
|
||||
require.NoFileExists(t, orphan)
|
||||
require.FileExists(t, recent)
|
||||
require.FileExists(t, unrelated)
|
||||
svc.CloseAttachmentUploads()
|
||||
require.Empty(t, svc.attachmentUploads.entries)
|
||||
}
|
||||
|
||||
func TestUploadAttachmentAboveLegacyRequestLimit(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
const size = 300 * MebiByte
|
||||
_, err := svc.Store.UpsertInstanceSetting(ctx, &storepb.InstanceSetting{Key: storepb.InstanceSettingKey_STORAGE,
|
||||
Value: &storepb.InstanceSetting_StorageSetting{StorageSetting: &storepb.InstanceStorageSetting{UploadSizeLimitMb: 400}},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
id := startTestUpload(ctx, t, svc, size)
|
||||
chunk := bytes.Repeat([]byte{0x5a}, attachmentUploadChunkSize)
|
||||
var response *v1pb.UploadAttachmentResponse
|
||||
for offset := int64(0); offset < size; offset += int64(len(chunk)) {
|
||||
response, err = svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{
|
||||
Upload: uploadID(id), WriteOffset: offset, Data: chunk, FinishWrite: offset+int64(len(chunk)) == size,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
}
|
||||
require.EqualValues(t, size, response.Attachment.Size)
|
||||
rows, err := svc.Store.ListAttachments(ctx, &store.FindAttachment{})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, rows, 1)
|
||||
file, err := os.Open(rows[0].Reference)
|
||||
require.NoError(t, err)
|
||||
defer file.Close()
|
||||
info, err := file.Stat()
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, size, info.Size())
|
||||
_, err = file.Seek(-int64(len(chunk)), io.SeekEnd)
|
||||
require.NoError(t, err)
|
||||
tail := make([]byte, len(chunk))
|
||||
_, err = io.ReadFull(file, tail)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, chunk, tail)
|
||||
}
|
||||
|
||||
func TestUploadAttachmentMediaProcessing(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
content []byte
|
||||
motion bool
|
||||
}{
|
||||
{name: "JPEG", content: testutil.BuildJPEG(20, 10)},
|
||||
{name: "motion photo", content: testutil.BuildMotionPhotoJPEG(), motion: true},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
metadata := &v1pb.Attachment{Filename: "image.unknown", MediaMetadata: &v1pb.MediaMetadata{Width: proto.Int32(20), Height: proto.Int32(10)}}
|
||||
spec := &v1pb.UploadAttachmentRequest_Spec{Spec: &v1pb.UploadAttachmentSpec{Attachment: metadata, TotalSize: int64(len(tc.content))}}
|
||||
initial, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: spec})
|
||||
require.NoError(t, err)
|
||||
result, err := svc.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: uploadID(initial.UploadId), Data: tc.content, FinishWrite: true})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "image/jpeg", result.Attachment.Type)
|
||||
require.True(t, proto.Equal(metadata.MediaMetadata, result.Attachment.MediaMetadata))
|
||||
uid, err := ExtractAttachmentUIDFromName(result.Attachment.Name)
|
||||
require.NoError(t, err)
|
||||
row, err := svc.Store.GetAttachment(ctx, &store.FindAttachment{UID: &uid})
|
||||
require.NoError(t, err)
|
||||
content, err := os.ReadFile(row.Reference)
|
||||
require.NoError(t, err)
|
||||
if tc.motion {
|
||||
require.Equal(t, tc.content, content)
|
||||
require.True(t, result.Attachment.MotionMedia.HasEmbeddedVideo)
|
||||
} else {
|
||||
stripped, err := stripImageExif(bytes.NewReader(tc.content), "image/jpeg")
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, stripped, content)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
111
server/router/api/v1/attachment_upload_transport_test.go
Normal file
111
server/router/api/v1/attachment_upload_transport_test.go
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"connectrpc.com/connect"
|
||||
"github.com/labstack/echo/v5"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
"github.com/usememos/memos/proto/gen/api/v1/apiv1connect"
|
||||
"github.com/usememos/memos/server/auth"
|
||||
)
|
||||
|
||||
type uploadCountingReader struct {
|
||||
reader io.Reader
|
||||
read int
|
||||
}
|
||||
|
||||
func (r *uploadCountingReader) Read(p []byte) (int, error) {
|
||||
n, err := r.reader.Read(p)
|
||||
r.read += n
|
||||
return n, err
|
||||
}
|
||||
|
||||
func TestUploadAttachmentTransports(t *testing.T) {
|
||||
svc, ctx := newUploadTestService(t)
|
||||
user, err := svc.fetchCurrentUser(ctx)
|
||||
require.NoError(t, err)
|
||||
token, _, err := auth.GenerateAccessTokenV2(user.ID, user.Username, string(user.Role), string(user.RowStatus), []byte(svc.Secret))
|
||||
require.NoError(t, err)
|
||||
e := echo.New()
|
||||
require.NoError(t, svc.RegisterGateway(context.Background(), e))
|
||||
|
||||
for _, path := range []string{"/api/v1/attachments:upload", attachmentUploadProcedure} {
|
||||
t.Run(path, func(t *testing.T) {
|
||||
call := func(message proto.Message, authenticated bool) *httptest.ResponseRecorder {
|
||||
t.Helper()
|
||||
data, err := protojson.Marshal(message)
|
||||
require.NoError(t, err)
|
||||
req := httptest.NewRequest(http.MethodPost, path, bytes.NewReader(data))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
if authenticated {
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
}
|
||||
rec := httptest.NewRecorder()
|
||||
e.ServeHTTP(rec, req)
|
||||
return rec
|
||||
}
|
||||
initial := &v1pb.UploadAttachmentRequest{Upload: uploadSpec("file.txt", 3)}
|
||||
require.Equal(t, http.StatusUnauthorized, call(initial, false).Code)
|
||||
rec := call(initial, true)
|
||||
require.Equal(t, http.StatusOK, rec.Code, rec.Body.String())
|
||||
response := &v1pb.UploadAttachmentResponse{}
|
||||
require.NoError(t, protojson.Unmarshal(rec.Body.Bytes(), response))
|
||||
rec = call(&v1pb.UploadAttachmentRequest{Upload: uploadID(response.UploadId), Data: []byte("abc"), FinishWrite: true}, true)
|
||||
require.Equal(t, http.StatusOK, rec.Code, rec.Body.String())
|
||||
require.NoError(t, protojson.Unmarshal(rec.Body.Bytes(), response))
|
||||
require.NotNil(t, response.Attachment)
|
||||
|
||||
oversized, err := protojson.Marshal(&v1pb.UploadAttachmentRequest{Data: make([]byte, attachmentUploadRequestLimit)})
|
||||
require.NoError(t, err)
|
||||
reader := &uploadCountingReader{reader: bytes.NewReader(oversized)}
|
||||
req := httptest.NewRequest(http.MethodPost, path, reader)
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
rec = httptest.NewRecorder()
|
||||
e.ServeHTTP(rec, req)
|
||||
require.GreaterOrEqual(t, rec.Code, 400)
|
||||
require.LessOrEqual(t, reader.read, attachmentUploadRequestLimit+1, "body must be bounded before decoding")
|
||||
})
|
||||
}
|
||||
|
||||
t.Run("Connect protobuf and compressed message limit", func(t *testing.T) {
|
||||
server := httptest.NewTestServer(t, e)
|
||||
client := apiv1connect.NewAttachmentServiceClient(server.Client(), server.URL)
|
||||
initial := connect.NewRequest(&v1pb.UploadAttachmentRequest{Upload: uploadSpec("binary.bin", attachmentUploadChunkSize)})
|
||||
initial.Header().Set("Authorization", "Bearer "+token)
|
||||
response, err := client.UploadAttachment(context.Background(), initial)
|
||||
require.NoError(t, err)
|
||||
last := connect.NewRequest(&v1pb.UploadAttachmentRequest{Upload: uploadID(response.Msg.UploadId), Data: make([]byte, attachmentUploadChunkSize), FinishWrite: true})
|
||||
last.Header().Set("Authorization", "Bearer "+token)
|
||||
finished, err := client.UploadAttachment(context.Background(), last)
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, attachmentUploadChunkSize, finished.Msg.Attachment.Size)
|
||||
|
||||
data, err := proto.Marshal(&v1pb.UploadAttachmentRequest{Data: make([]byte, attachmentUploadRequestLimit+1)})
|
||||
require.NoError(t, err)
|
||||
var compressed bytes.Buffer
|
||||
writer := gzip.NewWriter(&compressed)
|
||||
_, err = writer.Write(data)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, writer.Close())
|
||||
req := httptest.NewRequest(http.MethodPost, attachmentUploadProcedure, &compressed)
|
||||
req.Header.Set("Content-Type", "application/proto")
|
||||
req.Header.Set("Content-Encoding", "gzip")
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
rec := httptest.NewRecorder()
|
||||
e.ServeHTTP(rec, req)
|
||||
require.Equal(t, http.StatusTooManyRequests, rec.Code, rec.Body.String())
|
||||
require.Contains(t, rec.Body.String(), "resource_exhausted")
|
||||
})
|
||||
}
|
||||
|
|
@ -42,7 +42,6 @@ func (s *ConnectServiceHandler) RegisterConnectHandlers(mux *http.ServeMux, opts
|
|||
wrap(apiv1connect.NewSpaceServiceHandler(s, opts...)),
|
||||
wrap(apiv1connect.NewAttachmentServiceHandler(s, opts...)),
|
||||
wrap(apiv1connect.NewAIServiceHandler(s, opts...)),
|
||||
wrap(apiv1connect.NewMemoViewServiceHandler(s, opts...)),
|
||||
wrap(apiv1connect.NewIdentityProviderServiceHandler(s, opts...)),
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -301,6 +301,51 @@ func (s *ConnectServiceHandler) DeleteUserNotification(ctx context.Context, req
|
|||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
// ListMemoViews lists the saved memo views owned by a user.
|
||||
func (s *ConnectServiceHandler) ListMemoViews(ctx context.Context, req *connect.Request[v1pb.ListMemoViewsRequest]) (*connect.Response[v1pb.ListMemoViewsResponse], error) {
|
||||
resp, err := s.APIV1Service.ListMemoViews(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
// GetMemoView returns a saved memo view by resource name.
|
||||
func (s *ConnectServiceHandler) GetMemoView(ctx context.Context, req *connect.Request[v1pb.GetMemoViewRequest]) (*connect.Response[v1pb.MemoView], error) {
|
||||
resp, err := s.APIV1Service.GetMemoView(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
// CreateMemoView creates a saved memo view for a user.
|
||||
func (s *ConnectServiceHandler) CreateMemoView(ctx context.Context, req *connect.Request[v1pb.CreateMemoViewRequest]) (*connect.Response[v1pb.MemoView], error) {
|
||||
resp, err := s.APIV1Service.CreateMemoView(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
// UpdateMemoView updates the selected fields of a saved memo view.
|
||||
func (s *ConnectServiceHandler) UpdateMemoView(ctx context.Context, req *connect.Request[v1pb.UpdateMemoViewRequest]) (*connect.Response[v1pb.MemoView], error) {
|
||||
resp, err := s.APIV1Service.UpdateMemoView(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
// DeleteMemoView deletes a saved memo view by resource name.
|
||||
func (s *ConnectServiceHandler) DeleteMemoView(ctx context.Context, req *connect.Request[v1pb.DeleteMemoViewRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.DeleteMemoView(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
// MemoService
|
||||
|
||||
func (s *ConnectServiceHandler) CreateMemo(ctx context.Context, req *connect.Request[v1pb.CreateMemoRequest]) (*connect.Response[v1pb.Memo], error) {
|
||||
|
|
@ -595,6 +640,14 @@ func (s *ConnectServiceHandler) DeleteSpaceMember(ctx context.Context, req *conn
|
|||
|
||||
// AttachmentService
|
||||
|
||||
func (s *ConnectServiceHandler) UploadAttachment(ctx context.Context, req *connect.Request[v1pb.UploadAttachmentRequest]) (*connect.Response[v1pb.UploadAttachmentResponse], error) {
|
||||
resp, err := s.APIV1Service.UploadAttachment(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
func (s *ConnectServiceHandler) CreateAttachment(ctx context.Context, req *connect.Request[v1pb.CreateAttachmentRequest]) (*connect.Response[v1pb.Attachment], error) {
|
||||
resp, err := s.APIV1Service.CreateAttachment(ctx, req.Msg)
|
||||
if err != nil {
|
||||
|
|
@ -653,53 +706,6 @@ func (s *ConnectServiceHandler) Transcribe(ctx context.Context, req *connect.Req
|
|||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
// MemoViewService
|
||||
|
||||
// ListMemoViews lists the saved memo views owned by a user.
|
||||
func (s *ConnectServiceHandler) ListMemoViews(ctx context.Context, req *connect.Request[v1pb.ListMemoViewsRequest]) (*connect.Response[v1pb.ListMemoViewsResponse], error) {
|
||||
resp, err := s.APIV1Service.ListMemoViews(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
// GetMemoView returns a saved memo view by resource name.
|
||||
func (s *ConnectServiceHandler) GetMemoView(ctx context.Context, req *connect.Request[v1pb.GetMemoViewRequest]) (*connect.Response[v1pb.MemoView], error) {
|
||||
resp, err := s.APIV1Service.GetMemoView(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
// CreateMemoView creates a saved memo view for a user.
|
||||
func (s *ConnectServiceHandler) CreateMemoView(ctx context.Context, req *connect.Request[v1pb.CreateMemoViewRequest]) (*connect.Response[v1pb.MemoView], error) {
|
||||
resp, err := s.APIV1Service.CreateMemoView(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
// UpdateMemoView updates the selected fields of a saved memo view.
|
||||
func (s *ConnectServiceHandler) UpdateMemoView(ctx context.Context, req *connect.Request[v1pb.UpdateMemoViewRequest]) (*connect.Response[v1pb.MemoView], error) {
|
||||
resp, err := s.APIV1Service.UpdateMemoView(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
// DeleteMemoView deletes a saved memo view by resource name.
|
||||
func (s *ConnectServiceHandler) DeleteMemoView(ctx context.Context, req *connect.Request[v1pb.DeleteMemoViewRequest]) (*connect.Response[emptypb.Empty], error) {
|
||||
resp, err := s.APIV1Service.DeleteMemoView(ctx, req.Msg)
|
||||
if err != nil {
|
||||
return nil, convertGRPCError(err)
|
||||
}
|
||||
return connect.NewResponse(resp), nil
|
||||
}
|
||||
|
||||
// IdentityProviderService
|
||||
|
||||
func (s *ConnectServiceHandler) ListIdentityProviders(ctx context.Context, req *connect.Request[v1pb.ListIdentityProvidersRequest]) (*connect.Response[v1pb.ListIdentityProvidersResponse], error) {
|
||||
|
|
|
|||
|
|
@ -89,6 +89,11 @@ func TestGatewayRouteResolverResolvesKnownRoutes(t *testing.T) {
|
|||
{http.MethodPost, "/api/v1/users", "/api/v1/users", "/memos.api.v1.UserService/CreateUser"},
|
||||
{http.MethodGet, "/api/v1/users", "/api/v1/users", "/memos.api.v1.UserService/ListUsers"},
|
||||
{http.MethodGet, "/api/v1/{name=users/*}", "/api/v1/users/1", "/memos.api.v1.UserService/GetUser"},
|
||||
{http.MethodGet, "/api/v1/{parent=users/*}/views", "/api/v1/users/alice/views", "/memos.api.v1.UserService/ListMemoViews"},
|
||||
{http.MethodPost, "/api/v1/{parent=users/*}/views", "/api/v1/users/alice/views", "/memos.api.v1.UserService/CreateMemoView"},
|
||||
{http.MethodGet, "/api/v1/{name=users/*/views/*}", "/api/v1/users/alice/views/work", "/memos.api.v1.UserService/GetMemoView"},
|
||||
{http.MethodPatch, "/api/v1/{memo_view.name=users/*/views/*}", "/api/v1/users/alice/views/work", "/memos.api.v1.UserService/UpdateMemoView"},
|
||||
{http.MethodDelete, "/api/v1/{name=users/*/views/*}", "/api/v1/users/alice/views/work", "/memos.api.v1.UserService/DeleteMemoView"},
|
||||
{http.MethodGet, "/api/v1/memos", "/api/v1/memos", "/memos.api.v1.MemoService/ListMemos"},
|
||||
{http.MethodGet, "/api/v1/{name=memos/*}", "/api/v1/memos/abc", "/memos.api.v1.MemoService/GetMemo"},
|
||||
{http.MethodPost, "/api/v1/memos", "/api/v1/memos", "/memos.api.v1.MemoService/CreateMemo"},
|
||||
|
|
|
|||
|
|
@ -66,15 +66,11 @@ func (s *APIV1Service) convertMemoFromStoreWithCreators(ctx context.Context, mem
|
|||
memoMessage.Location = convertLocationFromStore(memo.Payload.Location)
|
||||
}
|
||||
|
||||
// Parent identity is part of a readable comment's context. It grants no
|
||||
// access to the parent; clients resolve it independently and handle denial.
|
||||
if memo.ParentUID != nil {
|
||||
contextMemo, err := s.Store.GetMemo(ctx, &store.FindMemo{UID: memo.ParentUID})
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to resolve comment context")
|
||||
}
|
||||
if contextMemo != nil && s.checkMemoReadAccess(ctx, contextMemo) == nil {
|
||||
parentName := buildMemoName(*memo.ParentUID)
|
||||
memoMessage.Parent = &parentName
|
||||
}
|
||||
parentName := buildMemoName(*memo.ParentUID)
|
||||
memoMessage.Parent = &parentName
|
||||
}
|
||||
|
||||
// Reactions have no independent audience and are readable whenever this
|
||||
|
|
|
|||
35
server/router/api/v1/memo_view_icon.go
Normal file
35
server/router/api/v1/memo_view_icon.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
)
|
||||
|
||||
func convertMemoViewIconFromStore(icon *storepb.MemoViewsUserSetting_MemoView_Icon) *v1pb.MemoView_Icon {
|
||||
if icon == nil {
|
||||
return nil
|
||||
}
|
||||
switch value := icon.Value.(type) {
|
||||
case *storepb.MemoViewsUserSetting_MemoView_Icon_Emoji:
|
||||
return &v1pb.MemoView_Icon{Value: &v1pb.MemoView_Icon_Emoji{Emoji: value.Emoji}}
|
||||
case *storepb.MemoViewsUserSetting_MemoView_Icon_Lucide:
|
||||
return &v1pb.MemoView_Icon{Value: &v1pb.MemoView_Icon_Lucide{Lucide: value.Lucide}}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func convertMemoViewIconToStore(icon *v1pb.MemoView_Icon) *storepb.MemoViewsUserSetting_MemoView_Icon {
|
||||
if icon == nil {
|
||||
return nil
|
||||
}
|
||||
switch value := icon.Value.(type) {
|
||||
case *v1pb.MemoView_Icon_Emoji:
|
||||
return &storepb.MemoViewsUserSetting_MemoView_Icon{Value: &storepb.MemoViewsUserSetting_MemoView_Icon_Emoji{Emoji: value.Emoji}}
|
||||
case *v1pb.MemoView_Icon_Lucide:
|
||||
return &storepb.MemoViewsUserSetting_MemoView_Icon{Value: &storepb.MemoViewsUserSetting_MemoView_Icon_Lucide{Lucide: value.Lucide}}
|
||||
default:
|
||||
// Preserve an empty icon so validation rejects it instead of treating it as a reset.
|
||||
return &storepb.MemoViewsUserSetting_MemoView_Icon{}
|
||||
}
|
||||
}
|
||||
89
server/router/api/v1/space_icon_test.go
Normal file
89
server/router/api/v1/space_icon_test.go
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/fieldmaskpb"
|
||||
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
func TestSpaceIconLifecycle(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
service := newIntegrationService(t)
|
||||
owner := createSpaceTestUser(ctx, t, service, "icon-owner", store.RoleUser)
|
||||
member := createSpaceTestUser(ctx, t, service, "icon-member", store.RoleUser)
|
||||
ownerCtx := userCtx(ctx, owner.ID)
|
||||
emoji := &v1pb.Space_Icon{Value: &v1pb.Space_Icon_Emoji{Emoji: "🌱"}}
|
||||
space, err := service.CreateSpace(ownerCtx, &v1pb.CreateSpaceRequest{
|
||||
SpaceId: "icon-space", Space: &v1pb.Space{Title: "Garden", Icon: emoji},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.True(t, proto.Equal(emoji, space.Icon))
|
||||
|
||||
invitation := inviteSpaceTestUser(ctx, t, service, owner, member, space, v1pb.SpaceMember_USER)
|
||||
require.True(t, proto.Equal(emoji, invitation.Space.Icon), "invitation metadata includes the icon")
|
||||
_, err = service.AcceptSpaceInvitation(userCtx(ctx, member.ID), &v1pb.AcceptSpaceInvitationRequest{Name: invitation.Name})
|
||||
require.NoError(t, err)
|
||||
|
||||
space, err = service.UpdateSpace(ownerCtx, &v1pb.UpdateSpaceRequest{
|
||||
Space: &v1pb.Space{Name: space.Name, Title: "Renamed"}, UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"title"}},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.True(t, proto.Equal(emoji, space.Icon), "unmasked icon remains unchanged")
|
||||
lucide := &v1pb.Space_Icon{Value: &v1pb.Space_Icon_Lucide{Lucide: "leaf"}}
|
||||
update := &v1pb.UpdateSpaceRequest{
|
||||
Space: &v1pb.Space{Name: space.Name, Icon: lucide}, UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"icon"}},
|
||||
}
|
||||
_, err = service.UpdateSpace(userCtx(ctx, member.ID), update)
|
||||
require.Equal(t, codes.PermissionDenied, status.Code(err))
|
||||
space, err = service.UpdateSpace(ownerCtx, update)
|
||||
require.NoError(t, err)
|
||||
require.True(t, proto.Equal(lucide, space.Icon))
|
||||
require.Equal(t, "Renamed", space.Title)
|
||||
fetched, err := service.GetSpace(ownerCtx, &v1pb.GetSpaceRequest{Name: space.Name})
|
||||
require.NoError(t, err)
|
||||
require.True(t, proto.Equal(lucide, fetched.Icon))
|
||||
listed, err := service.ListSpaces(ownerCtx, &v1pb.ListSpacesRequest{})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, listed.Spaces, 1)
|
||||
require.True(t, proto.Equal(lucide, listed.Spaces[0].Icon))
|
||||
|
||||
update.Space.Icon = &v1pb.Space_Icon{Value: &v1pb.Space_Icon_Emoji{Emoji: "not an emoji"}}
|
||||
_, err = service.UpdateSpace(ownerCtx, update)
|
||||
require.Equal(t, codes.InvalidArgument, status.Code(err))
|
||||
fetched, err = service.GetSpace(ownerCtx, &v1pb.GetSpaceRequest{Name: space.Name})
|
||||
require.NoError(t, err)
|
||||
require.True(t, proto.Equal(lucide, fetched.Icon), "invalid updates do not change the stored icon")
|
||||
|
||||
update.Space.Icon = nil
|
||||
space, err = service.UpdateSpace(ownerCtx, update)
|
||||
require.NoError(t, err)
|
||||
require.Nil(t, space.Icon)
|
||||
fetched, err = service.GetSpace(ownerCtx, &v1pb.GetSpaceRequest{Name: space.Name})
|
||||
require.NoError(t, err)
|
||||
require.Nil(t, fetched.Icon)
|
||||
}
|
||||
|
||||
func TestCreateSpaceRejectsInvalidIcon(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
service := newIntegrationService(t)
|
||||
owner := createSpaceTestUser(ctx, t, service, "invalid-icon-owner", store.RoleUser)
|
||||
for _, icon := range []*v1pb.Space_Icon{
|
||||
{},
|
||||
{Value: &v1pb.Space_Icon_Emoji{Emoji: "🌱🌱"}},
|
||||
{Value: &v1pb.Space_Icon_Lucide{Lucide: "<svg>"}},
|
||||
} {
|
||||
_, err := service.CreateSpace(userCtx(ctx, owner.ID), &v1pb.CreateSpaceRequest{Space: &v1pb.Space{Title: "Invalid", Icon: icon}})
|
||||
require.Equal(t, codes.InvalidArgument, status.Code(err))
|
||||
}
|
||||
spaces, err := service.ListSpaces(userCtx(ctx, owner.ID), &v1pb.ListSpacesRequest{})
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, spaces.Spaces)
|
||||
}
|
||||
|
|
@ -8,9 +8,11 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/emptypb"
|
||||
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
|
|
@ -98,10 +100,15 @@ func (s *APIV1Service) CreateSpace(ctx context.Context, request *v1pb.CreateSpac
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
icon := convertSpaceIconToStore(request.Space.Icon)
|
||||
if err := store.ValidateSpaceIcon(icon); err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
created, err := s.Store.CreateSpace(ctx, &store.Space{
|
||||
UID: uid,
|
||||
Title: title,
|
||||
Description: strings.TrimSpace(request.Space.Description),
|
||||
Payload: &storepb.SpacePayload{Icon: icon},
|
||||
}, currentUser.ID)
|
||||
if err != nil {
|
||||
return nil, mapSpaceMutationError(err, "failed to create space")
|
||||
|
|
@ -201,6 +208,16 @@ func (s *APIV1Service) UpdateSpace(ctx context.Context, request *v1pb.UpdateSpac
|
|||
case "description":
|
||||
description := strings.TrimSpace(request.Space.Description)
|
||||
update.Description = &description
|
||||
case "icon":
|
||||
icon := convertSpaceIconToStore(request.Space.Icon)
|
||||
if err := store.ValidateSpaceIcon(icon); err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
update.Payload = &storepb.SpacePayload{}
|
||||
if space.Payload != nil {
|
||||
update.Payload = proto.CloneOf(space.Payload)
|
||||
}
|
||||
update.Payload.Icon = icon
|
||||
default:
|
||||
return nil, status.Errorf(codes.InvalidArgument, "unsupported update mask path: %s", path)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package v1
|
|||
|
||||
import (
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
|
|
@ -35,6 +36,36 @@ func convertSpaceMetadataFromStore(space *store.Space) *v1pb.Space {
|
|||
Name: buildSpaceName(space.UID),
|
||||
Title: space.Title,
|
||||
Description: space.Description,
|
||||
Icon: convertSpaceIconFromStore(space.Payload.GetIcon()),
|
||||
}
|
||||
}
|
||||
|
||||
func convertSpaceIconFromStore(icon *storepb.SpacePayload_Icon) *v1pb.Space_Icon {
|
||||
if icon == nil {
|
||||
return nil
|
||||
}
|
||||
switch value := icon.Value.(type) {
|
||||
case *storepb.SpacePayload_Icon_Emoji:
|
||||
return &v1pb.Space_Icon{Value: &v1pb.Space_Icon_Emoji{Emoji: value.Emoji}}
|
||||
case *storepb.SpacePayload_Icon_Lucide:
|
||||
return &v1pb.Space_Icon{Value: &v1pb.Space_Icon_Lucide{Lucide: value.Lucide}}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func convertSpaceIconToStore(icon *v1pb.Space_Icon) *storepb.SpacePayload_Icon {
|
||||
if icon == nil {
|
||||
return nil
|
||||
}
|
||||
switch value := icon.Value.(type) {
|
||||
case *v1pb.Space_Icon_Emoji:
|
||||
return &storepb.SpacePayload_Icon{Value: &storepb.SpacePayload_Icon_Emoji{Emoji: value.Emoji}}
|
||||
case *v1pb.Space_Icon_Lucide:
|
||||
return &storepb.SpacePayload_Icon{Value: &storepb.SpacePayload_Icon_Lucide{Lucide: value.Lucide}}
|
||||
default:
|
||||
// Preserve an empty icon so validation rejects it instead of treating it as a reset.
|
||||
return &storepb.SpacePayload_Icon{}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,40 @@ func TestS3AttachmentLifecycleAcrossStorageChange(t *testing.T) {
|
|||
runS3AttachmentLifecycleAcrossStorageChange(t, fake)
|
||||
}
|
||||
|
||||
func TestUploadAttachmentS3(t *testing.T) {
|
||||
ts := NewTestService(t)
|
||||
defer ts.Cleanup()
|
||||
defer ts.Service.CloseAttachmentUploads()
|
||||
fake := fakes3.New(t, "uploads")
|
||||
ctx := context.Background()
|
||||
user, err := ts.CreateRegularUser(ctx, "chunk-uploader")
|
||||
require.NoError(t, err)
|
||||
ctx = ts.CreateUserContext(ctx, user.ID)
|
||||
storage := fakeStorage("upload-s3", "Uploads", fake.Config("uploads"))
|
||||
upsertS3StorageSetting(ctx, t, ts, storage.Id, storage)
|
||||
chunk := bytes.Repeat([]byte("x"), 2<<20)
|
||||
initial, err := ts.Service.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{Upload: &v1pb.UploadAttachmentRequest_Spec{Spec: &v1pb.UploadAttachmentSpec{
|
||||
Attachment: &v1pb.Attachment{Filename: "large.bin", Type: "application/octet-stream"}, TotalSize: int64(3 * len(chunk)),
|
||||
}}})
|
||||
require.NoError(t, err)
|
||||
var result *v1pb.UploadAttachmentResponse
|
||||
for i := range 3 {
|
||||
result, err = ts.Service.UploadAttachment(ctx, &v1pb.UploadAttachmentRequest{
|
||||
Upload: &v1pb.UploadAttachmentRequest_UploadId{UploadId: initial.UploadId}, WriteOffset: int64(i * len(chunk)), Data: chunk, FinishWrite: i == 2,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
}
|
||||
uid, err := apiv1.ExtractAttachmentUIDFromName(result.Attachment.Name)
|
||||
require.NoError(t, err)
|
||||
row, err := ts.Store.GetAttachment(ctx, &store.FindAttachment{UID: &uid})
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, row.Blob)
|
||||
require.Equal(t, storepb.AttachmentStorageType_S3, row.StorageType)
|
||||
content, err := fake.GetObject("uploads", row.Payload.GetS3Object().GetKey())
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, bytes.Repeat(chunk, 3), content)
|
||||
}
|
||||
|
||||
func TestS3AttachmentLifecycleAcrossStorageChangeMinIO(t *testing.T) {
|
||||
server := testminio.New(t, "attachments-old", "attachments-new")
|
||||
runS3AttachmentLifecycleAcrossStorageChange(t, server)
|
||||
|
|
|
|||
112
server/router/api/v1/test/memo_move_test.go
Normal file
112
server/router/api/v1/test/memo_move_test.go
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/types/known/fieldmaskpb"
|
||||
|
||||
apiv1 "github.com/usememos/memos/proto/gen/api/v1"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
func TestMoveMemoPreservesIndependentConversation(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ts := NewTestService(t)
|
||||
defer ts.Cleanup()
|
||||
author, err := ts.CreateRegularUser(ctx, "move-author")
|
||||
require.NoError(t, err)
|
||||
commenter, err := ts.CreateRegularUser(ctx, "move-commenter")
|
||||
require.NoError(t, err)
|
||||
reader, err := ts.CreateRegularUser(ctx, "move-reader")
|
||||
require.NoError(t, err)
|
||||
authorCtx := ts.CreateUserContext(ctx, author.ID)
|
||||
commenterCtx := ts.CreateUserContext(ctx, commenter.ID)
|
||||
readerCtx := ts.CreateUserContext(ctx, reader.ID)
|
||||
source, err := ts.Store.CreateSpace(ctx, &store.Space{UID: "move-source", Title: "Source"}, author.ID)
|
||||
require.NoError(t, err)
|
||||
target, err := ts.Store.CreateSpace(ctx, &store.Space{UID: "move-target", Title: "Target"}, author.ID)
|
||||
require.NoError(t, err)
|
||||
for _, member := range []*store.SpaceMember{
|
||||
{SpaceID: source.ID, UserID: commenter.ID, Role: store.SpaceMemberRoleUser},
|
||||
{SpaceID: target.ID, UserID: reader.ID, Role: store.SpaceMemberRoleUser},
|
||||
} {
|
||||
_, err := ts.InviteAndAcceptSpaceMember(ctx, member, author.ID)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
sourceName, targetName := "spaces/"+source.UID, "spaces/"+target.UID
|
||||
reference, err := ts.Service.CreateMemo(authorCtx, &apiv1.CreateMemoRequest{Memo: &apiv1.Memo{
|
||||
Content: "source reference", Space: &sourceName, Visibility: apiv1.Visibility_SPACE,
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
attachment, err := ts.Service.CreateAttachment(authorCtx, &apiv1.CreateAttachmentRequest{
|
||||
Attachment: &apiv1.Attachment{Filename: "proposal.txt", Type: "text/plain", Content: []byte("proposal attachment")},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
original, err := ts.Service.CreateMemo(authorCtx, &apiv1.CreateMemoRequest{Memo: &apiv1.Memo{
|
||||
Content: "original memo", Space: &sourceName, Visibility: apiv1.Visibility_SPACE,
|
||||
Attachments: []*apiv1.Attachment{attachment},
|
||||
Relations: []*apiv1.MemoRelation{{Type: apiv1.MemoRelation_REFERENCE, RelatedMemo: &apiv1.MemoRelation_Memo{Name: reference.Name}}},
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
comment, err := ts.Service.CreateMemoComment(commenterCtx, &apiv1.CreateMemoCommentRequest{
|
||||
Name: original.Name, Comment: &apiv1.Memo{Content: "source comment", Space: &sourceName, Visibility: apiv1.Visibility_SPACE},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
reaction, err := ts.Service.UpsertMemoReaction(commenterCtx, &apiv1.UpsertMemoReactionRequest{
|
||||
Name: original.Name, Reaction: &apiv1.Reaction{ReactionType: "👍"},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
moved, err := ts.Service.UpdateMemo(authorCtx, &apiv1.UpdateMemoRequest{
|
||||
Memo: &apiv1.Memo{Name: original.Name, Space: &targetName, Visibility: apiv1.Visibility_SPACE},
|
||||
UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"space", "visibility"}},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, original.Name, moved.Name)
|
||||
require.Equal(t, original.Creator, moved.Creator)
|
||||
require.Equal(t, original.CreateTime, moved.CreateTime)
|
||||
require.Equal(t, original.UpdateTime, moved.UpdateTime)
|
||||
require.Equal(t, original.Content, moved.Content)
|
||||
require.Len(t, moved.Attachments, 1)
|
||||
require.Equal(t, original.Attachments, moved.Attachments)
|
||||
require.Len(t, moved.Relations, 2, "the author in both Spaces retains references and comments")
|
||||
require.Len(t, moved.Reactions, 1)
|
||||
require.Equal(t, reaction.Name, moved.Reactions[0].Name)
|
||||
|
||||
_, err = ts.Service.GetMemo(commenterCtx, &apiv1.GetMemoRequest{Name: original.Name})
|
||||
require.Equal(t, codes.PermissionDenied, status.Code(err))
|
||||
readableComment, err := ts.Service.GetMemo(commenterCtx, &apiv1.GetMemoRequest{Name: comment.Name})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, original.Name, readableComment.GetParent(), "parent identity survives lost parent access")
|
||||
require.Equal(t, sourceName, readableComment.GetSpace())
|
||||
require.Equal(t, comment.Visibility, readableComment.Visibility)
|
||||
require.Equal(t, comment.Content, readableComment.Content)
|
||||
require.Empty(t, readableComment.Relations, "the inaccessible parent must not appear in relation previews")
|
||||
|
||||
for _, viewer := range []context.Context{authorCtx, readerCtx} {
|
||||
comments, err := ts.Service.ListMemoComments(viewer, &apiv1.ListMemoCommentsRequest{Name: original.Name})
|
||||
require.NoError(t, err)
|
||||
if viewer == authorCtx {
|
||||
require.Len(t, comments.Memos, 1)
|
||||
} else {
|
||||
require.Empty(t, comments.Memos)
|
||||
}
|
||||
}
|
||||
destinationMemo, err := ts.Service.GetMemo(readerCtx, &apiv1.GetMemoRequest{Name: original.Name})
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, destinationMemo.Relations)
|
||||
require.Len(t, destinationMemo.Reactions, 1, "existing reactions are visible to new readers")
|
||||
_, err = ts.Service.GetMemo(readerCtx, &apiv1.GetMemoRequest{Name: comment.Name})
|
||||
require.Equal(t, codes.PermissionDenied, status.Code(err))
|
||||
_, err = ts.Service.DeleteMemoReaction(readerCtx, &apiv1.DeleteMemoReactionRequest{Name: reaction.Name})
|
||||
require.Equal(t, codes.PermissionDenied, status.Code(err))
|
||||
_, err = ts.Service.DeleteMemoReaction(commenterCtx, &apiv1.DeleteMemoReactionRequest{Name: reaction.Name})
|
||||
require.NoError(t, err, "the creator can withdraw a reaction without parent access")
|
||||
reactions, err := ts.Service.ListMemoReactions(readerCtx, &apiv1.ListMemoReactionsRequest{Name: original.Name})
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, reactions.Reactions)
|
||||
}
|
||||
|
|
@ -1051,11 +1051,11 @@ func TestGetMemoCommentUsesMemoLocalReadAccessAndConcealsContext(t *testing.T) {
|
|||
commentName := createdComment.Name
|
||||
publicComment, err := ts.Service.GetMemo(ctx, &apiv1.GetMemoRequest{Name: commentName})
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, publicComment.GetParent(), "unreadable context must not be exposed")
|
||||
require.Equal(t, parent.Name, publicComment.GetParent(), "parent identity remains available without granting access")
|
||||
|
||||
otherComment, err := ts.Service.GetMemo(otherCtx, &apiv1.GetMemoRequest{Name: commentName})
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, otherComment.GetParent(), "relation context requires both endpoints to be readable")
|
||||
require.Equal(t, parent.Name, otherComment.GetParent(), "parent identity is independent of parent readability")
|
||||
|
||||
comment, err := ts.Service.GetMemo(ownerCtx, &apiv1.GetMemoRequest{Name: commentName})
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -49,14 +49,14 @@ func TestUpdateMemoTimestamps(t *testing.T) {
|
|||
}})
|
||||
require.NoError(t, err)
|
||||
tc.patch.Name = memo.Name
|
||||
before := time.Now().Unix()
|
||||
beforeSec := time.Now().Unix()
|
||||
updated, err := ts.Service.UpdateMemo(userCtx, &apiv1.UpdateMemoRequest{
|
||||
Memo: tc.patch, UpdateMask: &fieldmaskpb.FieldMask{Paths: tc.paths},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tc.wantCreate, updated.CreateTime.Seconds)
|
||||
if tc.autoUpdate {
|
||||
require.GreaterOrEqual(t, updated.UpdateTime.Seconds, before)
|
||||
require.GreaterOrEqual(t, updated.UpdateTime.Seconds, beforeSec)
|
||||
require.LessOrEqual(t, updated.UpdateTime.Seconds, time.Now().Unix())
|
||||
} else {
|
||||
require.Equal(t, tc.wantUpdate, updated.UpdateTime.Seconds)
|
||||
|
|
|
|||
99
server/router/api/v1/test/memo_view_icon_test.go
Normal file
99
server/router/api/v1/test/memo_view_icon_test.go
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/fieldmaskpb"
|
||||
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
)
|
||||
|
||||
func TestMemoViewIconLifecycle(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ts := NewTestService(t)
|
||||
defer ts.Cleanup()
|
||||
owner, err := ts.CreateRegularUser(ctx, "icon-owner")
|
||||
require.NoError(t, err)
|
||||
other, err := ts.CreateRegularUser(ctx, "icon-other")
|
||||
require.NoError(t, err)
|
||||
ownerCtx := ts.CreateUserContext(ctx, owner.ID)
|
||||
parent := "users/" + owner.Username
|
||||
emoji := &v1pb.MemoView_Icon{Value: &v1pb.MemoView_Icon_Emoji{Emoji: "👩🏽🌾"}}
|
||||
request := &v1pb.CreateMemoViewRequest{
|
||||
Parent: parent,
|
||||
MemoView: &v1pb.MemoView{Title: "Garden", Filter: "pinned", Icon: emoji},
|
||||
ValidateOnly: true,
|
||||
}
|
||||
validated, err := ts.Service.CreateMemoView(ownerCtx, request)
|
||||
require.NoError(t, err)
|
||||
require.True(t, proto.Equal(emoji, validated.Icon))
|
||||
listed, err := ts.Service.ListMemoViews(ownerCtx, &v1pb.ListMemoViewsRequest{Parent: parent})
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, listed.MemoViews)
|
||||
|
||||
request.ValidateOnly = false
|
||||
view, err := ts.Service.CreateMemoView(ownerCtx, request)
|
||||
require.NoError(t, err)
|
||||
require.True(t, proto.Equal(emoji, view.Icon))
|
||||
view, err = ts.Service.UpdateMemoView(ownerCtx, &v1pb.UpdateMemoViewRequest{
|
||||
MemoView: &v1pb.MemoView{Name: view.Name, Title: "Renamed", Filter: "has_link"},
|
||||
UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"title", "filter"}},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.True(t, proto.Equal(emoji, view.Icon), "other field updates preserve the icon")
|
||||
|
||||
lucide := &v1pb.MemoView_Icon{Value: &v1pb.MemoView_Icon_Lucide{Lucide: "future-icon"}}
|
||||
update := &v1pb.UpdateMemoViewRequest{
|
||||
MemoView: &v1pb.MemoView{Name: view.Name, Icon: lucide},
|
||||
UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"icon"}},
|
||||
}
|
||||
_, err = ts.Service.UpdateMemoView(ts.CreateUserContext(ctx, other.ID), update)
|
||||
require.Equal(t, codes.PermissionDenied, status.Code(err))
|
||||
view, err = ts.Service.UpdateMemoView(ownerCtx, update)
|
||||
require.NoError(t, err)
|
||||
require.True(t, proto.Equal(lucide, view.Icon))
|
||||
require.Equal(t, "Renamed", view.Title)
|
||||
require.Equal(t, "has_link", view.Filter)
|
||||
fetched, err := ts.Service.GetMemoView(ownerCtx, &v1pb.GetMemoViewRequest{Name: view.Name})
|
||||
require.NoError(t, err)
|
||||
require.True(t, proto.Equal(lucide, fetched.Icon))
|
||||
listed, err = ts.Service.ListMemoViews(ownerCtx, &v1pb.ListMemoViewsRequest{Parent: parent})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, listed.MemoViews, 1)
|
||||
require.True(t, proto.Equal(lucide, listed.MemoViews[0].Icon))
|
||||
|
||||
for _, invalid := range []*v1pb.MemoView_Icon{
|
||||
{},
|
||||
{Value: &v1pb.MemoView_Icon_Emoji{Emoji: "🌱🌱"}},
|
||||
{Value: &v1pb.MemoView_Icon_Emoji{Emoji: ""}},
|
||||
{Value: &v1pb.MemoView_Icon_Lucide{Lucide: "BookOpen"}},
|
||||
{Value: &v1pb.MemoView_Icon_Lucide{Lucide: ""}},
|
||||
} {
|
||||
request.MemoView.Icon = invalid
|
||||
request.ValidateOnly = true
|
||||
_, err = ts.Service.CreateMemoView(ownerCtx, request)
|
||||
require.Equal(t, codes.InvalidArgument, status.Code(err))
|
||||
request.ValidateOnly = false
|
||||
_, err = ts.Service.CreateMemoView(ownerCtx, request)
|
||||
require.Equal(t, codes.InvalidArgument, status.Code(err))
|
||||
update.MemoView.Icon = invalid
|
||||
_, err = ts.Service.UpdateMemoView(ownerCtx, update)
|
||||
require.Equal(t, codes.InvalidArgument, status.Code(err))
|
||||
}
|
||||
fetched, err = ts.Service.GetMemoView(ownerCtx, &v1pb.GetMemoViewRequest{Name: view.Name})
|
||||
require.NoError(t, err)
|
||||
require.True(t, proto.Equal(lucide, fetched.Icon), "invalid updates leave storage unchanged")
|
||||
|
||||
update.MemoView.Icon = nil
|
||||
view, err = ts.Service.UpdateMemoView(ownerCtx, update)
|
||||
require.NoError(t, err)
|
||||
require.Nil(t, view.Icon)
|
||||
fetched, err = ts.Service.GetMemoView(ownerCtx, &v1pb.GetMemoViewRequest{Name: view.Name})
|
||||
require.NoError(t, err)
|
||||
require.Nil(t, fetched.Icon)
|
||||
}
|
||||
|
|
@ -149,7 +149,7 @@ func TestUpsertMemoReactionRevalidatesSpaceParticipation(t *testing.T) {
|
|||
|
||||
require.NoError(t, ts.Store.DeleteSpaceMember(ctx, &store.DeleteSpaceMember{SpaceID: space.ID, UserID: member.ID}, owner.ID))
|
||||
_, err = ts.Service.DeleteMemoReaction(memberCtx, &apiv1.DeleteMemoReactionRequest{Name: memberReaction.Name})
|
||||
require.Equal(t, codes.PermissionDenied, status.Code(err))
|
||||
require.NoError(t, err, "the creator may withdraw a reaction after leaving")
|
||||
_, err = ts.Service.UpsertMemoReaction(memberCtx, &apiv1.UpsertMemoReactionRequest{
|
||||
Name: memoName,
|
||||
Reaction: &apiv1.Reaction{ReactionType: "🔥"},
|
||||
|
|
@ -162,8 +162,7 @@ func TestUpsertMemoReactionRevalidatesSpaceParticipation(t *testing.T) {
|
|||
Role: store.SpaceMemberRoleUser,
|
||||
}, owner.ID)
|
||||
require.NoError(t, err)
|
||||
_, err = ts.Service.DeleteMemoReaction(memberCtx, &apiv1.DeleteMemoReactionRequest{Name: memberReaction.Name})
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = ts.Service.UpsertMemoReaction(memberCtx, &apiv1.UpsertMemoReactionRequest{
|
||||
Name: memoName,
|
||||
Reaction: &apiv1.Reaction{ReactionType: "🔥"},
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ func convertMemoViewFromStore(username string, memoView *storepb.MemoViewsUserSe
|
|||
Name: constructMemoViewName(username, memoView.GetId()),
|
||||
Title: memoView.GetTitle(),
|
||||
Filter: memoView.GetFilter(),
|
||||
Icon: convertMemoViewIconFromStore(memoView.GetIcon()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -138,6 +139,7 @@ func (s *APIV1Service) CreateMemoView(ctx context.Context, request *v1pb.CreateM
|
|||
Id: util.GenUUID(),
|
||||
Title: request.GetMemoView().GetTitle(),
|
||||
Filter: request.GetMemoView().GetFilter(),
|
||||
Icon: convertMemoViewIconToStore(request.GetMemoView().GetIcon()),
|
||||
}
|
||||
if newMemoView.Title == "" {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "title is required")
|
||||
|
|
@ -145,6 +147,9 @@ func (s *APIV1Service) CreateMemoView(ctx context.Context, request *v1pb.CreateM
|
|||
if err := s.validateFilter(ctx, newMemoView.Filter); err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid filter: %v", err)
|
||||
}
|
||||
if err := store.ValidateMemoViewIcon(newMemoView.Icon); err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid icon: %v", err)
|
||||
}
|
||||
if request.ValidateOnly {
|
||||
return convertMemoViewFromStore(user.Username, newMemoView), nil
|
||||
}
|
||||
|
|
@ -170,6 +175,7 @@ func (s *APIV1Service) UpdateMemoView(ctx context.Context, request *v1pb.UpdateM
|
|||
}
|
||||
|
||||
var title, filterValue *string
|
||||
var icon **storepb.MemoViewsUserSetting_MemoView_Icon
|
||||
for _, field := range request.UpdateMask.Paths {
|
||||
switch field {
|
||||
case "title":
|
||||
|
|
@ -184,12 +190,18 @@ func (s *APIV1Service) UpdateMemoView(ctx context.Context, request *v1pb.UpdateM
|
|||
}
|
||||
value := request.GetMemoView().GetFilter()
|
||||
filterValue = &value
|
||||
case "icon":
|
||||
value := convertMemoViewIconToStore(request.GetMemoView().GetIcon())
|
||||
if err := store.ValidateMemoViewIcon(value); err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid icon: %v", err)
|
||||
}
|
||||
icon = &value
|
||||
default:
|
||||
return nil, status.Errorf(codes.InvalidArgument, "unsupported update mask path: %s", field)
|
||||
}
|
||||
}
|
||||
|
||||
updatedMemoView, err := s.Store.UpdateUserMemoView(ctx, user.ID, memoViewID, title, filterValue)
|
||||
updatedMemoView, err := s.Store.UpdateUserMemoView(ctx, user.ID, memoViewID, title, filterValue, icon)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to update memo view: %v", err)
|
||||
}
|
||||
|
|
@ -25,6 +25,15 @@ import (
|
|||
// it derives its own limit from this constant to keep the two gates in lockstep.
|
||||
const MaxAPIRequestBytes = 256 << 20
|
||||
|
||||
// requestBodyLimit returns the request body cap for a procedure. Chunked
|
||||
// uploads carry at most one chunk per call, so they get a much lower cap.
|
||||
func requestBodyLimit(procedure string) int64 {
|
||||
if procedure == attachmentUploadProcedure {
|
||||
return attachmentUploadRequestLimit
|
||||
}
|
||||
return MaxAPIRequestBytes
|
||||
}
|
||||
|
||||
type APIV1Service struct {
|
||||
v1pb.UnimplementedInstanceServiceServer
|
||||
v1pb.UnimplementedAuthServiceServer
|
||||
|
|
@ -33,7 +42,6 @@ type APIV1Service struct {
|
|||
v1pb.UnimplementedSpaceServiceServer
|
||||
v1pb.UnimplementedAttachmentServiceServer
|
||||
v1pb.UnimplementedAIServiceServer
|
||||
v1pb.UnimplementedMemoViewServiceServer
|
||||
v1pb.UnimplementedIdentityProviderServiceServer
|
||||
|
||||
Secret string
|
||||
|
|
@ -51,6 +59,7 @@ type APIV1Service struct {
|
|||
instanceStatsCache instanceStatsCache
|
||||
|
||||
linkMetadataFetcher linkMetadataFetcher
|
||||
attachmentUploads attachmentUploads
|
||||
}
|
||||
|
||||
// NewAPIV1Service creates an API v1 service with its shared dependencies.
|
||||
|
|
@ -132,6 +141,7 @@ func (s *APIV1Service) RegisterGateway(ctx context.Context, echoServer *echo.Ech
|
|||
if result != nil {
|
||||
r = r.WithContext(auth.ApplyToContext(ctx, result))
|
||||
}
|
||||
r.Body = http.MaxBytesReader(w, r.Body, requestBodyLimit(procedure))
|
||||
|
||||
next(w, r, pathParams)
|
||||
}
|
||||
|
|
@ -163,16 +173,13 @@ func (s *APIV1Service) RegisterGateway(ctx context.Context, echoServer *echo.Ech
|
|||
if err := v1pb.RegisterAIServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := v1pb.RegisterMemoViewServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := v1pb.RegisterIdentityProviderServiceHandlerServer(ctx, gwMux, s); err != nil {
|
||||
return err
|
||||
}
|
||||
gwGroup := echoServer.Group("")
|
||||
// Register SSE endpoint with same CORS as rest of /api/v1.
|
||||
RegisterSSERoutes(gwGroup, s.SSEHub, s.Store, s.Secret)
|
||||
handler := echo.WrapHandler(http.MaxBytesHandler(gwMux, MaxAPIRequestBytes))
|
||||
handler := echo.WrapHandler(gwMux)
|
||||
|
||||
gwGroup.Any("/api/v1/*", handler)
|
||||
gwGroup.Any("/file/*", handler)
|
||||
|
|
@ -187,10 +194,17 @@ func (s *APIV1Service) RegisterGateway(ctx context.Context, echoServer *echo.Ech
|
|||
)
|
||||
connectMux := http.NewServeMux()
|
||||
connectHandler := NewConnectServiceHandler(s)
|
||||
connectHandler.RegisterConnectHandlers(connectMux, connectInterceptors, connect.WithReadMaxBytes(MaxAPIRequestBytes))
|
||||
connectHandler.RegisterConnectHandlers(connectMux, connectInterceptors,
|
||||
// Bound the decompressed message as well as the wire bytes below.
|
||||
connect.WithConditionalHandlerOptions(func(spec connect.Spec) []connect.HandlerOption {
|
||||
return []connect.HandlerOption{connect.WithReadMaxBytes(int(requestBodyLimit(spec.Procedure)))}
|
||||
}))
|
||||
|
||||
connectGroup := echoServer.Group("")
|
||||
connectGroup.Any("/memos.api.v1.*", echo.WrapHandler(http.MaxBytesHandler(connectMux, MaxAPIRequestBytes)))
|
||||
connectGroup.Any("/memos.api.v1.*", echo.WrapHandler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
r.Body = http.MaxBytesReader(w, r.Body, requestBodyLimit(r.URL.Path))
|
||||
connectMux.ServeHTTP(w, r)
|
||||
})))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ a personal access token as a bearer credential. Example client config:
|
|||
|
||||
The server exposes a curated allowlist (`curatedOperationIDs` in `catalog.go`),
|
||||
centered on memos and attachments, plus two read-only orientation tools:
|
||||
`memo_view_list_memo_views` (surfaces a user's named CEL filters for reuse with
|
||||
`user_list_memo_views` (surfaces a user's named CEL filters for reuse with
|
||||
`memo_list_memos`) and `auth_get_current_user` (a "whoami" so an agent can
|
||||
resolve its own user — the single allowed auth/identity operation):
|
||||
|
||||
|
|
@ -175,7 +175,7 @@ resolve its own user — the single allowed auth/identity operation):
|
|||
| `AttachmentService_CreateAttachment` | `attachment_create_attachment` |
|
||||
| `AttachmentService_GetAttachment` | `attachment_get_attachment` |
|
||||
| `AttachmentService_DeleteAttachment` | `attachment_delete_attachment` |
|
||||
| `MemoViewService_ListMemoViews` | `memo_view_list_memo_views` |
|
||||
| `UserService_ListMemoViews` | `user_list_memo_views` |
|
||||
| `AuthService_GetCurrentUser` | `auth_get_current_user` |
|
||||
|
||||
**Naming rule** (`toolNameFromOperationID`): drop the `Service` suffix from the
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ var curatedOperationIDs = []string{
|
|||
"AttachmentService_CreateAttachment",
|
||||
"AttachmentService_GetAttachment",
|
||||
"AttachmentService_DeleteAttachment",
|
||||
"MemoViewService_ListMemoViews",
|
||||
"UserService_ListMemoViews",
|
||||
// The only allowed auth/identity operation: a read-only "whoami" so agents
|
||||
// can resolve the current user (e.g. for MemoViewService_ListMemoViews).
|
||||
// can resolve the current user (e.g. for UserService_ListMemoViews).
|
||||
"AuthService_GetCurrentUser",
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,10 @@ func TestCuratedOperationIDsStayMemoFocused(t *testing.T) {
|
|||
if operationID != "AuthService_GetCurrentUser" {
|
||||
require.NotContains(t, operationID, "AuthService_")
|
||||
}
|
||||
require.NotContains(t, operationID, "UserService_")
|
||||
// Saved memo views are the only user resource exposed through MCP.
|
||||
if operationID != "UserService_ListMemoViews" {
|
||||
require.NotContains(t, operationID, "UserService_")
|
||||
}
|
||||
require.NotContains(t, operationID, "AIService_")
|
||||
require.NotContains(t, operationID, "IdentityProviderService_")
|
||||
require.NotContains(t, operationID, "InstanceService_")
|
||||
|
|
@ -284,8 +287,8 @@ func TestBuildToolFromOperationExposesListMemoViews(t *testing.T) {
|
|||
registry, err := buildOperationRegistry(spec)
|
||||
require.NoError(t, err)
|
||||
|
||||
tool, operation := buildToolFromOperation(registry["MemoViewService_ListMemoViews"])
|
||||
require.Equal(t, "memo_view_list_memo_views", tool.Name)
|
||||
tool, operation := buildToolFromOperation(registry["UserService_ListMemoViews"])
|
||||
require.Equal(t, "user_list_memo_views", tool.Name)
|
||||
require.Equal(t, "GET", operation.Method)
|
||||
require.True(t, tool.Annotations.ReadOnlyHint)
|
||||
|
||||
|
|
|
|||
|
|
@ -62,6 +62,6 @@ content, all of which are stable across re-seeds.
|
|||
`"work" in tags` (or `tags.exists(t, t == "work")`), not `tag == "work"`.
|
||||
- `memo_list_memos` returns only top-level memos; comments are reached via
|
||||
`memo_list_memo_comments`.
|
||||
- The seed defines no memo views and no attachments, so `memo_view_list_memo_views`
|
||||
- The seed defines no memo views and no attachments, so `user_list_memo_views`
|
||||
and the attachment tools return empty sets against a fresh seed. Add seed rows
|
||||
before writing questions that depend on them.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
These questions test whether an LLM can accomplish realistic tasks by
|
||||
composing the curated MCP tools (memo_list_memos with CEL filters,
|
||||
memo_list_memo_comments, memo_list_memo_reactions, memo_view_list_memo_views,
|
||||
memo_list_memo_comments, memo_list_memo_reactions, user_list_memo_views,
|
||||
auth_get_current_user, ...). They are NOT unit tests of the server plumbing —
|
||||
see *_test.go for that.
|
||||
|
||||
|
|
|
|||
|
|
@ -30,9 +30,9 @@ type Server struct {
|
|||
Profile *profile.Profile
|
||||
Store *store.Store
|
||||
|
||||
echoServer *echo.Echo
|
||||
httpServer *http.Server
|
||||
sseHub *apiv1.SSEHub
|
||||
echoServer *echo.Echo
|
||||
httpServer *http.Server
|
||||
apiV1Service *apiv1.APIV1Service
|
||||
}
|
||||
|
||||
func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store) (*Server, error) {
|
||||
|
|
@ -66,7 +66,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
|
|||
frontend.NewFrontendService(profile, store).Serve(ctx, echoServer)
|
||||
|
||||
apiV1Service := apiv1.NewAPIV1Service(s.Secret, profile, store)
|
||||
s.sseHub = apiV1Service.SSEHub
|
||||
s.apiV1Service = apiV1Service
|
||||
|
||||
// Register HTTP file server routes BEFORE gRPC-Gateway to ensure proper range request handling for Safari.
|
||||
// This uses native HTTP serving (http.ServeContent) instead of gRPC for video/audio files.
|
||||
|
|
@ -127,6 +127,7 @@ func (s *Server) Shutdown(ctx context.Context) {
|
|||
|
||||
s.closeLongLivedConnections()
|
||||
s.shutdownHTTPServer(ctx)
|
||||
s.apiV1Service.CloseAttachmentUploads()
|
||||
|
||||
// Close database connection.
|
||||
if err := s.Store.Close(); err != nil {
|
||||
|
|
@ -138,9 +139,7 @@ func (s *Server) Shutdown(ctx context.Context) {
|
|||
|
||||
func (s *Server) closeLongLivedConnections() {
|
||||
// Long-lived SSE requests do not finish on their own during http.Server.Shutdown.
|
||||
if s.sseHub != nil {
|
||||
s.sseHub.Close()
|
||||
}
|
||||
s.apiV1Service.SSEHub.Close()
|
||||
}
|
||||
|
||||
func (s *Server) shutdownHTTPServer(ctx context.Context) {
|
||||
|
|
|
|||
33
store/custom_icon.go
Normal file
33
store/custom_icon.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package store
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/usememos/memos/internal/markdown/parser"
|
||||
)
|
||||
|
||||
func validateEmojiIcon(emoji string) error {
|
||||
if !parser.IsEmoji(emoji) {
|
||||
return errors.New("icon must contain one fully qualified emoji")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateLucideIcon(name string) error {
|
||||
if len(name) == 0 || len(name) > 128 {
|
||||
return errors.New("icon name must contain 1 to 128 bytes")
|
||||
}
|
||||
for _, part := range strings.Split(name, "-") {
|
||||
if part == "" {
|
||||
return errors.New("icon name must use lowercase kebab-case")
|
||||
}
|
||||
for _, char := range part {
|
||||
if (char < 'a' || char > 'z') && (char < '0' || char > '9') {
|
||||
return errors.New("icon name must use lowercase kebab-case")
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
@ -157,7 +157,7 @@ func (d *DB) deleteReactionAsCreator(ctx context.Context, delete *store.DeleteRe
|
|||
}
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if delete.Policy != nil {
|
||||
if err := validateMySQLReactionWritePolicy(ctx, tx, &store.Reaction{
|
||||
if err := validateMySQLReactionDeletePolicy(ctx, tx, &store.Reaction{
|
||||
CreatorID: *delete.ActorUserID,
|
||||
MemoID: *delete.MemoID,
|
||||
Policy: delete.Policy,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,18 @@ func validateMySQLReactionWritePolicy(ctx context.Context, tx *sql.Tx, reaction
|
|||
return store.ValidateReactionWriteParticipation(reaction, participation)
|
||||
}
|
||||
|
||||
func validateMySQLReactionDeletePolicy(ctx context.Context, tx *sql.Tx, reaction *store.Reaction) error {
|
||||
policy := reaction.Policy
|
||||
participation, err := loadMySQLMemoParticipation(ctx, tx, reaction.MemoID, policy.ActorUserID)
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return store.ErrReactionMemoNotFound
|
||||
}
|
||||
return errors.Wrap(err, "failed to read reaction participation")
|
||||
}
|
||||
return store.ValidateReactionWithdrawal(reaction, participation)
|
||||
}
|
||||
|
||||
func mysqlSpaceMemberActive(ctx context.Context, tx *sql.Tx, spaceID, userID int32) (bool, error) {
|
||||
var role store.SpaceMemberRole
|
||||
err := tx.QueryRowContext(ctx, `SELECT role FROM space_member
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ import (
|
|||
|
||||
mysqldriver "github.com/go-sql-driver/mysql"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
|
|
@ -23,9 +25,17 @@ func (d *DB) CreateSpace(ctx context.Context, create *store.Space, creatorID int
|
|||
if err := lockMySQLActiveUser(ctx, tx, creatorID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fields := []string{"uid", "title", "description"}
|
||||
values := []string{"?", "?", "?"}
|
||||
args := []any{create.UID, create.Title, create.Description}
|
||||
payload := "{}"
|
||||
if create.Payload != nil {
|
||||
data, err := protojson.Marshal(create.Payload)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to marshal space payload")
|
||||
}
|
||||
payload = string(data)
|
||||
}
|
||||
fields := []string{"uid", "title", "description", "payload"}
|
||||
values := []string{"?", "?", "?", "?"}
|
||||
args := []any{create.UID, create.Title, create.Description, payload}
|
||||
result, err := tx.ExecContext(ctx, "INSERT INTO space ("+strings.Join(fields, ", ")+") VALUES ("+strings.Join(values, ", ")+")", args...)
|
||||
if err != nil {
|
||||
if isMySQLUniqueViolation(err) {
|
||||
|
|
@ -55,7 +65,7 @@ func (d *DB) CreateSpace(ctx context.Context, create *store.Space, creatorID int
|
|||
|
||||
func (d *DB) ListSpaces(ctx context.Context, find *store.FindSpace) ([]*store.Space, error) {
|
||||
where, args := []string{"1 = 1"}, []any{}
|
||||
selectFields := "space.id, space.uid, space.title, space.description"
|
||||
selectFields := "space.id, space.uid, space.title, space.description, space.payload"
|
||||
joins := ""
|
||||
groupBy := ""
|
||||
if find.ID != nil {
|
||||
|
|
@ -119,6 +129,13 @@ func (d *DB) UpdateSpace(ctx context.Context, update *store.UpdateSpace, actorUs
|
|||
if update.Description != nil {
|
||||
sets, args = append(sets, "description = ?"), append(args, *update.Description)
|
||||
}
|
||||
if update.Payload != nil {
|
||||
data, err := protojson.Marshal(update.Payload)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to marshal space payload")
|
||||
}
|
||||
sets, args = append(sets, "payload = ?"), append(args, string(data))
|
||||
}
|
||||
args = append(args, update.ID)
|
||||
if _, err := tx.ExecContext(ctx, "UPDATE space SET "+strings.Join(sets, ", ")+" WHERE id = ?", args...); err != nil {
|
||||
return nil, err
|
||||
|
|
@ -434,14 +451,20 @@ func (d *DB) DeleteSpaceMember(ctx context.Context, delete *store.DeleteSpaceMem
|
|||
type mysqlRowScanner interface{ Scan(...any) error }
|
||||
|
||||
func scanMySQLSpace(row mysqlRowScanner, space *store.Space) error {
|
||||
return row.Scan(&space.ID, &space.UID, &space.Title, &space.Description)
|
||||
return scanMySQLSpaceWithSummary(row, space, false)
|
||||
}
|
||||
|
||||
func scanMySQLSpaceWithSummary(row mysqlRowScanner, space *store.Space, withSummary bool) error {
|
||||
if !withSummary {
|
||||
return scanMySQLSpace(row, space)
|
||||
var payloadBytes []byte
|
||||
targets := []any{&space.ID, &space.UID, &space.Title, &space.Description, &payloadBytes}
|
||||
if withSummary {
|
||||
targets = append(targets, &space.CurrentUserRole, &space.MemberCount)
|
||||
}
|
||||
return row.Scan(&space.ID, &space.UID, &space.Title, &space.Description, &space.CurrentUserRole, &space.MemberCount)
|
||||
if err := row.Scan(targets...); err != nil {
|
||||
return err
|
||||
}
|
||||
space.Payload = &storepb.SpacePayload{}
|
||||
return errors.Wrap(protojsonUnmarshaler.Unmarshal(payloadBytes, space.Payload), "failed to unmarshal space payload")
|
||||
}
|
||||
|
||||
func scanMySQLSpaceSummary(row mysqlRowScanner, space *store.Space) error {
|
||||
|
|
@ -462,7 +485,7 @@ func populateMySQLSpaceSummary(ctx context.Context, tx *sql.Tx, space *store.Spa
|
|||
|
||||
func getMySQLSpace(ctx context.Context, tx *sql.Tx, id int32) (*store.Space, error) {
|
||||
space := &store.Space{}
|
||||
return space, scanMySQLSpace(tx.QueryRowContext(ctx, `SELECT id, uid, title, description FROM space WHERE id = ?`, id), space)
|
||||
return space, scanMySQLSpace(tx.QueryRowContext(ctx, `SELECT id, uid, title, description, payload FROM space WHERE id = ?`, id), space)
|
||||
}
|
||||
|
||||
func getMySQLSpaceMember(ctx context.Context, tx *sql.Tx, spaceID, userID int32) (*store.SpaceMember, error) {
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ func (d *DB) deleteReactionAsCreator(ctx context.Context, delete *store.DeleteRe
|
|||
}
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if delete.Policy != nil {
|
||||
if err := validatePostgresReactionWritePolicy(ctx, tx, &store.Reaction{
|
||||
if err := validatePostgresReactionDeletePolicy(ctx, tx, &store.Reaction{
|
||||
CreatorID: *delete.ActorUserID,
|
||||
MemoID: *delete.MemoID,
|
||||
Policy: delete.Policy,
|
||||
|
|
|
|||
|
|
@ -20,3 +20,15 @@ func validatePostgresReactionWritePolicy(ctx context.Context, tx *sql.Tx, reacti
|
|||
}
|
||||
return store.ValidateReactionWriteParticipation(reaction, participation)
|
||||
}
|
||||
|
||||
func validatePostgresReactionDeletePolicy(ctx context.Context, tx *sql.Tx, reaction *store.Reaction) error {
|
||||
policy := reaction.Policy
|
||||
participation, err := readPostgresMemoParticipation(ctx, tx, reaction.MemoID, policy.ActorUserID)
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return store.ErrReactionMemoNotFound
|
||||
}
|
||||
return errors.Wrap(err, "failed to read reaction participation")
|
||||
}
|
||||
return store.ValidateReactionWithdrawal(reaction, participation)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ import (
|
|||
|
||||
"github.com/lib/pq"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
|
|
@ -23,16 +25,29 @@ func (d *DB) CreateSpace(ctx context.Context, create *store.Space, creatorID int
|
|||
if err := lockPostgresActiveUser(ctx, tx, creatorID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fields := []string{"uid", "title", "description"}
|
||||
args := []any{create.UID, create.Title, create.Description}
|
||||
payload := "{}"
|
||||
if create.Payload != nil {
|
||||
data, err := protojson.Marshal(create.Payload)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to marshal space payload")
|
||||
}
|
||||
payload = string(data)
|
||||
}
|
||||
fields := []string{"uid", "title", "description", "payload"}
|
||||
args := []any{create.UID, create.Title, create.Description, payload}
|
||||
space := &store.Space{}
|
||||
query := "INSERT INTO space (" + strings.Join(fields, ", ") + ") VALUES (" + placeholders(len(args)) + ") RETURNING id, uid, title, description"
|
||||
if err := tx.QueryRowContext(ctx, query, args...).Scan(&space.ID, &space.UID, &space.Title, &space.Description); err != nil {
|
||||
var payloadBytes []byte
|
||||
query := "INSERT INTO space (" + strings.Join(fields, ", ") + ") VALUES (" + placeholders(len(args)) + ") RETURNING id, uid, title, description, payload"
|
||||
if err := tx.QueryRowContext(ctx, query, args...).Scan(&space.ID, &space.UID, &space.Title, &space.Description, &payloadBytes); err != nil {
|
||||
if isPostgresUniqueViolation(err) {
|
||||
return nil, store.ErrSpaceAlreadyExists
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
space.Payload = &storepb.SpacePayload{}
|
||||
if err := protojsonUnmarshaler.Unmarshal(payloadBytes, space.Payload); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to unmarshal space payload")
|
||||
}
|
||||
if _, err := tx.ExecContext(ctx, "INSERT INTO space_member (space_id, user_id, status, role) VALUES ($1, $2, $3, $4)", space.ID, creatorID, store.SpaceMemberStatusActive, store.SpaceMemberRoleAdmin); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -46,7 +61,7 @@ func (d *DB) CreateSpace(ctx context.Context, create *store.Space, creatorID int
|
|||
|
||||
func (d *DB) ListSpaces(ctx context.Context, find *store.FindSpace) ([]*store.Space, error) {
|
||||
where, args := []string{"1 = 1"}, []any{}
|
||||
selectFields := "space.id, space.uid, space.title, space.description"
|
||||
selectFields := "space.id, space.uid, space.title, space.description, space.payload"
|
||||
joins := ""
|
||||
groupBy := ""
|
||||
add := func(condition string, value any) {
|
||||
|
|
@ -75,7 +90,7 @@ func (d *DB) ListSpaces(ctx context.Context, find *store.FindSpace) ([]*store.Sp
|
|||
JOIN "user" active_user ON active_user.id = active_member.user_id AND active_user.row_status = 'NORMAL'`
|
||||
add("viewer_member.user_id = %s", *find.MemberUserID)
|
||||
where = append(where, "viewer_member.status = 'ACTIVE'", "viewer_member.role IN ('ADMIN', 'USER')", "viewer_user.row_status = 'NORMAL'")
|
||||
groupBy = " GROUP BY space.id, space.uid, space.title, space.description, viewer_member.role"
|
||||
groupBy = " GROUP BY space.id, space.uid, space.title, space.description, space.payload, viewer_member.role"
|
||||
}
|
||||
query := "SELECT " + selectFields + " FROM space" + joins + " WHERE " + strings.Join(where, " AND ") + groupBy + " ORDER BY space.id DESC"
|
||||
query = appendPostgresLimit(query, find.Limit, find.Offset)
|
||||
|
|
@ -87,13 +102,18 @@ func (d *DB) ListSpaces(ctx context.Context, find *store.FindSpace) ([]*store.Sp
|
|||
spaces := []*store.Space{}
|
||||
for rows.Next() {
|
||||
space := &store.Space{}
|
||||
scanTargets := []any{&space.ID, &space.UID, &space.Title, &space.Description}
|
||||
var payloadBytes []byte
|
||||
scanTargets := []any{&space.ID, &space.UID, &space.Title, &space.Description, &payloadBytes}
|
||||
if find.MemberUserID != nil {
|
||||
scanTargets = append(scanTargets, &space.CurrentUserRole, &space.MemberCount)
|
||||
}
|
||||
if err := rows.Scan(scanTargets...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
space.Payload = &storepb.SpacePayload{}
|
||||
if err := protojsonUnmarshaler.Unmarshal(payloadBytes, space.Payload); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to unmarshal space payload")
|
||||
}
|
||||
spaces = append(spaces, space)
|
||||
}
|
||||
return spaces, rows.Err()
|
||||
|
|
@ -122,12 +142,24 @@ func (d *DB) UpdateSpace(ctx context.Context, update *store.UpdateSpace, actorUs
|
|||
if update.Description != nil {
|
||||
add("description", *update.Description)
|
||||
}
|
||||
if update.Payload != nil {
|
||||
data, err := protojson.Marshal(update.Payload)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to marshal space payload")
|
||||
}
|
||||
add("payload", string(data))
|
||||
}
|
||||
args = append(args, update.ID)
|
||||
space := &store.Space{}
|
||||
query := "UPDATE space SET " + strings.Join(sets, ", ") + " WHERE id = " + placeholder(len(args)) + " RETURNING id, uid, title, description"
|
||||
if err := tx.QueryRowContext(ctx, query, args...).Scan(&space.ID, &space.UID, &space.Title, &space.Description); err != nil {
|
||||
var payloadBytes []byte
|
||||
query := "UPDATE space SET " + strings.Join(sets, ", ") + " WHERE id = " + placeholder(len(args)) + " RETURNING id, uid, title, description, payload"
|
||||
if err := tx.QueryRowContext(ctx, query, args...).Scan(&space.ID, &space.UID, &space.Title, &space.Description, &payloadBytes); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
space.Payload = &storepb.SpacePayload{}
|
||||
if err := protojsonUnmarshaler.Unmarshal(payloadBytes, space.Payload); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to unmarshal space payload")
|
||||
}
|
||||
if err := populatePostgresSpaceSummary(ctx, tx, space, actorUserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ func (d *DB) deleteReactionAsCreator(ctx context.Context, delete *store.DeleteRe
|
|||
}
|
||||
defer func() { _ = tx.Rollback() }()
|
||||
if delete.Policy != nil {
|
||||
if err := validateSQLiteReactionWritePolicy(ctx, tx, &store.Reaction{
|
||||
if err := validateSQLiteReactionDeletePolicy(ctx, tx, &store.Reaction{
|
||||
CreatorID: *delete.ActorUserID,
|
||||
MemoID: *delete.MemoID,
|
||||
Policy: delete.Policy,
|
||||
|
|
|
|||
|
|
@ -21,6 +21,18 @@ func validateSQLiteReactionWritePolicy(ctx context.Context, tx dbExecutor, react
|
|||
return store.ValidateReactionWriteParticipation(reaction, participation)
|
||||
}
|
||||
|
||||
func validateSQLiteReactionDeletePolicy(ctx context.Context, tx dbExecutor, reaction *store.Reaction) error {
|
||||
policy := reaction.Policy
|
||||
participation, err := loadSQLiteMemoParticipation(ctx, tx, reaction.MemoID, policy.ActorUserID)
|
||||
if err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return store.ErrReactionMemoNotFound
|
||||
}
|
||||
return errors.Wrap(err, "failed to read reaction participation")
|
||||
}
|
||||
return store.ValidateReactionWithdrawal(reaction, participation)
|
||||
}
|
||||
|
||||
func sqliteSpaceMemberActive(ctx context.Context, tx dbExecutor, spaceID, userID int32) (bool, error) {
|
||||
var role store.SpaceMemberRole
|
||||
err := tx.QueryRowContext(ctx, `SELECT role FROM space_member
|
||||
|
|
|
|||
|
|
@ -7,9 +7,11 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
msqlite "modernc.org/sqlite"
|
||||
sqlite3 "modernc.org/sqlite/lib"
|
||||
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
|
|
@ -23,17 +25,30 @@ func (d *DB) CreateSpace(ctx context.Context, create *store.Space, creatorID int
|
|||
return nil, err
|
||||
}
|
||||
|
||||
fields := []string{"uid", "title", "description"}
|
||||
values := []string{"?", "?", "?"}
|
||||
args := []any{create.UID, create.Title, create.Description}
|
||||
query := "INSERT INTO space (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(values, ", ") + ") RETURNING id, uid, title, description"
|
||||
payload := "{}"
|
||||
if create.Payload != nil {
|
||||
data, err := protojson.Marshal(create.Payload)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to marshal space payload")
|
||||
}
|
||||
payload = string(data)
|
||||
}
|
||||
fields := []string{"uid", "title", "description", "payload"}
|
||||
values := []string{"?", "?", "?", "?"}
|
||||
args := []any{create.UID, create.Title, create.Description, payload}
|
||||
query := "INSERT INTO space (" + strings.Join(fields, ", ") + ") VALUES (" + strings.Join(values, ", ") + ") RETURNING id, uid, title, description, payload"
|
||||
space := &store.Space{}
|
||||
if err := tx.QueryRowContext(ctx, query, args...).Scan(&space.ID, &space.UID, &space.Title, &space.Description); err != nil {
|
||||
var payloadBytes []byte
|
||||
if err := tx.QueryRowContext(ctx, query, args...).Scan(&space.ID, &space.UID, &space.Title, &space.Description, &payloadBytes); err != nil {
|
||||
if isSQLiteUniqueViolation(err) {
|
||||
return nil, store.ErrSpaceAlreadyExists
|
||||
}
|
||||
return nil, errors.Wrap(err, "failed to create space")
|
||||
}
|
||||
space.Payload = &storepb.SpacePayload{}
|
||||
if err := protojsonUnmarshaler.Unmarshal(payloadBytes, space.Payload); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to unmarshal space payload")
|
||||
}
|
||||
if _, err := tx.ExecContext(ctx, "INSERT INTO space_member (space_id, user_id, status, role) VALUES (?, ?, ?, ?)", space.ID, creatorID, store.SpaceMemberStatusActive, store.SpaceMemberRoleAdmin); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to create initial space admin")
|
||||
}
|
||||
|
|
@ -47,7 +62,7 @@ func (d *DB) CreateSpace(ctx context.Context, create *store.Space, creatorID int
|
|||
|
||||
func (d *DB) ListSpaces(ctx context.Context, find *store.FindSpace) ([]*store.Space, error) {
|
||||
where, args := []string{"1 = 1"}, []any{}
|
||||
selectFields := "space.id, space.uid, space.title, space.description"
|
||||
selectFields := "space.id, space.uid, space.title, space.description, space.payload"
|
||||
joins := ""
|
||||
groupBy := ""
|
||||
if find.ID != nil {
|
||||
|
|
@ -72,7 +87,7 @@ func (d *DB) ListSpaces(ctx context.Context, find *store.FindSpace) ([]*store.Sp
|
|||
JOIN user active_user ON active_user.id = active_member.user_id AND active_user.row_status = 'NORMAL'`
|
||||
where = append(where, "viewer_member.user_id = ?", "viewer_member.status = 'ACTIVE'", "viewer_member.role IN ('ADMIN', 'USER')", "viewer_user.row_status = 'NORMAL'")
|
||||
args = append(args, *find.MemberUserID)
|
||||
groupBy = " GROUP BY space.id, space.uid, space.title, space.description, viewer_member.role"
|
||||
groupBy = " GROUP BY space.id, space.uid, space.title, space.description, space.payload, viewer_member.role"
|
||||
}
|
||||
query := "SELECT " + selectFields + " FROM space" + joins + " WHERE " + strings.Join(where, " AND ") + groupBy + " ORDER BY space.id DESC"
|
||||
query = appendSQLiteLimit(query, find.Limit, find.Offset)
|
||||
|
|
@ -84,13 +99,18 @@ func (d *DB) ListSpaces(ctx context.Context, find *store.FindSpace) ([]*store.Sp
|
|||
spaces := []*store.Space{}
|
||||
for rows.Next() {
|
||||
space := &store.Space{}
|
||||
scanTargets := []any{&space.ID, &space.UID, &space.Title, &space.Description}
|
||||
var payloadBytes []byte
|
||||
scanTargets := []any{&space.ID, &space.UID, &space.Title, &space.Description, &payloadBytes}
|
||||
if find.MemberUserID != nil {
|
||||
scanTargets = append(scanTargets, &space.CurrentUserRole, &space.MemberCount)
|
||||
}
|
||||
if err := rows.Scan(scanTargets...); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
space.Payload = &storepb.SpacePayload{}
|
||||
if err := protojsonUnmarshaler.Unmarshal(payloadBytes, space.Payload); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to unmarshal space payload")
|
||||
}
|
||||
spaces = append(spaces, space)
|
||||
}
|
||||
return spaces, rows.Err()
|
||||
|
|
@ -112,13 +132,25 @@ func (d *DB) UpdateSpace(ctx context.Context, update *store.UpdateSpace, actorUs
|
|||
if update.Description != nil {
|
||||
sets, args = append(sets, "description = ?"), append(args, *update.Description)
|
||||
}
|
||||
if update.Payload != nil {
|
||||
data, err := protojson.Marshal(update.Payload)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to marshal space payload")
|
||||
}
|
||||
sets, args = append(sets, "payload = ?"), append(args, string(data))
|
||||
}
|
||||
args = append(args, update.ID)
|
||||
query := `UPDATE space SET ` + strings.Join(sets, ", ") + ` WHERE id = ?
|
||||
RETURNING id, uid, title, description`
|
||||
RETURNING id, uid, title, description, payload`
|
||||
space := &store.Space{}
|
||||
if err := tx.QueryRowContext(ctx, query, args...).Scan(&space.ID, &space.UID, &space.Title, &space.Description); err != nil {
|
||||
var payloadBytes []byte
|
||||
if err := tx.QueryRowContext(ctx, query, args...).Scan(&space.ID, &space.UID, &space.Title, &space.Description, &payloadBytes); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
space.Payload = &storepb.SpacePayload{}
|
||||
if err := protojsonUnmarshaler.Unmarshal(payloadBytes, space.Payload); err != nil {
|
||||
return nil, errors.Wrap(err, "failed to unmarshal space payload")
|
||||
}
|
||||
if err := populateSQLiteSpaceSummary(ctx, tx, space, actorUserID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
22
store/memo_view_icon.go
Normal file
22
store/memo_view_icon.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package store
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
)
|
||||
|
||||
// ValidateMemoViewIcon validates optional display metadata for a saved view.
|
||||
func ValidateMemoViewIcon(icon *storepb.MemoViewsUserSetting_MemoView_Icon) error {
|
||||
if icon == nil {
|
||||
return nil
|
||||
}
|
||||
switch value := icon.Value.(type) {
|
||||
case *storepb.MemoViewsUserSetting_MemoView_Icon_Emoji:
|
||||
return validateEmojiIcon(value.Emoji)
|
||||
case *storepb.MemoViewsUserSetting_MemoView_Icon_Lucide:
|
||||
return validateLucideIcon(value.Lucide)
|
||||
default:
|
||||
return errors.New("view icon must specify emoji or lucide")
|
||||
}
|
||||
}
|
||||
3
store/migration/mysql/0.31/06__space_payload.sql
Normal file
3
store/migration/mysql/0.31/06__space_payload.sql
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ALTER TABLE space ADD COLUMN payload JSON;
|
||||
UPDATE space SET payload = '{}';
|
||||
ALTER TABLE space MODIFY COLUMN payload JSON NOT NULL;
|
||||
|
|
@ -33,7 +33,8 @@ CREATE TABLE `space` (
|
|||
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
`uid` VARCHAR(256) NOT NULL UNIQUE,
|
||||
`title` TEXT NOT NULL,
|
||||
`description` TEXT NOT NULL
|
||||
`description` TEXT NOT NULL,
|
||||
`payload` JSON NOT NULL
|
||||
);
|
||||
|
||||
-- space membership
|
||||
|
|
|
|||
1
store/migration/postgres/0.31/06__space_payload.sql
Normal file
1
store/migration/postgres/0.31/06__space_payload.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE space ADD COLUMN payload JSONB NOT NULL DEFAULT '{}';
|
||||
|
|
@ -33,7 +33,8 @@ CREATE TABLE space (
|
|||
id SERIAL PRIMARY KEY,
|
||||
uid TEXT NOT NULL UNIQUE,
|
||||
title TEXT NOT NULL,
|
||||
description TEXT NOT NULL DEFAULT ''
|
||||
description TEXT NOT NULL DEFAULT '',
|
||||
payload JSONB NOT NULL DEFAULT '{}'
|
||||
);
|
||||
|
||||
-- space membership
|
||||
|
|
|
|||
1
store/migration/sqlite/0.31/06__space_payload.sql
Normal file
1
store/migration/sqlite/0.31/06__space_payload.sql
Normal file
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE space ADD COLUMN payload TEXT NOT NULL DEFAULT '{}';
|
||||
|
|
@ -34,7 +34,8 @@ CREATE TABLE space (
|
|||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
uid TEXT NOT NULL UNIQUE,
|
||||
title TEXT NOT NULL,
|
||||
description TEXT NOT NULL DEFAULT ''
|
||||
description TEXT NOT NULL DEFAULT '',
|
||||
payload TEXT NOT NULL DEFAULT '{}'
|
||||
);
|
||||
|
||||
-- space membership
|
||||
|
|
|
|||
|
|
@ -25,6 +25,16 @@ func validateReactionWritePolicy(reaction *Reaction) error {
|
|||
// ValidateReactionWriteParticipation applies the reaction actor identity and
|
||||
// memo-local participation rules to state loaded by the write transaction.
|
||||
func ValidateReactionWriteParticipation(reaction *Reaction, snapshot *MemoCommentAuthorizationSnapshot) error {
|
||||
if err := ValidateReactionWithdrawal(reaction, snapshot); err != nil {
|
||||
return err
|
||||
}
|
||||
return ValidateMemoCommentAuthorization(snapshot)
|
||||
}
|
||||
|
||||
// ValidateReactionWithdrawal allows an active actor to withdraw their own reaction
|
||||
// without requiring continued access to or participation in the memo. The driver
|
||||
// also verifies ownership of the stored reaction in the same transaction.
|
||||
func ValidateReactionWithdrawal(reaction *Reaction, snapshot *MemoCommentAuthorizationSnapshot) error {
|
||||
if err := validateReactionWritePolicy(reaction); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -40,5 +50,5 @@ func ValidateReactionWriteParticipation(reaction *Reaction, snapshot *MemoCommen
|
|||
if snapshot.ContextID != reaction.MemoID {
|
||||
return ErrMemoMutationConflict
|
||||
}
|
||||
return ValidateMemoCommentAuthorization(snapshot)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
-- ============================================================================
|
||||
-- Memos demo seed data
|
||||
-- Memos seed data
|
||||
--
|
||||
-- Login on the demo instance is SSO-only, so visitors always arrive as a
|
||||
-- brand-new user with an empty timeline. All seed content is therefore
|
||||
|
|
@ -7,7 +7,8 @@
|
|||
-- * PUBLIC memos — the logged-out storefront (screenshots, first visit)
|
||||
-- * PROTECTED memos — the reward for signing in; Explore visibly gains
|
||||
-- content after login, teaching the visibility model
|
||||
-- * PRIVATE memos — none seeded: nobody can ever log in as a seed user
|
||||
-- * PRIVATE / SPACE — none seeded: visitors cannot sign in as seed users
|
||||
-- or access their Space memberships
|
||||
--
|
||||
-- Cast (passwords were random and discarded — seed users are NPCs):
|
||||
-- 1 steven (ADMIN) — Memos maintainer; welcome, sponsors, changelog, tips
|
||||
|
|
@ -16,20 +17,54 @@
|
|||
-- 4 sam (USER) — reader & cook; books, recipes, movie lists
|
||||
-- ============================================================================
|
||||
|
||||
INSERT INTO user (id,username,role,nickname,description,password_hash) VALUES(1,'steven','ADMIN','Steven','Creator & maintainer of Memos. I water this demo instance daily 🪴','$2y$12$A/8h4XS6hQmRVVSRFQHsR.wWVJbSG40avhuphOBdK5ws99W1kunr6');
|
||||
INSERT INTO user (id,username,role,nickname,description,password_hash) VALUES(1,'steven','ADMIN','Steven','Creator & maintainer of Memos. Product updates and notes from building it 🪴','$2y$12$A/8h4XS6hQmRVVSRFQHsR.wWVJbSG40avhuphOBdK5ws99W1kunr6');
|
||||
INSERT INTO user (id,username,role,nickname,description,password_hash) VALUES(2,'johnny','USER','Johnny','Backend dev. Notes about Git, Go, and whatever I broke today 🔧','$2y$12$CaqLYlvpHjL1qbVNny0lre59ctT2doIvVLh4Pn1yipsDUtbcbeum6');
|
||||
INSERT INTO user (id,username,role,nickname,description,password_hash) VALUES(3,'bob','USER','Bob','Traveling photographer. Writing places down before I forget them 🌍','$2y$12$A/8h4XS6hQmRVVSRFQHsR.wWVJbSG40avhuphOBdK5ws99W1kunr6');
|
||||
INSERT INTO user (id,username,role,nickname,description,password_hash) VALUES(4,'sam','USER','Sam','Reader, cook, maker of lists 📚🍜','$2y$12$CaqLYlvpHjL1qbVNny0lre59ctT2doIvVLh4Pn1yipsDUtbcbeum6');
|
||||
|
||||
-- ============================================================================
|
||||
-- Spaces — placement and audience are independent. Public and protected memos
|
||||
-- remain readable to non-members, but their Space names and icons are only
|
||||
-- available to their authors and members. New SSO users are not auto-enrolled.
|
||||
-- ============================================================================
|
||||
|
||||
INSERT INTO space (id,uid,title,description,payload) VALUES(1,'updates','Updates','Announcements and tips.','{"icon":{"lucide":"sprout"}}');
|
||||
INSERT INTO space (id,uid,title,description,payload) VALUES(2,'dev','Dev','Projects and technical notes.','{"icon":{"lucide":"wrench"}}');
|
||||
INSERT INTO space (id,uid,title,description,payload) VALUES(3,'travel','Travel','Trips and photography.','{"icon":{"emoji":"🌍"}}');
|
||||
INSERT INTO space (id,uid,title,description,payload) VALUES(4,'reading','Reading','Books and quotes.','{"icon":{"emoji":"📚"}}');
|
||||
|
||||
-- Updates: Steven manages announcements; everyone participates.
|
||||
INSERT INTO space_member (space_id,user_id,status,role) VALUES(1,1,'ACTIVE','ADMIN');
|
||||
INSERT INTO space_member (space_id,user_id,status,role) VALUES(1,2,'ACTIVE','USER');
|
||||
INSERT INTO space_member (space_id,user_id,status,role) VALUES(1,3,'ACTIVE','USER');
|
||||
INSERT INTO space_member (space_id,user_id,status,role) VALUES(1,4,'ACTIVE','USER');
|
||||
|
||||
-- Dev: Johnny leads, with Steven and Bob.
|
||||
INSERT INTO space_member (space_id,user_id,status,role) VALUES(2,2,'ACTIVE','ADMIN');
|
||||
INSERT INTO space_member (space_id,user_id,status,role) VALUES(2,1,'ACTIVE','USER');
|
||||
INSERT INTO space_member (space_id,user_id,status,role) VALUES(2,3,'ACTIVE','USER');
|
||||
|
||||
-- Travel: Bob leads, with Steven and Sam.
|
||||
INSERT INTO space_member (space_id,user_id,status,role) VALUES(3,3,'ACTIVE','ADMIN');
|
||||
INSERT INTO space_member (space_id,user_id,status,role) VALUES(3,1,'ACTIVE','USER');
|
||||
INSERT INTO space_member (space_id,user_id,status,role) VALUES(3,4,'ACTIVE','USER');
|
||||
|
||||
-- Reading: Sam leads, with Steven and Johnny.
|
||||
INSERT INTO space_member (space_id,user_id,status,role) VALUES(4,4,'ACTIVE','ADMIN');
|
||||
INSERT INTO space_member (space_id,user_id,status,role) VALUES(4,1,'ACTIVE','USER');
|
||||
INSERT INTO space_member (space_id,user_id,status,role) VALUES(4,2,'ACTIVE','USER');
|
||||
|
||||
-- Recipes and movies stay unassigned; a memo does not need a Space.
|
||||
|
||||
-- ============================================================================
|
||||
-- Pinned memos (Welcome leads — newest created_ts in the pinned section)
|
||||
-- ============================================================================
|
||||
|
||||
-- 1. Welcome (steven, pinned) — orientation + SSO call-to-action + protected teaser
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,pinned,payload) VALUES(1,'welcome0000001',1,strftime('%s','now','-2 days'),strftime('%s','now','-2 days'),replace('# Welcome to Memos 👋\n\nHi, I''m Steven — I build Memos. You''ve found the public demo: a real, living instance where you can poke at every feature before self-hosting your own.\n\nMemos is an open-source, self-hosted home for short-form thoughts. Capture quickly, organize lightly, own everything.\n\n> Most apps treat notes like documents. Memos treats them like thoughts — small, timestamped, searchable.\n\n## Make yourself at home\n\n- [ ] Scroll this Explore feed — everything here was written with Memos\n- [ ] React to a memo you like (🎉 works great on this one)\n- [ ] **Sign in** (top right) — SSO takes ten seconds and gives you your own space\n- [ ] Write your first memo. One sentence is plenty. That''s the point.\n- [ ] Like it? Star [the repo](https://github.com/usememos/memos) ⭐\n\n🔒 *Psst — a few memos on this instance are hidden until you sign in. Members only.*\n\n## What Memos can do\n\n| Feature | Where to see it |\n|---------|-----------------|\n| **Markdown** | Everywhere — tables, `code`, task lists, quotes |\n| **Tags** | `#dev/git` — nested tags grow a tree in the sidebar |\n| **Comments & reactions** | Right under this memo 👇 |\n| **Memo references** | Johnny''s weekly review links back to his week |\n| **Attachments** | Bob''s golden-hour art from the coastal trail |\n| **Locations** | Look for the 📍 pins |\n| **Visibility** | Public, protected, or private — chosen per memo |\n\n## Take it home\n\n```bash\ndocker run -d -p 5230:5230 -v ~/.memos:/var/opt/memos neosmemo/memos:stable\n```\n\nYour data lives in one SQLite file, on your machine. #welcome #getting-started','\n',char(10)),'PUBLIC',1,'{"tags":["welcome","getting-started"],"property":{"hasLink":true,"hasCode":true,"hasTaskList":true,"hasIncompleteTasks":true}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,pinned,payload,space_id) VALUES(1,'welcome0000001',1,strftime('%s','now','-2 days'),strftime('%s','now','-2 days'),replace('# Welcome to Memos 👋\n\nHi, I''m Steven — I build Memos. Welcome to our shared home for product updates, projects, trips, and reading notes.\n\nMemos is an open-source, self-hosted home for short-form thoughts. Capture quickly, organize lightly, own everything.\n\n> Most apps treat notes like documents. Memos treats them like thoughts — small, timestamped, searchable.\n\n## Make yourself at home\n\n- [ ] Scroll this Explore feed — everything here was written with Memos\n- [ ] React to a memo you like (🎉 works great on this one)\n- [ ] **Sign in** to write your own memos. Create a Space for a project or a group.\n- [ ] Write your first memo. One sentence is plenty. That''s the point.\n- [ ] Like it? Star [the repo](https://github.com/usememos/memos) ⭐\n\n🔒 *Psst — a few memos on this instance are hidden until you sign in. Anyone signed in can read them.*\n\n## What Memos can do\n\n| Feature | Where to see it |\n|---------|-----------------|\n| **Markdown** | Everywhere — tables, `code`, task lists, quotes |\n| **Tags** | `#dev/git` — nested tags grow a tree in the sidebar |\n| **Spaces** | Group related memos and invite people to contribute |\n| **Space icons** | Choose an emoji or a symbol for each Space |\n| **Comments & reactions** | Right under this memo 👇 |\n| **Memo references** | Johnny''s weekly review links back to his week |\n| **Attachments** | Bob''s golden-hour art from the coastal trail |\n| **Locations** | Look for the 📍 pins |\n| **Visibility** | Public, protected, private, or Space members — chosen per memo |\n\n## Take it home\n\n```bash\ndocker run -d -p 5230:5230 -v ~/.memos:/var/opt/memos neosmemo/memos:stable\n```\n\nYour data lives in one SQLite file, on your machine. #welcome #getting-started','\n',char(10)),'PUBLIC',1,'{"tags":["welcome","getting-started"],"property":{"hasLink":true,"hasCode":true,"hasTaskList":true,"hasIncompleteTasks":true}}',1);
|
||||
|
||||
-- 2. Sponsors (steven, pinned) — sits below Welcome (older created_ts)
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,pinned,payload) VALUES(2,'sponsors000001',1,strftime('%s','now','-6 days'),strftime('%s','now','-6 days'),replace('Memos is free and open source, kept independent by its sponsors — no ads, no telemetry, no paywalls. 🙏 If you build with Memos, please consider supporting them in return.\n\n## ⭐ Sponsors\n\n<a href="https://coderabbit.link/usememos" target="_blank" rel="noopener"><img src="https://victorious-bubble-f69a016683.media.strapiapp.com/Orange_Typemark_43bf516c9d.svg" alt="CodeRabbit" height="44" /></a>\n\nCut code review time & bugs in half, instantly. [coderabbit.link/usememos →](https://coderabbit.link/usememos)\n\n---\n\n**SSD Nodes** — Affordable VPS hosting for self-hosters. [ssdnodes.com →](https://ssdnodes.com/?utm_source=memos&utm_medium=sponsor)\n\n---\n\n**TestMu AI** — The world’s first full-stack Agentic AI Quality Engineering platform. [testmuai.com →](https://www.testmuai.com/?utm_medium=sponsor&utm_source=memos)\n\n---\n\nWant to see your company here? Reach out via [GitHub Sponsors](https://github.com/sponsors/usememos).\n\n#sponsors','\n',char(10)),'PUBLIC',1,'{"tags":["sponsors"],"property":{"hasLink":true}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,pinned,payload,space_id) VALUES(2,'sponsors000001',1,strftime('%s','now','-6 days'),strftime('%s','now','-6 days'),replace('Memos is free and open source, kept independent by its sponsors — no ads, no telemetry, no paywalls. 🙏 If you build with Memos, please consider supporting them in return.\n\n## ⭐ Sponsors\n\n<a href="https://coderabbit.link/usememos" target="_blank" rel="noopener"><img src="https://victorious-bubble-f69a016683.media.strapiapp.com/Orange_Typemark_43bf516c9d.svg" alt="CodeRabbit" height="44" /></a>\n\nCut code review time & bugs in half, instantly. [coderabbit.link/usememos →](https://coderabbit.link/usememos)\n\n---\n\n**SSD Nodes** — Affordable VPS hosting for self-hosters. [ssdnodes.com →](https://ssdnodes.com/?utm_source=memos&utm_medium=sponsor)\n\n---\n\n**TestMu AI** — The world’s first full-stack Agentic AI Quality Engineering platform. [testmuai.com →](https://www.testmuai.com/?utm_medium=sponsor&utm_source=memos)\n\n---\n\nWant to see your company here? Reach out via [GitHub Sponsors](https://github.com/sponsors/usememos).\n\n#sponsors','\n',char(10)),'PUBLIC',1,'{"tags":["sponsors"],"property":{"hasLink":true}}',1);
|
||||
|
||||
-- ============================================================================
|
||||
-- Public timeline — mixed lengths, four voices, dense in the last 48 hours
|
||||
|
|
@ -37,52 +72,52 @@ INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,pin
|
|||
-- ============================================================================
|
||||
|
||||
-- 10. Steven: official Chrome extension launch (featured first in Explore)
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(10,'webclipper0001',1,strftime('%s','now','-30 minutes'),strftime('%s','now','-30 minutes'),replace('# ✂️ Memos Web Clipper for Chrome\n\nThe ***official*** Memos Web Clipper turns the page you''re reading into a source-linked memo in under five seconds.\n\n[Add Memos Web Clipper to Chrome →](https://chromewebstore.google.com/detail/memos-web-clipper/nebaoebnljalfegiidibihhkebeiklbl)\n\n| Capture from Chrome | What lands in Memos |\n|---------------------|---------------------|\n| Current page | Title, summary, and source link |\n| Text selection | Quoted excerpt with its source |\n| Selected image | A real attachment on your instance |\n\nEdit the generated memo, choose its visibility, or customize the template and default tags before saving.\n\n### Private by design\n\nThe clipper sends captured content only to the self-hosted Memos instance you connect — and only when you save. No analytics, third-party servers, or tracking. #memos/extensions','\n',char(10)),'PUBLIC','{"tags":["memos","memos/extensions"],"property":{"hasLink":true}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(10,'webclipper0001',1,strftime('%s','now','-30 minutes'),strftime('%s','now','-30 minutes'),replace('# ✂️ Memos Web Clipper for Chrome\n\nThe ***official*** Memos Web Clipper turns the page you''re reading into a source-linked memo in under five seconds.\n\n[Add Memos Web Clipper to Chrome →](https://chromewebstore.google.com/detail/memos-web-clipper/nebaoebnljalfegiidibihhkebeiklbl)\n\n| Capture from Chrome | What lands in Memos |\n|---------------------|---------------------|\n| Current page | Title, summary, and source link |\n| Text selection | Quoted excerpt with its source |\n| Selected image | A real attachment on your instance |\n\nEdit the generated memo, choose its visibility, or customize the template and default tags before saving.\n\n### Private by design\n\nThe clipper sends captured content only to the self-hosted Memos instance you connect — and only when you save. No analytics, third-party servers, or tracking. #memos/extensions','\n',char(10)),'PUBLIC','{"tags":["memos","memos/extensions"],"property":{"hasLink":true}}',1);
|
||||
|
||||
-- 3. Bob: photo memo with an image attachment + location
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(3,'goldenhour0001',3,strftime('%s','now','-3 hours'),strftime('%s','now','-3 hours'),'Golden hour on the coastal trail tonight. The camera couldn''t hold the colors, so here''s my minimal-art rendition instead 🎨 #travel/hikes','PUBLIC','{"tags":["travel","travel/hikes"],"property":{"hasLink":false},"location":{"placeholder":"Point Reyes, California, United States","latitude":37.9954,"longitude":-123.0204}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(3,'goldenhour0001',3,strftime('%s','now','-3 hours'),strftime('%s','now','-3 hours'),'Golden hour on the coastal trail tonight. The camera couldn''t hold the colors, so here''s my minimal-art rendition instead 🎨 #travel/hikes','PUBLIC','{"tags":["travel","travel/hikes"],"property":{"hasLink":false},"location":{"placeholder":"Point Reyes, California, United States","latitude":37.9954,"longitude":-123.0204}}',3);
|
||||
|
||||
-- 27. Steven: build-in-public changelog note (real v0.30 highlights)
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(27,'v030changelog1',1,strftime('%s','now','-6 hours'),strftime('%s','now','-6 hours'),replace('Rolled v0.30 out to this demo instance 🚀 The highlights:\n\n- Editor rebuilt on CodeMirror — your markdown stays plain text, but formatting renders as you type\n- Scroll position is restored when you navigate back to a long feed\n- Tooltip polish and a pile of small fixes\n\nFull notes: [github.com/usememos/memos/releases](https://github.com/usememos/memos/releases)\n\nDogfooding note: this memo was of course drafted in the new editor. #memos/changelog','\n',char(10)),'PUBLIC','{"tags":["memos","memos/changelog"],"property":{"hasLink":true}}');
|
||||
-- 27. Steven: introducing Spaces and custom icons
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(27,'v030changelog1',1,strftime('%s','now','-6 hours'),strftime('%s','now','-6 hours'),replace('## Spaces for the things we share\n\nWe''ve organized our memos into four Spaces:\n\n- **Updates** — announcements and tips\n- **Dev** — projects and technical notes\n- **Travel** — trips and photography\n- **Reading** — books and quotes\n\nEach Space has its own members and an emoji or symbol to help you recognize it. Tags still work inside Spaces, and memos can stay unassigned.\n\nA public memo remains public when placed in a Space. Choose Space visibility to share it only with that Space''s members.\n\nCreate your own Space, or accept an invitation to join an existing one.\n\nMore updates: [release notes](https://github.com/usememos/memos/releases). #memos/changelog','\n',char(10)),'PUBLIC','{"tags":["memos","memos/changelog"],"property":{"hasLink":true}}',1);
|
||||
|
||||
-- 4. Sam: one-line book quote
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(4,'samquote000001',4,strftime('%s','now','-7 hours'),strftime('%s','now','-7 hours'),replace('> "We tell ourselves stories in order to live." — Joan Didion\n\nBeen thinking about this all morning. #books','\n',char(10)),'PUBLIC','{"tags":["books"],"property":{"hasLink":false}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(4,'samquote000001',4,strftime('%s','now','-7 hours'),strftime('%s','now','-7 hours'),replace('> "We tell ourselves stories in order to live." — Joan Didion\n\nBeen thinking about this all morning. #books','\n',char(10)),'PUBLIC','{"tags":["books"],"property":{"hasLink":false}}',4);
|
||||
|
||||
-- 5. Johnny: weekly review — REFERENCES his memos from the past week (see memo_relation)
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(5,'johnnyweekly001',2,strftime('%s','now','-22 hours'),strftime('%s','now','-22 hours'),replace('## 🗓️ Week 28 review\n\n**Shipped:** v0.2 of the side project finally went out.\n\n**Learned:** the single-file branch diff trick — small thing, saves me daily.\n\n**Reading:** still working through *Deep Work*. The no-Slack-before-11am rule survived its second week.\n\n**Next week:** actually write the digest CLI I keep talking about, or stop talking about it.\n\nLinked the memos below so future me can retrace the week. #weekly','\n',char(10)),'PUBLIC','{"tags":["weekly"],"property":{"hasLink":false}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(5,'johnnyweekly001',2,strftime('%s','now','-22 hours'),strftime('%s','now','-22 hours'),replace('## 🗓️ Week 28 review\n\n**Shipped:** v0.2 of the side project finally went out.\n\n**Learned:** the single-file branch diff trick — small thing, saves me daily.\n\n**Reading:** still working through *Deep Work*. The no-Slack-before-11am rule survived its second week.\n\n**Next week:** actually write the digest CLI I keep talking about, or stop talking about it.\n\nLinked the memos below so future me can retrace the week. #weekly','\n',char(10)),'PUBLIC','{"tags":["weekly"],"property":{"hasLink":false}}',2);
|
||||
|
||||
-- 6. Steven: short product tip
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(6,'tagtipmemo0001',1,strftime('%s','now','-26 hours'),strftime('%s','now','-26 hours'),'Tip: tags are just typed inline — `#like/this` — and nested ones grow a tree in the sidebar. No setup, no tag manager. #getting-started','PUBLIC','{"tags":["getting-started"],"property":{"hasLink":false}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(6,'tagtipmemo0001',1,strftime('%s','now','-26 hours'),strftime('%s','now','-26 hours'),'Tip: tags are just typed inline — `#like/this` — and nested ones grow a tree in the sidebar. No setup, no tag manager. #getting-started','PUBLIC','{"tags":["getting-started"],"property":{"hasLink":false}}',1);
|
||||
|
||||
-- 7. Johnny: shipped-it note
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(7,'johnnyshipped01',2,strftime('%s','now','-2 days','+3 hours'),strftime('%s','now','-2 days','+3 hours'),'Shipped v0.2 of my side project tonight 🚀 Rewrote the sync engine and cut startup time in half. Scrolling back through my own #dev/til memos made the changelog write itself.','PUBLIC','{"tags":["dev","dev/til"],"property":{"hasLink":false}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(7,'johnnyshipped01',2,strftime('%s','now','-2 days','+3 hours'),strftime('%s','now','-2 days','+3 hours'),'Shipped v0.2 of my side project tonight 🚀 Rewrote the sync engine and cut startup time in half. Scrolling back through my own #dev/til memos made the changelog write itself.','PUBLIC','{"tags":["dev","dev/til"],"property":{"hasLink":false}}',2);
|
||||
|
||||
-- 8. Johnny: short TIL with a code block (referenced by the weekly review)
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(8,'johnnytilgit001',2,strftime('%s','now','-3 days'),strftime('%s','now','-3 days'),replace('TIL you can diff a single file between branches — no checkout, no stash dance:\n\n```bash\ngit diff main..feature -- path/to/file.go\n```\n\n#dev/til #dev/git','\n',char(10)),'PUBLIC','{"tags":["dev","dev/til","dev/git"],"property":{"hasLink":false,"hasCode":true}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(8,'johnnytilgit001',2,strftime('%s','now','-3 days'),strftime('%s','now','-3 days'),replace('TIL you can diff a single file between branches — no checkout, no stash dance:\n\n```bash\ngit diff main..feature -- path/to/file.go\n```\n\n#dev/til #dev/git','\n',char(10)),'PUBLIC','{"tags":["dev","dev/til","dev/git"],"property":{"hasLink":false,"hasCode":true}}',2);
|
||||
|
||||
-- 29. Johnny: link/bookmark capture — a core Memos use case
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(29,'johnnybookmark1',2,strftime('%s','now','-32 hours'),strftime('%s','now','-32 hours'),'Weekend read, bookmarking before I lose it: [SQLite: 35% faster than the filesystem](https://sqlite.org/fasterthanfs.html) — makes me feel better about my entire digital life being one .db file 😄 #dev/reading','PUBLIC','{"tags":["dev","dev/reading"],"property":{"hasLink":true}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(29,'johnnybookmark1',2,strftime('%s','now','-32 hours'),strftime('%s','now','-32 hours'),'Weekend read, bookmarking before I lose it: [SQLite: 35% faster than the filesystem](https://sqlite.org/fasterthanfs.html) — makes me feel better about my entire digital life being one .db file 😄 #dev/reading','PUBLIC','{"tags":["dev","dev/reading"],"property":{"hasLink":true}}',2);
|
||||
|
||||
-- 9. Sam: recipe with a task list
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(9,'samramen000001',4,strftime('%s','now','-4 days'),strftime('%s','now','-4 days'),replace('## 🍜 Midnight miso ramen (15 minutes)\n\nFor nights when the book was too good to stop reading.\n\n- [x] Dashi or veg stock, 500ml\n- [x] Miso paste, 2 big spoons\n- [x] Noodles, one nest\n- [x] Soft egg — 6½ minutes, exactly\n- [ ] Scallions (always forget the scallions)\n\nSteep the miso, don''t boil it. That''s the whole secret. #cooking','\n',char(10)),'PUBLIC','{"tags":["cooking"],"property":{"hasLink":false,"hasTaskList":true,"hasIncompleteTasks":true}}');
|
||||
|
||||
-- 30. Steven: compact Markdown rendering check framed as maintainer dogfooding
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(30,'rendertest0001',1,strftime('%s','now','-10 days'),strftime('%s','now','-10 days'),replace('## 🧪 Markdown rendering check #memos/dev\n\nA quick smoke test I open after releases:\n\n**Bold**, *italic*, ~~strikethrough~~, `inline code`, and a [docs link](https://www.usememos.com/docs).\n\n> Simple notes should render beautifully.\n\n```go\nfmt.Println("syntax highlighting ✓")\n```\n\n| Check | Status |\n|-------|--------|\n| Text styles | ✅ |\n| Code blocks | ✅ |\n| Tables | ✅ |\n\n- [x] Check desktop\n- [x] Check mobile\n- [ ] Ship the next release','\n',char(10)),'PUBLIC','{"tags":["memos","memos/dev"],"property":{"hasLink":true,"hasCode":true,"hasTaskList":true,"hasIncompleteTasks":true}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(30,'rendertest0001',1,strftime('%s','now','-10 days'),strftime('%s','now','-10 days'),replace('## 🧪 Markdown rendering check #memos/dev\n\nA quick smoke test I open after releases:\n\n**Bold**, *italic*, ~~strikethrough~~, `inline code`, and a [docs link](https://www.usememos.com/docs).\n\n> Simple notes should render beautifully.\n\n```go\nfmt.Println("syntax highlighting ✓")\n```\n\n| Check | Status |\n|-------|--------|\n| Text styles | ✅ |\n| Code blocks | ✅ |\n| Tables | ✅ |\n\n- [x] Check desktop\n- [x] Check mobile\n- [ ] Ship the next release','\n',char(10)),'PUBLIC','{"tags":["memos","memos/dev"],"property":{"hasLink":true,"hasCode":true,"hasTaskList":true,"hasIncompleteTasks":true}}',1);
|
||||
|
||||
-- 11. Sam: movie watchlist with a table
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(11,'sammovies00001',4,strftime('%s','now','-9 days'),strftime('%s','now','-9 days'),replace('## 🎬 Movie catch-up #movies\n\nWorking through films I''ve been meaning to watch for, uh, years.\n\n| Movie | Status | Rating |\n|-------|--------|--------|\n| The Grand Budapest Hotel | ✅ Watched | ⭐⭐⭐⭐⭐ |\n| Spirited Away | ✅ Watched | ⭐⭐⭐⭐⭐ |\n| Everything Everywhere All at Once | ✅ Watched | ⭐⭐⭐⭐⭐ |\n| Dune: Part Two | 📅 This weekend | — |\n| Oppenheimer | 📋 Queued | — |\n\n**Spirited Away**: cried twice, no regrets. **Everything Everywhere**: went in cold, did not expect the bagel.\n\nNext month: full Miyazaki marathon 🎨 Taking suggestions for where to start.','\n',char(10)),'PUBLIC','{"tags":["movies"],"property":{"hasLink":false}}');
|
||||
|
||||
-- 12. Bob: short travel journal + location
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(12,'bobnighttrain1',3,strftime('%s','now','-12 days'),strftime('%s','now','-12 days'),'Overnight train from Oslo to Bergen. Woke at 5am to fjords in fog and couldn''t go back to sleep. Some views are worth the bad coffee ☕ #travel','PUBLIC','{"tags":["travel"],"property":{"hasLink":false},"location":{"placeholder":"Bergen, Vestland, Norway","latitude":60.3913,"longitude":5.3221}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(12,'bobnighttrain1',3,strftime('%s','now','-12 days'),strftime('%s','now','-12 days'),'Overnight train from Oslo to Bergen. Woke at 5am to fjords in fog and couldn''t go back to sleep. Some views are worth the bad coffee ☕ #travel','PUBLIC','{"tags":["travel"],"property":{"hasLink":false},"location":{"placeholder":"Bergen, Vestland, Norway","latitude":60.3913,"longitude":5.3221}}',3);
|
||||
|
||||
-- 13. Bob: travel bucket list + location
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(13,'bobbucketlist1',3,strftime('%s','now','-13 days'),strftime('%s','now','-13 days'),replace('## 🌍 My travel bucket list #travel/bucketlist\n\n> Writing this from a tiny café near the Seine. Will keep updating after each trip. 📍\n\n### Been\n- [x] Paris, France — the croissants ruined every croissant after\n- [x] Shanghai, China — modern skyline next to thousand-year-old temples, somehow it works\n- [x] Grand Canyon, USA — photos do not do it justice, and I say that professionally\n- [x] Barcelona, Spain — Gaudí''s buildings look grown, not built\n\n### Next\n- [ ] Northern Lights in Iceland — booking for winter, *finally*\n- [ ] Safari in Tanzania\n- [ ] Great Barrier Reef, before it gets worse\n- [ ] New Zealand road trip — south island, two weeks minimum','\n',char(10)),'PUBLIC','{"tags":["travel","travel/bucketlist"],"property":{"hasTaskList":true,"hasIncompleteTasks":true},"location":{"placeholder":"Paris, Île-de-France, France","latitude":48.8566,"longitude":2.3522}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(13,'bobbucketlist1',3,strftime('%s','now','-13 days'),strftime('%s','now','-13 days'),replace('## 🌍 My travel bucket list #travel/bucketlist\n\n> Writing this from a tiny café near the Seine. Will keep updating after each trip. 📍\n\n### Been\n- [x] Paris, France — the croissants ruined every croissant after\n- [x] Shanghai, China — modern skyline next to thousand-year-old temples, somehow it works\n- [x] Grand Canyon, USA — photos do not do it justice, and I say that professionally\n- [x] Barcelona, Spain — Gaudí''s buildings look grown, not built\n\n### Next\n- [ ] Northern Lights in Iceland — booking for winter, *finally*\n- [ ] Safari in Tanzania\n- [ ] Great Barrier Reef, before it gets worse\n- [ ] New Zealand road trip — south island, two weeks minimum','\n',char(10)),'PUBLIC','{"tags":["travel","travel/bucketlist"],"property":{"hasTaskList":true,"hasIncompleteTasks":true},"location":{"placeholder":"Paris, Île-de-France, France","latitude":48.8566,"longitude":2.3522}}',3);
|
||||
|
||||
-- 14. Johnny: git cheat sheet — long-form anchor with code blocks
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(14,'johnnygitcheat1',2,strftime('%s','now','-17 days'),strftime('%s','now','-17 days'),replace('## ⚡ Git commands I keep forgetting #dev/git #dev/cheatsheet\n\nWriting these down so I stop googling the same things every week.\n\n```bash\n# Show the last commit in detail\ngit show --stat HEAD\n\n# Undo the last commit, keep changes staged\ngit reset --soft HEAD~1\n\n# Stash including untracked files\ngit stash push -u -m "wip: before refactor"\n\n# Find which commit introduced a string\ngit log -S "function_name" --source --all\n```\n\nThe `-S` one is gold for archaeology — way better than scrolling blame.','\n',char(10)),'PUBLIC','{"tags":["dev","dev/git","dev/cheatsheet"],"property":{"hasLink":false,"hasCode":true}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(14,'johnnygitcheat1',2,strftime('%s','now','-17 days'),strftime('%s','now','-17 days'),replace('## ⚡ Git commands I keep forgetting #dev/git #dev/cheatsheet\n\nWriting these down so I stop googling the same things every week.\n\n```bash\n# Show the last commit in detail\ngit show --stat HEAD\n\n# Undo the last commit, keep changes staged\ngit reset --soft HEAD~1\n\n# Stash including untracked files\ngit stash push -u -m "wip: before refactor"\n\n# Find which commit introduced a string\ngit log -S "function_name" --source --all\n```\n\nThe `-S` one is gold for archaeology — way better than scrolling blame.','\n',char(10)),'PUBLIC','{"tags":["dev","dev/git","dev/cheatsheet"],"property":{"hasLink":false,"hasCode":true}}',2);
|
||||
|
||||
-- 15. Johnny: reading note + café location (oldest memo — the back of the feed)
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(15,'johnnyreading01',2,strftime('%s','now','-22 days'),strftime('%s','now','-22 days'),replace('## 📖 Reading: Deep Work #books\n\nStarted Cal Newport''s *Deep Work* this week. This passage stopped me:\n\n> "Human beings, it seems, are at their best when immersed deeply in something challenging."\n\nThat''s the whole pitch in one sentence. The rest of the book is evidence.\n\nExperiment for the next two weeks: no Slack or email before 11am. See what shifts when the morning is mine.','\n',char(10)),'PUBLIC','{"tags":["books"],"property":{"hasLink":false},"location":{"placeholder":"Sightglass Coffee, San Francisco, California, United States","latitude":37.7726,"longitude":-122.4099}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(15,'johnnyreading01',2,strftime('%s','now','-22 days'),strftime('%s','now','-22 days'),replace('## 📖 Reading: Deep Work #books\n\nStarted Cal Newport''s *Deep Work* this week. This passage stopped me:\n\n> "Human beings, it seems, are at their best when immersed deeply in something challenging."\n\nThat''s the whole pitch in one sentence. The rest of the book is evidence.\n\nExperiment for the next two weeks: no Slack or email before 11am. See what shifts when the morning is mine.','\n',char(10)),'PUBLIC','{"tags":["books"],"property":{"hasLink":false},"location":{"placeholder":"Sightglass Coffee, San Francisco, California, United States","latitude":37.7726,"longitude":-122.4099}}',4);
|
||||
|
||||
-- ============================================================================
|
||||
-- Protected memos — invisible when logged out; Explore gains these after SSO
|
||||
|
|
@ -90,43 +125,43 @@ INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,pay
|
|||
-- ============================================================================
|
||||
|
||||
-- 16. Steven: self-referential visibility explainer
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(16,'protectedintro',1,strftime('%s','now','-20 hours'),strftime('%s','now','-20 hours'),replace('🔓 **If you can read this, you''re signed in.**\n\nThis memo''s visibility is **Protected** — every member of this instance can see it, but the logged-out public can''t. There''s a third level, **Private**, that only the author ever sees.\n\nEvery memo picks its own level: public for the world, protected for your team or community, private for your 3am thoughts. #getting-started','\n',char(10)),'PROTECTED','{"tags":["getting-started"],"property":{"hasLink":false}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(16,'protectedintro',1,strftime('%s','now','-20 hours'),strftime('%s','now','-20 hours'),replace('🔓 **If you can read this, you''re signed in.**\n\nThis memo uses **Protected** visibility: anyone signed in to this instance can read it.\n\nEach memo has its own audience:\n\n- **Public** — anyone, including visitors who aren''t signed in.\n- **Protected** — anyone signed in to this instance.\n- **Private** — only its author.\n- **Space** — active members of the Space where the memo is placed.\n\nPlacing a memo in a Space doesn''t automatically make it members-only. Choose **Space** visibility when that''s the audience you want. #getting-started','\n',char(10)),'PROTECTED','{"tags":["getting-started"],"property":{"hasLink":false}}',1);
|
||||
|
||||
-- 17. Johnny: half-formed idea — protected memos are naturally rougher
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(17,'johnnydigestcli',2,strftime('%s','now','-9 hours'),strftime('%s','now','-9 hours'),'Half-formed idea: a tiny CLI that collects my #dev/til memos into a weekly digest. Memos has a full API with access tokens, so this is one evening of work. Parking it here so future me has no excuses.','PROTECTED','{"tags":["dev","dev/til"],"property":{"hasLink":false}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(17,'johnnydigestcli',2,strftime('%s','now','-9 hours'),strftime('%s','now','-9 hours'),'Half-formed idea: a tiny CLI that collects my #dev/til memos into a weekly digest. Memos has a full API with access tokens, so this is one evening of work. Parking it here so future me has no excuses.','PROTECTED','{"tags":["dev","dev/til"],"property":{"hasLink":false}}',2);
|
||||
|
||||
-- 18. Bob: members-only packing list
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(18,'bobpacklist001',3,strftime('%s','now','-5 days'),strftime('%s','now','-5 days'),replace('Coast trip packing list — members-only edition, because nobody needs to know how much coffee gear I carry:\n\n- [x] Camera + the one lens I''ll actually use\n- [x] AeroPress, hand grinder, scale ☕\n- [x] Rain shell\n- [ ] The second lens I won''t use but will pack anyway\n\n#travel/hikes','\n',char(10)),'PROTECTED','{"tags":["travel","travel/hikes"],"property":{"hasLink":false,"hasTaskList":true,"hasIncompleteTasks":true}}');
|
||||
-- 18. Bob: packing list for signed-in readers
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(18,'bobpacklist001',3,strftime('%s','now','-5 days'),strftime('%s','now','-5 days'),replace('Coast trip packing list — sharing this with everyone signed in, because you deserve to know how much coffee gear I carry:\n\n- [x] Camera + the one lens I''ll actually use\n- [x] AeroPress, hand grinder, scale ☕\n- [x] Rain shell\n- [ ] The second lens I won''t use but will pack anyway\n\n#travel/hikes','\n',char(10)),'PROTECTED','{"tags":["travel","travel/hikes"],"property":{"hasLink":false,"hasTaskList":true,"hasIncompleteTasks":true}}',3);
|
||||
|
||||
-- 19. Sam: confession
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(19,'sambookpile001',4,strftime('%s','now','-30 hours'),strftime('%s','now','-30 hours'),'Note to self: stop buying books faster than I read them. Current pile: 9. Keeping this memo protected so only fellow members witness my shame 📚 #books','PROTECTED','{"tags":["books"],"property":{"hasLink":false}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(19,'sambookpile001',4,strftime('%s','now','-30 hours'),strftime('%s','now','-30 hours'),'Note to self: stop buying books faster than I read them. Current pile: 9. Keeping this memo protected so only people signed in witness my shame 📚 #books','PROTECTED','{"tags":["books"],"property":{"hasLink":false}}',4);
|
||||
|
||||
-- ============================================================================
|
||||
-- Comments (memos linked via memo_relation COMMENT)
|
||||
-- ============================================================================
|
||||
|
||||
-- 20. Sam on Welcome
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(20,'cmtwelcome0001',4,strftime('%s','now','-21 hours'),strftime('%s','now','-21 hours'),'Signed in with GitHub and posted my first memo inside a minute. Lowest-friction note app I''ve used 👏','PUBLIC','{"property":{"hasLink":false}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(20,'cmtwelcome0001',4,strftime('%s','now','-21 hours'),strftime('%s','now','-21 hours'),'Signed in with GitHub and posted my first memo inside a minute. Lowest-friction note app I''ve used 👏','PUBLIC','{"property":{"hasLink":false}}',1);
|
||||
|
||||
-- 21–22. Thread on Johnny's git cheat sheet
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(21,'cmtgitcheat001',3,strftime('%s','now','-17 days','+5 hours'),strftime('%s','now','-17 days','+5 hours'),'Saving the `git log -S` one. Code archaeology mode unlocked 🔥','PUBLIC','{"property":{"hasLink":false}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(22,'cmtgitcheat002',2,strftime('%s','now','-17 days','+6 hours'),strftime('%s','now','-17 days','+6 hours'),'Also try `git log -p -- path/to/file` when you want the actual content changes for one file. Same archaeology vibe.','PUBLIC','{"property":{"hasLink":false}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(21,'cmtgitcheat001',3,strftime('%s','now','-17 days','+5 hours'),strftime('%s','now','-17 days','+5 hours'),'Saving the `git log -S` one. Code archaeology mode unlocked 🔥','PUBLIC','{"property":{"hasLink":false}}',2);
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(22,'cmtgitcheat002',2,strftime('%s','now','-17 days','+6 hours'),strftime('%s','now','-17 days','+6 hours'),'Also try `git log -p -- path/to/file` when you want the actual content changes for one file. Same archaeology vibe.','PUBLIC','{"property":{"hasLink":false}}',2);
|
||||
|
||||
-- 23–24. Thread on Bob's golden-hour memo
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(23,'cmtgolden00001',4,strftime('%s','now','-2 hours'),strftime('%s','now','-2 hours'),'Okay, the gradient sky is gorgeous. Which trail is this?','PUBLIC','{"property":{"hasLink":false}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(24,'cmtgolden00002',3,strftime('%s','now','-1 hours'),strftime('%s','now','-1 hours'),'Point Reyes, the stretch north of the lighthouse — tap the 📍 on the memo. Golden hour there never misses.','PUBLIC','{"property":{"hasLink":false}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(23,'cmtgolden00001',4,strftime('%s','now','-2 hours'),strftime('%s','now','-2 hours'),'Okay, the gradient sky is gorgeous. Which trail is this?','PUBLIC','{"property":{"hasLink":false}}',3);
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(24,'cmtgolden00002',3,strftime('%s','now','-1 hours'),strftime('%s','now','-1 hours'),'Point Reyes, the stretch north of the lighthouse — tap the 📍 on the memo. Golden hour there never misses.','PUBLIC','{"property":{"hasLink":false}}',3);
|
||||
|
||||
-- 25. Johnny on Sam's movie list
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(25,'cmtmovies00001',2,strftime('%s','now','-8 days'),strftime('%s','now','-8 days'),'Start the Miyazaki marathon with *Porco Rosso*. Trust me.','PUBLIC','{"property":{"hasLink":false}}');
|
||||
|
||||
-- 28. Johnny on Steven's changelog note
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(28,'cmtchangelog01',2,strftime('%s','now','-4 hours'),strftime('%s','now','-4 hours'),'Scroll restoration 🙏 Losing my place in a long feed was my one real gripe. The new editor feels noticeably snappier too.','PUBLIC','{"property":{"hasLink":false}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(28,'cmtchangelog01',2,strftime('%s','now','-4 hours'),strftime('%s','now','-4 hours'),'Gave Dev a wrench icon. Much easier to spot when switching between coding notes and Reading 🔧','PUBLIC','{"property":{"hasLink":false}}',1);
|
||||
|
||||
-- 31. Johnny on the rendering test memo (includes an @mention)
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(31,'cmtrendertest1',2,strftime('%s','now','-10 days','+4 hours'),strftime('%s','now','-10 days','+4 hours'),'The fact that the public demo doubles as your CI is very on brand, @steven 😄','PUBLIC','{"property":{"hasLink":false}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(31,'cmtrendertest1',2,strftime('%s','now','-10 days','+4 hours'),strftime('%s','now','-10 days','+4 hours'),'Keeping a Markdown checklist right alongside the release notes makes sense, @steven 😄','PUBLIC','{"property":{"hasLink":false}}',1);
|
||||
|
||||
-- 26. Johnny on the protected explainer (protected too — consistent visibility)
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload) VALUES(26,'cmtprotected01',2,strftime('%s','now','-18 hours'),strftime('%s','now','-18 hours'),'Can confirm: this memo did not exist for me until I signed in. Neat trick 👀','PROTECTED','{"property":{"hasLink":false}}');
|
||||
INSERT INTO memo (id,uid,creator_id,created_ts,updated_ts,content,visibility,payload,space_id) VALUES(26,'cmtprotected01',2,strftime('%s','now','-18 hours'),strftime('%s','now','-18 hours'),'Can confirm: this memo did not exist for me until I signed in. Neat trick 👀','PROTECTED','{"property":{"hasLink":false}}',1);
|
||||
|
||||
-- ============================================================================
|
||||
-- Relations
|
||||
|
|
@ -140,7 +175,7 @@ INSERT INTO memo_relation VALUES(23,3,'COMMENT'); -- Sam → golden hour
|
|||
INSERT INTO memo_relation VALUES(24,3,'COMMENT'); -- Bob → golden hour
|
||||
INSERT INTO memo_relation VALUES(25,11,'COMMENT'); -- Johnny → movie list
|
||||
INSERT INTO memo_relation VALUES(26,16,'COMMENT'); -- Johnny → protected explainer
|
||||
INSERT INTO memo_relation VALUES(28,27,'COMMENT'); -- Johnny → v0.30 changelog
|
||||
INSERT INTO memo_relation VALUES(28,27,'COMMENT'); -- Johnny → Spaces announcement
|
||||
INSERT INTO memo_relation VALUES(31,30,'COMMENT'); -- Johnny → rendering test
|
||||
|
||||
-- References: Johnny's weekly review links back to his week
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/usememos/memos/internal/base"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
)
|
||||
|
||||
// ErrLastSpaceAdmin indicates that a membership mutation would leave an active
|
||||
|
|
@ -71,6 +72,7 @@ type Space struct {
|
|||
UID string
|
||||
Title string
|
||||
Description string
|
||||
Payload *storepb.SpacePayload
|
||||
CurrentUserRole SpaceMemberRole
|
||||
MemberCount int32
|
||||
}
|
||||
|
|
@ -92,6 +94,7 @@ type UpdateSpace struct {
|
|||
ID int32
|
||||
Title *string
|
||||
Description *string
|
||||
Payload *storepb.SpacePayload
|
||||
}
|
||||
|
||||
// DeleteSpace identifies a Space to hard-delete.
|
||||
|
|
@ -181,6 +184,9 @@ func (s *Store) CreateSpace(ctx context.Context, create *Space, creatorID int32)
|
|||
if strings.TrimSpace(create.Title) == "" {
|
||||
return nil, errors.New("space title is required")
|
||||
}
|
||||
if err := ValidateSpaceIcon(create.Payload.GetIcon()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return s.driver.CreateSpace(ctx, create, creatorID)
|
||||
}
|
||||
|
||||
|
|
@ -209,7 +215,10 @@ func (s *Store) UpdateSpace(ctx context.Context, update *UpdateSpace, actorUserI
|
|||
if update.Title != nil && strings.TrimSpace(*update.Title) == "" {
|
||||
return nil, errors.New("space title is required")
|
||||
}
|
||||
if update.Title == nil && update.Description == nil {
|
||||
if err := ValidateSpaceIcon(update.Payload.GetIcon()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if update.Title == nil && update.Description == nil && update.Payload == nil {
|
||||
return nil, errors.New("space update requires at least one field")
|
||||
}
|
||||
return s.driver.UpdateSpace(ctx, update, actorUserID)
|
||||
|
|
|
|||
23
store/space_icon.go
Normal file
23
store/space_icon.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package store
|
||||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
)
|
||||
|
||||
// ValidateSpaceIcon validates display metadata without depending on a client's
|
||||
// installed Lucide catalog. A nil icon requests the default Space mark.
|
||||
func ValidateSpaceIcon(icon *storepb.SpacePayload_Icon) error {
|
||||
if icon == nil {
|
||||
return nil
|
||||
}
|
||||
switch value := icon.Value.(type) {
|
||||
case *storepb.SpacePayload_Icon_Emoji:
|
||||
return validateEmojiIcon(value.Emoji)
|
||||
case *storepb.SpacePayload_Icon_Lucide:
|
||||
return validateLucideIcon(value.Lucide)
|
||||
default:
|
||||
return errors.New("space icon must specify emoji or lucide")
|
||||
}
|
||||
}
|
||||
27
store/space_icon_test.go
Normal file
27
store/space_icon_test.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package store
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
)
|
||||
|
||||
func TestValidateSpaceIcon(t *testing.T) {
|
||||
require.NoError(t, ValidateSpaceIcon(nil))
|
||||
require.Error(t, ValidateSpaceIcon(&storepb.SpacePayload_Icon{}))
|
||||
for _, emoji := range []string{"🌱", "👩🏽🌾", "🇸🇬", "❤️", "1️⃣"} {
|
||||
require.NoError(t, ValidateSpaceIcon(&storepb.SpacePayload_Icon{Value: &storepb.SpacePayload_Icon_Emoji{Emoji: emoji}}), emoji)
|
||||
}
|
||||
for _, emoji := range []string{"", "leaf", "🌱🌱", " 🌱", "🏻", "\xff"} {
|
||||
require.Error(t, ValidateSpaceIcon(&storepb.SpacePayload_Icon{Value: &storepb.SpacePayload_Icon_Emoji{Emoji: emoji}}), emoji)
|
||||
}
|
||||
for _, name := range []string{"leaf", "book-open", "house-plus", "circle-1", "future-icon"} {
|
||||
require.NoError(t, ValidateSpaceIcon(&storepb.SpacePayload_Icon{Value: &storepb.SpacePayload_Icon_Lucide{Lucide: name}}), name)
|
||||
}
|
||||
for _, name := range []string{"", "LeafIcon", "book_open", "-leaf", "leaf-", "book--open", "<svg>", "🌱", strings.Repeat("a", 129)} {
|
||||
require.Error(t, ValidateSpaceIcon(&storepb.SpacePayload_Icon{Value: &storepb.SpacePayload_Icon_Lucide{Lucide: name}}), name)
|
||||
}
|
||||
}
|
||||
|
|
@ -62,11 +62,11 @@ func TestFreshInstall(t *testing.T) {
|
|||
// The fresh schema supports memo-local Space placement without adding a
|
||||
// canonical thread shape. COMMENT remains an ordinary relation row.
|
||||
driver := getDriverFromEnv()
|
||||
insertSpace := "INSERT INTO space (id, uid, title, description) VALUES (?, ?, ?, ?)"
|
||||
insertSpace := "INSERT INTO space (id, uid, title, description, payload) VALUES (?, ?, ?, ?, '{}')"
|
||||
insertMemo := "INSERT INTO memo (id, uid, creator_id, content, visibility, payload, space_id) VALUES (?, ?, ?, ?, ?, ?, ?)"
|
||||
insertRelation := "INSERT INTO memo_relation (memo_id, related_memo_id, type) VALUES (?, ?, ?)"
|
||||
if driver == "postgres" {
|
||||
insertSpace = "INSERT INTO space (id, uid, title, description) VALUES ($1, $2, $3, $4)"
|
||||
insertSpace = "INSERT INTO space (id, uid, title, description, payload) VALUES ($1, $2, $3, $4, '{}')"
|
||||
insertMemo = "INSERT INTO memo (id, uid, creator_id, content, visibility, payload, space_id) VALUES ($1, $2, $3, $4, $5, $6, $7)"
|
||||
insertRelation = "INSERT INTO memo_relation (memo_id, related_memo_id, type) VALUES ($1, $2, $3)"
|
||||
}
|
||||
|
|
@ -307,6 +307,8 @@ func TestMigrationSpaceMemberStatusBackfillsActive(t *testing.T) {
|
|||
db := ts.GetDriver().GetDB()
|
||||
_, err = db.ExecContext(ctx, "ALTER TABLE space_member DROP COLUMN status")
|
||||
require.NoError(t, err)
|
||||
_, err = db.ExecContext(ctx, "ALTER TABLE space DROP COLUMN payload")
|
||||
require.NoError(t, err)
|
||||
|
||||
basicSetting, err := ts.GetInstanceBasicSetting(ctx)
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ func TestReactionWritePolicyRejectsInactiveActorAndMemo(t *testing.T) {
|
|||
require.ErrorIs(t, err, store.ErrMemoSpaceNotWritable)
|
||||
}
|
||||
|
||||
func TestDeleteReactionAtomicallyEnforcesCreatorAndParticipation(t *testing.T) {
|
||||
func TestDeleteReactionAtomicallyEnforcesCreatorWithoutParticipation(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ts := NewTestingStore(ctx, t)
|
||||
defer ts.Close()
|
||||
|
|
@ -168,14 +168,8 @@ func TestDeleteReactionAtomicallyEnforcesCreatorAndParticipation(t *testing.T) {
|
|||
err = ts.DeleteReaction(ctx, &store.DeleteReaction{
|
||||
ID: &reaction.ID, MemoID: &memo.ID, ActorUserID: &member.ID, Policy: reactionWritePolicy(member.ID),
|
||||
})
|
||||
require.ErrorIs(t, err, store.ErrMemoSpaceMembershipRequired)
|
||||
requireReactionPresent(ctx, t, ts, reaction.ID)
|
||||
require.NoError(t, err, "creators can withdraw reactions after leaving the Space")
|
||||
|
||||
_, err = createSpaceMemberForTest(ctx, ts, &store.SpaceMember{SpaceID: space.ID, UserID: member.ID, Role: store.SpaceMemberRoleUser}, owner.ID)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, ts.DeleteReaction(ctx, &store.DeleteReaction{
|
||||
ID: &reaction.ID, MemoID: &memo.ID, ActorUserID: &member.ID, Policy: reactionWritePolicy(member.ID),
|
||||
}))
|
||||
requireReactionMissing(ctx, t, ts, reaction.ID)
|
||||
}
|
||||
|
||||
|
|
|
|||
85
store/test/space_payload_test.go
Normal file
85
store/test/space_payload_test.go
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
)
|
||||
|
||||
func TestSpacePayloadRoundTrip(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ts := NewTestingStore(ctx, t)
|
||||
defer ts.Close()
|
||||
owner, err := createTestingHostUser(ctx, ts)
|
||||
require.NoError(t, err)
|
||||
space, err := ts.CreateSpace(ctx, &store.Space{
|
||||
UID: "icon-space", Title: "Garden",
|
||||
Payload: &storepb.SpacePayload{Icon: &storepb.SpacePayload_Icon{
|
||||
Value: &storepb.SpacePayload_Icon_Emoji{Emoji: "👩🏽🌾"},
|
||||
}},
|
||||
}, owner.ID)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "👩🏽🌾", space.Payload.GetIcon().GetEmoji())
|
||||
|
||||
for _, find := range []*store.FindSpace{{ID: &space.ID}, {MemberUserID: &owner.ID}} {
|
||||
spaces, err := ts.ListSpaces(ctx, find)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, spaces, 1)
|
||||
require.Equal(t, "👩🏽🌾", spaces[0].Payload.GetIcon().GetEmoji())
|
||||
}
|
||||
title := "Renamed garden"
|
||||
space, err = ts.UpdateSpace(ctx, &store.UpdateSpace{ID: space.ID, Title: &title}, owner.ID)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "👩🏽🌾", space.Payload.GetIcon().GetEmoji())
|
||||
|
||||
space, err = ts.UpdateSpace(ctx, &store.UpdateSpace{ID: space.ID, Payload: &storepb.SpacePayload{
|
||||
Icon: &storepb.SpacePayload_Icon{Value: &storepb.SpacePayload_Icon_Lucide{Lucide: "leaf"}},
|
||||
}}, owner.ID)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "leaf", space.Payload.GetIcon().GetLucide())
|
||||
require.Equal(t, title, space.Title)
|
||||
var raw string
|
||||
require.NoError(t, ts.GetDriver().GetDB().QueryRowContext(ctx, "SELECT payload FROM space WHERE uid = 'icon-space'").Scan(&raw))
|
||||
require.JSONEq(t, `{"icon":{"lucide":"leaf"}}`, raw)
|
||||
|
||||
space, err = ts.UpdateSpace(ctx, &store.UpdateSpace{ID: space.ID, Payload: &storepb.SpacePayload{}}, owner.ID)
|
||||
require.NoError(t, err)
|
||||
require.Nil(t, space.Payload.GetIcon())
|
||||
require.NoError(t, ts.GetDriver().GetDB().QueryRowContext(ctx, "SELECT payload FROM space WHERE uid = 'icon-space'").Scan(&raw))
|
||||
require.JSONEq(t, `{}`, raw)
|
||||
}
|
||||
|
||||
func TestMigrationSpacePayloadBackfillsDefault(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ts := NewTestingStore(ctx, t)
|
||||
defer ts.Close()
|
||||
owner, err := createTestingHostUser(ctx, ts)
|
||||
require.NoError(t, err)
|
||||
space, err := ts.CreateSpace(ctx, &store.Space{UID: "legacy-space", Title: "Legacy"}, owner.ID)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, space.Payload)
|
||||
require.Nil(t, space.Payload.Icon)
|
||||
_, err = ts.GetDriver().GetDB().ExecContext(ctx, "ALTER TABLE space DROP COLUMN payload")
|
||||
require.NoError(t, err)
|
||||
setting, err := ts.GetInstanceBasicSetting(ctx)
|
||||
require.NoError(t, err)
|
||||
setting.SchemaVersion = "0.31.6"
|
||||
_, err = ts.UpsertInstanceSetting(ctx, &storepb.InstanceSetting{
|
||||
Key: storepb.InstanceSettingKey_BASIC,
|
||||
Value: &storepb.InstanceSetting_BasicSetting{BasicSetting: setting},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, ts.Migrate(ctx))
|
||||
space, err = ts.GetSpace(ctx, &store.FindSpace{ID: &space.ID})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "Legacy", space.Title)
|
||||
require.NotNil(t, space.Payload)
|
||||
require.Nil(t, space.Payload.Icon)
|
||||
var raw string
|
||||
require.NoError(t, ts.GetDriver().GetDB().QueryRowContext(ctx, "SELECT payload FROM space WHERE uid = 'legacy-space'").Scan(&raw))
|
||||
require.JSONEq(t, `{}`, raw)
|
||||
}
|
||||
|
|
@ -939,21 +939,27 @@ func TestUserMemoViewConcurrentPartialUpdates(t *testing.T) {
|
|||
Id: "work",
|
||||
Title: "Original title",
|
||||
Filter: `tag in ["original"]`,
|
||||
Icon: &storepb.MemoViewsUserSetting_MemoView_Icon{Value: &storepb.MemoViewsUserSetting_MemoView_Icon_Emoji{Emoji: "🌱"}},
|
||||
}))
|
||||
|
||||
updatedTitle := "Updated title"
|
||||
updatedFilter := `tag in ["updated"]`
|
||||
var wg sync.WaitGroup
|
||||
errs := make([]error, 2)
|
||||
errs := make([]error, 3)
|
||||
start := make(chan struct{})
|
||||
|
||||
wg.Go(func() {
|
||||
<-start
|
||||
_, errs[0] = ts.UpdateUserMemoView(ctx, user.ID, "work", &updatedTitle, nil)
|
||||
_, errs[0] = ts.UpdateUserMemoView(ctx, user.ID, "work", &updatedTitle, nil, nil)
|
||||
})
|
||||
wg.Go(func() {
|
||||
<-start
|
||||
_, errs[1] = ts.UpdateUserMemoView(ctx, user.ID, "work", nil, &updatedFilter)
|
||||
_, errs[1] = ts.UpdateUserMemoView(ctx, user.ID, "work", nil, &updatedFilter, nil)
|
||||
})
|
||||
wg.Go(func() {
|
||||
<-start
|
||||
icon := &storepb.MemoViewsUserSetting_MemoView_Icon{Value: &storepb.MemoViewsUserSetting_MemoView_Icon_Lucide{Lucide: "leaf"}}
|
||||
_, errs[2] = ts.UpdateUserMemoView(ctx, user.ID, "work", nil, nil, &icon)
|
||||
})
|
||||
close(start)
|
||||
wg.Wait()
|
||||
|
|
@ -961,11 +967,14 @@ func TestUserMemoViewConcurrentPartialUpdates(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
_, err = ts.ListUserSettings(ctx, &store.FindUserSetting{UserID: &user.ID, Key: storepb.UserSetting_MEMO_VIEWS})
|
||||
require.NoError(t, err)
|
||||
memoViews, err := ts.GetUserMemoViews(ctx, user.ID)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, memoViews, 1)
|
||||
require.Equal(t, updatedTitle, memoViews[0].GetTitle())
|
||||
require.Equal(t, updatedFilter, memoViews[0].GetFilter())
|
||||
require.Equal(t, "leaf", memoViews[0].GetIcon().GetLucide())
|
||||
}
|
||||
|
||||
func TestGetUserMemoViewsReturnsCopies(t *testing.T) {
|
||||
|
|
@ -980,17 +989,20 @@ func TestGetUserMemoViewsReturnsCopies(t *testing.T) {
|
|||
Id: "work",
|
||||
Title: "Original title",
|
||||
Filter: `tag in ["original"]`,
|
||||
Icon: &storepb.MemoViewsUserSetting_MemoView_Icon{Value: &storepb.MemoViewsUserSetting_MemoView_Icon_Emoji{Emoji: "🌱"}},
|
||||
}))
|
||||
|
||||
firstRead, err := ts.GetUserMemoViews(ctx, user.ID)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, firstRead, 1)
|
||||
firstRead[0].Title = "Mutated title"
|
||||
firstRead[0].Icon.Value = &storepb.MemoViewsUserSetting_MemoView_Icon_Lucide{Lucide: "leaf"}
|
||||
|
||||
secondRead, err := ts.GetUserMemoViews(ctx, user.ID)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, secondRead, 1)
|
||||
require.Equal(t, "Original title", secondRead[0].GetTitle())
|
||||
require.Equal(t, "🌱", secondRead[0].GetIcon().GetEmoji())
|
||||
}
|
||||
|
||||
func TestUserSettingMemoViewsPartialUpdate(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -495,6 +495,7 @@ func (s *Store) AddUserMemoView(ctx context.Context, userID int32, memoView *sto
|
|||
}
|
||||
|
||||
// UpdateUserMemoView applies the non-nil field updates to the memo view carrying the same ID.
|
||||
// A non-nil icon update containing nil resets the icon.
|
||||
// It returns nil when no matching memo view is found.
|
||||
func (s *Store) UpdateUserMemoView(
|
||||
ctx context.Context,
|
||||
|
|
@ -502,6 +503,7 @@ func (s *Store) UpdateUserMemoView(
|
|||
memoViewID string,
|
||||
title *string,
|
||||
filter *string,
|
||||
icon **storepb.MemoViewsUserSetting_MemoView_Icon,
|
||||
) (*storepb.MemoViewsUserSetting_MemoView, error) {
|
||||
s.memoViewMu.Lock()
|
||||
defer s.memoViewMu.Unlock()
|
||||
|
|
@ -519,17 +521,16 @@ func (s *Store) UpdateUserMemoView(
|
|||
continue
|
||||
}
|
||||
|
||||
updatedMemoView = &storepb.MemoViewsUserSetting_MemoView{
|
||||
Id: item.GetId(),
|
||||
Title: item.GetTitle(),
|
||||
Filter: item.GetFilter(),
|
||||
}
|
||||
updatedMemoView = proto.CloneOf(item)
|
||||
if title != nil {
|
||||
updatedMemoView.Title = *title
|
||||
}
|
||||
if filter != nil {
|
||||
updatedMemoView.Filter = *filter
|
||||
}
|
||||
if icon != nil {
|
||||
updatedMemoView.Icon = proto.CloneOf(*icon)
|
||||
}
|
||||
memoViews = append(memoViews, updatedMemoView)
|
||||
}
|
||||
if updatedMemoView == nil {
|
||||
|
|
|
|||
24
uduapp.json
Normal file
24
uduapp.json
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"format": "uduapp/0.1",
|
||||
"id": "memos",
|
||||
"name": "Memos",
|
||||
"version": "0.24.0",
|
||||
"source": { "owner": "system", "repo": "memos" },
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile",
|
||||
"port": 5230
|
||||
},
|
||||
"native": {
|
||||
"toolchains": [
|
||||
{ "kind": "node", "version": "24" },
|
||||
{ "kind": "go", "version": "1.27" }
|
||||
],
|
||||
"build": "cd web && corepack enable && pnpm install --frozen-lockfile && pnpm release && cd .. && go build -trimpath -ldflags=\"-s -w\" -o memos ./cmd/memos",
|
||||
"run": ["./memos", "--port", "{port}", "--data", "{data}"]
|
||||
},
|
||||
"data": {
|
||||
"dir": "/var/opt/memos",
|
||||
"snapshotKeep": 3
|
||||
},
|
||||
"launcher": { "name": "Memos" }
|
||||
}
|
||||
|
|
@ -269,6 +269,8 @@ const MemoDetailSidebarContent = () => {
|
|||
<MemoDetailSidebar
|
||||
memo={memoDetail.memo}
|
||||
parentMemo={memoDetail.parentMemo}
|
||||
parentStatus={memoDetail.parentStatus}
|
||||
onParentRetry={memoDetail.onParentRetry}
|
||||
parentPage={memoDetail.from}
|
||||
hasExplicitOrigin={memoDetail.hasExplicitOrigin}
|
||||
commentCount={memoDetail.commentCount}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ function SpaceSwitcher({ className, size = "md" }: { className?: string; size?:
|
|||
<span className={cn("flex min-w-0 items-center overflow-hidden", size === "header" ? "gap-2" : "gap-1.5")}>
|
||||
{selectedSpaceName ? (
|
||||
<>
|
||||
<SpaceMark size={spaceMarkSize} />
|
||||
<SpaceMark icon={selectedSpace?.icon} size={spaceMarkSize} />
|
||||
<span data-sidebar-label className="flex min-w-0 flex-1 flex-col justify-center overflow-hidden">
|
||||
<span
|
||||
className={cn(
|
||||
|
|
@ -160,7 +160,7 @@ function SpaceSwitcher({ className, size = "md" }: { className?: string; size?:
|
|||
to={getSpaceSwitchPath(location, space.name)}
|
||||
ariaLabel={showUid && uid ? `${space.title} (${uid})` : space.title}
|
||||
>
|
||||
<SpaceMark size="sm" />
|
||||
<SpaceMark icon={space.icon} size="sm" />
|
||||
<span className="min-w-0 flex-1 overflow-hidden">
|
||||
<span className="block max-w-full truncate font-medium">{space.title}</span>
|
||||
{showUid && uid ? (
|
||||
|
|
|
|||
|
|
@ -1,13 +1,14 @@
|
|||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { MoreHorizontalIcon, ParenthesesIcon, PlusIcon, SquareCheckIcon } from "lucide-react";
|
||||
import { MoreHorizontalIcon, PlusIcon, SquareCheckIcon } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import toast from "react-hot-toast";
|
||||
import { useLocation, useNavigate } from "react-router-dom";
|
||||
import ConfirmDialog from "@/components/ConfirmDialog";
|
||||
import MemoDisplaySettingMenu from "@/components/MemoDisplaySettingMenu";
|
||||
import MemoViewIcon from "@/components/MemoViewIcon";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
|
||||
import { memoViewServiceClient } from "@/connect";
|
||||
import { userServiceClient } from "@/connect";
|
||||
import { useAppSidebar } from "@/contexts/AppSidebarContext";
|
||||
import { useMemoFilterContext } from "@/contexts/MemoFilterContext";
|
||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||
|
|
@ -16,13 +17,14 @@ import { handleError } from "@/lib/error";
|
|||
import { BUILTIN_TASKS_VIEW_ID, getMemoViewId, isMemoCollectionRoute } from "@/lib/memo-views";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { collectionPathForLocation, ROUTES } from "@/router/routes";
|
||||
import type { MemoView } from "@/types/proto/api/v1/memo_view_service_pb";
|
||||
import type { MemoView } from "@/types/proto/api/v1/user_service_pb";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
import SidebarRow, {
|
||||
SIDEBAR_ROW_BOX_CLASSES,
|
||||
SIDEBAR_ROW_ICON_CLASSES,
|
||||
SIDEBAR_ROW_LABEL_CLASSES,
|
||||
SIDEBAR_ROW_SLOT_BUTTON_CLASSES,
|
||||
SidebarRowIconSlot,
|
||||
SIDEBAR_ROW_SLOT_CLASSES,
|
||||
sidebarRowStateAttributes,
|
||||
sidebarRowStateClasses,
|
||||
} from "./SidebarRow";
|
||||
|
|
@ -60,7 +62,7 @@ const ViewsSection = ({ manageActive = false }: { manageActive?: boolean }) => {
|
|||
const handleDelete = async () => {
|
||||
if (!deleteTarget) return;
|
||||
try {
|
||||
await memoViewServiceClient.deleteMemoView({ name: deleteTarget.name });
|
||||
await userServiceClient.deleteMemoView({ name: deleteTarget.name });
|
||||
await queryClient.invalidateQueries({ queryKey: userKeys.memoViews(currentUser?.name) });
|
||||
if (selectedMemoView === getMemoViewId(deleteTarget.name)) setMemoView(undefined);
|
||||
toast.success(t("setting.memo-view.delete-success", { title: deleteTarget.title }));
|
||||
|
|
@ -102,7 +104,9 @@ const ViewsSection = ({ manageActive = false }: { manageActive?: boolean }) => {
|
|||
className={cn(SIDEBAR_ROW_BOX_CLASSES, "group/view", sidebarRowStateClasses(state))}
|
||||
>
|
||||
<button type="button" onClick={() => handleView(id)} aria-pressed={active || undefined} className={SIDEBAR_ROW_LABEL_CLASSES}>
|
||||
<SidebarRowIconSlot icon={ParenthesesIcon} />
|
||||
<span className={SIDEBAR_ROW_SLOT_CLASSES} aria-hidden="true">
|
||||
<MemoViewIcon icon={memoView.icon} className={cn(SIDEBAR_ROW_ICON_CLASSES, "text-base")} />
|
||||
</span>
|
||||
<span className="min-w-0 flex-1 truncate">{memoView.title}</span>
|
||||
</button>
|
||||
<DropdownMenu>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { memo } from "react";
|
||||
import { memo, useState } from "react";
|
||||
import { type CalendarDayCell as CalendarDayCellData, getTooltipText } from "@/components/ActivityCalendar";
|
||||
import { FOCUS_VISIBLE_OUTLINE_CLASSES } from "@/components/ui/focus";
|
||||
import type { MemoTimeBasis } from "@/contexts/ViewContext";
|
||||
|
|
@ -8,17 +8,28 @@ import { CalendarLink } from "./CalendarLink";
|
|||
import type { CalendarDaySummary } from "./dayModel";
|
||||
import { buildCalendarPath, getMonthOfDate } from "./paths";
|
||||
|
||||
/** Vertical rhythm of a cell, in px; the grid derives how many rows fit from these. */
|
||||
export const CELL_PADDING_Y = 16;
|
||||
export const CELL_NUMBER_ROW = 24;
|
||||
export const CELL_ROWS_GAP = 4;
|
||||
export const CELL_ROW_HEIGHT = 18;
|
||||
export interface CalendarCellLayout {
|
||||
compact: boolean;
|
||||
textLines: number;
|
||||
imageHeight: number;
|
||||
imageCount: number;
|
||||
}
|
||||
|
||||
/** Use the actual cell size, including width lost to the resizable day panel. */
|
||||
export const layoutForCellSize = (width: number, height: number): CalendarCellLayout => {
|
||||
const available = Math.max(0, height - 48);
|
||||
return {
|
||||
compact: width < 100,
|
||||
textLines: width < 100 ? 0 : Math.min(3, Math.floor(available / 18)),
|
||||
imageHeight: width < 100 || available < 32 ? 0 : available,
|
||||
imageCount: width < 150 ? 1 : 2,
|
||||
};
|
||||
};
|
||||
|
||||
export interface CalendarDayCellProps {
|
||||
day: CalendarDayCellData;
|
||||
summary?: CalendarDaySummary;
|
||||
/** Memo rows the cell has room for; 0 below md, where the cell only shows a dot. */
|
||||
visibleRows: number;
|
||||
layout: CalendarCellLayout;
|
||||
/** The month's memos are still loading; `day.count` from statistics is all we know. */
|
||||
pending: boolean;
|
||||
timeBasis: MemoTimeBasis;
|
||||
|
|
@ -31,21 +42,19 @@ export interface CalendarDayCellProps {
|
|||
|
||||
const CORNER_CLASSES = { ss: "rounded-ss-lg", se: "rounded-se-lg", es: "rounded-es-lg", ee: "rounded-ee-lg" } as const;
|
||||
|
||||
/**
|
||||
* One day of the month grid: the number, then one row per memo, as many as fit, and a
|
||||
* "+N more" line for the rest. A row is the memo's first line with a small thumbnail when
|
||||
* it carries an image. The whole cell is one link so its aria-label speaks for the day.
|
||||
*/
|
||||
/** One day, one excerpt, and supporting photos. The entire cell opens the day's memo stream. */
|
||||
export const CalendarDayCell = memo(
|
||||
({ day, summary, visibleRows, pending, timeBasis, tabIndex, isLastColumn, isLastRow, corner }: CalendarDayCellProps) => {
|
||||
({ day, summary, layout, pending, timeBasis, tabIndex, isLastColumn, isLastRow, corner }: CalendarDayCellProps) => {
|
||||
const t = useTranslate();
|
||||
const [failedImages, setFailedImages] = useState<string[]>([]);
|
||||
const count = summary ? summary.memos.length : day.count;
|
||||
const entries = summary?.entries ?? [];
|
||||
// The "+N more" line takes a row of its own, so an overflowing day shows one fewer memo.
|
||||
const overflows = count > visibleRows;
|
||||
const shownEntries = entries.slice(0, overflows ? Math.max(visibleRows - 1, 0) : visibleRows);
|
||||
const showMore = overflows && visibleRows >= 1;
|
||||
const showSkeleton = pending && day.isCurrentMonth && day.count > 0;
|
||||
const excerpt = summary?.excerpt;
|
||||
const images = (summary?.images ?? []).filter((image) => !failedImages.includes(image.thumbnailUrl)).slice(0, layout.imageCount);
|
||||
// Keep a usable image even when a short cell cannot also fit the excerpt.
|
||||
// Text uses the space above the 32px image and 8px gap; flex gives photos any unused space.
|
||||
const showImages = images.length > 0 && layout.imageHeight >= 32;
|
||||
const textLines = showImages && excerpt ? Math.max(0, Math.min(2, Math.floor((layout.imageHeight - 40) / 18))) : layout.textLines;
|
||||
const showSkeleton = pending && !summary && day.isCurrentMonth && day.count > 0;
|
||||
|
||||
return (
|
||||
<CalendarLink
|
||||
|
|
@ -55,7 +64,7 @@ export const CalendarDayCell = memo(
|
|||
aria-label={getTooltipText(count, day.date, t, timeBasis)}
|
||||
aria-current={day.isSelected ? "page" : undefined}
|
||||
className={cn(
|
||||
"group/day relative flex min-h-14 min-w-0 flex-col overflow-hidden border-border/70 px-3 py-2 text-start no-underline transition-colors sm:min-h-20 md:min-h-[5.5rem]",
|
||||
"group/day relative flex min-h-14 min-w-0 flex-col overflow-hidden border-border/70 px-1.5 py-2 sm:px-3 text-start no-underline transition-colors sm:min-h-20 md:min-h-[5.5rem]",
|
||||
!isLastColumn && "border-e",
|
||||
!isLastRow && "border-b",
|
||||
corner && CORNER_CLASSES[corner],
|
||||
|
|
@ -64,57 +73,71 @@ export const CalendarDayCell = memo(
|
|||
day.isSelected ? "bg-accent" : day.isCurrentMonth ? "bg-card hover:bg-muted/40" : "bg-muted/25 hover:bg-muted/45",
|
||||
)}
|
||||
>
|
||||
{/* Everything in the cell starts on one axis: the number is plain text, and today's circle
|
||||
is drawn behind it, centered on the digits, so it never pushes the text. */}
|
||||
<span className="flex h-6 items-center">
|
||||
{/* A fixed date slot keeps today's circle inside the cell, including on narrow screens. */}
|
||||
<span className={cn("flex min-h-6 gap-1", layout.compact ? "flex-col items-start" : "items-center justify-between")}>
|
||||
<span
|
||||
className={cn(
|
||||
"relative z-0 inline-flex h-6 items-center text-ui leading-none tabular-nums",
|
||||
"relative z-0 inline-flex size-6 shrink-0 items-center justify-center text-ui font-medium leading-none tabular-nums",
|
||||
day.isToday
|
||||
? "font-medium text-primary-foreground before:absolute before:left-1/2 before:top-1/2 before:-z-10 before:size-[22px] before:-translate-x-1/2 before:-translate-y-1/2 before:rounded-full before:bg-primary before:content-['']"
|
||||
: !day.isCurrentMonth
|
||||
? "text-muted-foreground/40"
|
||||
: count > 0
|
||||
? "font-medium text-foreground"
|
||||
: "text-muted-foreground/60",
|
||||
: "text-muted-foreground",
|
||||
)}
|
||||
>
|
||||
{day.label}
|
||||
</span>
|
||||
{count > 0 && (
|
||||
<span
|
||||
className={cn(
|
||||
"min-w-0 max-w-full whitespace-nowrap text-[10px] font-normal leading-4 tabular-nums sm:text-2xs",
|
||||
layout.compact && "w-6 text-center",
|
||||
day.isCurrentMonth ? "text-muted-foreground" : "text-muted-foreground/40",
|
||||
)}
|
||||
>
|
||||
{count}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
|
||||
{showSkeleton && <span aria-hidden="true" className="mt-1.5 hidden h-2 w-2/3 animate-pulse rounded bg-muted md:block" />}
|
||||
{showSkeleton && layout.textLines > 0 && <span aria-hidden="true" className="mt-2 h-2 w-2/3 animate-pulse rounded bg-muted" />}
|
||||
|
||||
{day.isCurrentMonth && (shownEntries.length > 0 || showMore) && (
|
||||
<ul className="mt-1 flex min-w-0 flex-col">
|
||||
{shownEntries.map((entry) => (
|
||||
<li key={entry.memoName} className="flex h-4.5 min-w-0 items-center gap-1.5 text-xs leading-4 text-foreground/75">
|
||||
{entry.thumbnailUrl && (
|
||||
{day.isCurrentMonth && !showSkeleton && ((excerpt && textLines > 0) || showImages) && (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className="mt-1 flex min-h-0 min-w-0 flex-col gap-2"
|
||||
style={{ height: showImages ? layout.imageHeight : undefined }}
|
||||
>
|
||||
{excerpt && textLines > 0 && (
|
||||
<span
|
||||
className={cn(
|
||||
"shrink-0 overflow-hidden whitespace-pre-line break-words text-xs leading-[18px] text-foreground/80 [display:-webkit-box] [-webkit-box-orient:vertical]",
|
||||
excerpt.isCode && "font-mono",
|
||||
)}
|
||||
style={{ WebkitLineClamp: textLines }}
|
||||
>
|
||||
{excerpt.text}
|
||||
</span>
|
||||
)}
|
||||
{showImages && (
|
||||
<span className="flex max-h-16 min-h-8 min-w-0 flex-1 gap-1">
|
||||
{images.map((image) => (
|
||||
<img
|
||||
src={entry.thumbnailUrl}
|
||||
key={image.thumbnailUrl}
|
||||
src={image.thumbnailUrl}
|
||||
alt=""
|
||||
loading="lazy"
|
||||
decoding="async"
|
||||
className="size-3.5 shrink-0 rounded-[3px] object-cover"
|
||||
// A thumbnail the server cannot produce must not leave a blank box in front of the text.
|
||||
onError={(event) => {
|
||||
event.currentTarget.hidden = true;
|
||||
}}
|
||||
className="h-full min-w-0 flex-1 rounded object-cover"
|
||||
style={{ maxWidth: images.length === 1 ? 112 : undefined }}
|
||||
onError={() => setFailedImages((failed) => [...failed, image.thumbnailUrl])}
|
||||
/>
|
||||
)}
|
||||
<span className="min-w-0 flex-1 truncate">{entry.text}</span>
|
||||
</li>
|
||||
))}
|
||||
{showMore && (
|
||||
<li className="flex h-4.5 items-center text-xs leading-4 text-muted-foreground/70">
|
||||
{t("calendar.more-memos", { count: count - shownEntries.length })}
|
||||
</li>
|
||||
))}
|
||||
</span>
|
||||
)}
|
||||
</ul>
|
||||
)}
|
||||
|
||||
{count > 0 && (
|
||||
<span aria-hidden="true" className={cn("mt-1 size-1.5 rounded-full bg-primary/70", day.isCurrentMonth && "md:hidden")} />
|
||||
</span>
|
||||
)}
|
||||
</CalendarLink>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { type CalendarData, useMonthDays, useWeekdayLabels } from "@/components/
|
|||
import { useInstance } from "@/contexts/InstanceContext";
|
||||
import { useView } from "@/contexts/ViewContext";
|
||||
import { ISO_DATE_FORMAT } from "@/lib/calendar-utils";
|
||||
import { CalendarDayCell, CELL_NUMBER_ROW, CELL_PADDING_Y, CELL_ROW_HEIGHT, CELL_ROWS_GAP } from "./CalendarDayCell";
|
||||
import { CalendarDayCell, layoutForCellSize } from "./CalendarDayCell";
|
||||
import type { CalendarMonthModel } from "./dayModel";
|
||||
import { getDefaultDate } from "./paths";
|
||||
|
||||
|
|
@ -23,16 +23,12 @@ export interface CalendarGridProps {
|
|||
model: CalendarMonthModel;
|
||||
pending: boolean;
|
||||
selectedDate?: string;
|
||||
/** Whether cells have room for memo rows; below md they only show a dot. */
|
||||
/** Below md the compact calendar shows dates and counts, with the stream beneath. */
|
||||
showRows: boolean;
|
||||
}
|
||||
|
||||
const KEY_DELTAS: Record<string, number> = { ArrowLeft: -1, ArrowRight: 1, ArrowUp: -DAYS_IN_WEEK, ArrowDown: DAYS_IN_WEEK };
|
||||
|
||||
/** Memo rows that fit under the day number in a cell of `cellHeight` px. */
|
||||
export const rowsForCellHeight = (cellHeight: number): number =>
|
||||
Math.max(0, Math.floor((cellHeight - CELL_PADDING_Y - CELL_NUMBER_ROW - CELL_ROWS_GAP) / CELL_ROW_HEIGHT));
|
||||
|
||||
const cornerOf = (index: number, total: number): "ss" | "se" | "es" | "ee" | undefined => {
|
||||
if (index === 0) return "ss";
|
||||
if (index === DAYS_IN_WEEK - 1) return "se";
|
||||
|
|
@ -56,13 +52,12 @@ export const CalendarGrid = ({ month, monthLabel, today, counts, model, pending,
|
|||
const focusDate = selectedDate ?? getDefaultDate(month, today);
|
||||
const rowCount = Math.ceil(days.length / DAYS_IN_WEEK);
|
||||
|
||||
// CSS sizes the rows (see the cells' grid-auto-rows); the cell height is only read back to
|
||||
// learn how many memo rows fit, and re-read whenever the grid itself resizes.
|
||||
const [visibleRows, setVisibleRows] = useState(2);
|
||||
// Observe both dimensions so previews adapt when the day panel or viewport resizes.
|
||||
const [cellSize, setCellSize] = useState({ width: 0, height: 0 });
|
||||
useLayoutEffect(() => {
|
||||
const el = cellsRef.current;
|
||||
if (!el || !showRows) return;
|
||||
const apply = () => setVisibleRows(rowsForCellHeight(el.clientHeight / rowCount));
|
||||
if (!el) return;
|
||||
const apply = () => setCellSize({ width: el.clientWidth / DAYS_IN_WEEK, height: el.clientHeight / rowCount });
|
||||
apply();
|
||||
if (typeof ResizeObserver === "undefined") return;
|
||||
const observer = new ResizeObserver(apply);
|
||||
|
|
@ -101,17 +96,17 @@ export const CalendarGrid = ({ month, monthLabel, today, counts, model, pending,
|
|||
))}
|
||||
</div>
|
||||
{/* From xl the grid fills the sticky section, so the rows share its height evenly with a
|
||||
floor that keeps a number and two memo rows per day on short windows. */}
|
||||
floor that keeps the date, count, and a short excerpt visible on short windows. */}
|
||||
<div
|
||||
ref={cellsRef}
|
||||
className="grid grid-cols-7 overflow-hidden rounded-lg border border-border/70 bg-card xl:min-h-0 xl:flex-1 xl:[grid-auto-rows:minmax(5.5rem,1fr)]"
|
||||
className="grid auto-rows-fr grid-cols-7 overflow-hidden rounded-lg border border-border/70 bg-card md:[grid-auto-rows:9rem] xl:min-h-0 xl:flex-1 xl:[grid-auto-rows:minmax(5.5rem,1fr)]"
|
||||
>
|
||||
{days.map((day, index) => (
|
||||
<CalendarDayCell
|
||||
key={day.date}
|
||||
day={day}
|
||||
summary={model[day.date]}
|
||||
visibleRows={showRows ? visibleRows : 0}
|
||||
layout={layoutForCellSize(cellSize.width, showRows ? cellSize.height : 0)}
|
||||
pending={pending}
|
||||
timeBasis={timeBasis}
|
||||
tabIndex={day.date === focusDate ? 0 : -1}
|
||||
|
|
|
|||
|
|
@ -121,9 +121,9 @@ export const CalendarView = ({ month, date }: CalendarViewProps) => {
|
|||
const isEmptyMonth = !isLoading && !error && Object.keys(model).length === 0;
|
||||
|
||||
return (
|
||||
<div className="mx-auto flex w-full max-w-7xl items-start gap-6">
|
||||
<div className="flex w-full items-start gap-6">
|
||||
{/* From xl the section is sticky and viewport-tall so the grid can fill it beside the panel. */}
|
||||
<section className="mx-auto flex w-full min-w-0 max-w-5xl flex-1 flex-col gap-1 xl:sticky xl:top-6 xl:h-[calc(100dvh-3.5rem)]">
|
||||
<section className="flex w-full min-w-0 flex-1 flex-col gap-1 xl:sticky xl:top-6 xl:h-[calc(100dvh-3.5rem)]">
|
||||
<CalendarHeader month={month} monthLabel={monthLabel} today={today} activeDate={activeDate} closable={md} />
|
||||
<CalendarGrid
|
||||
month={month}
|
||||
|
|
|
|||
|
|
@ -1,48 +1,108 @@
|
|||
import dayjs from "dayjs";
|
||||
import type { Element, Root as HtmlRoot } from "hast";
|
||||
import type { Root, RootContent } from "mdast";
|
||||
import { fromMarkdown } from "mdast-util-from-markdown";
|
||||
import { gfmFromMarkdown } from "mdast-util-gfm";
|
||||
import { gfm } from "micromark-extension-gfm";
|
||||
import { defaultUrlTransform } from "react-markdown";
|
||||
import rehypeSanitize from "rehype-sanitize";
|
||||
import remarkRehype from "remark-rehype";
|
||||
import { unified } from "unified";
|
||||
import { visit } from "unist-util-visit";
|
||||
import { SANITIZE_SCHEMA } from "@/components/MemoContent/constants";
|
||||
import type { MemoTimeBasis } from "@/contexts/ViewContext";
|
||||
import { getMemoSortTime } from "@/hooks/useMemoSorting";
|
||||
import { ISO_DATE_FORMAT } from "@/lib/calendar-utils";
|
||||
import type { Memo } from "@/types/proto/api/v1/memo_service_pb";
|
||||
import { getAttachmentThumbnailUrl, isImage } from "@/utils/attachment";
|
||||
import { getAttachmentThumbnailUrl, getAttachmentUrl, isImage } from "@/utils/attachment";
|
||||
import { classifyManagedAttachmentImageURL, extractAttachmentUIDFromName } from "@/utils/managed-attachment";
|
||||
|
||||
/** Rows a day keeps for the grid; a cell shows as many as fit and folds the rest into "+N more". */
|
||||
export const MAX_DAY_ENTRIES = 8;
|
||||
|
||||
export interface CalendarDayEntry {
|
||||
export interface CalendarDayExcerpt {
|
||||
memoName: string;
|
||||
/** First non-empty line of the memo, plain text. */
|
||||
text: string;
|
||||
/** Thumbnail of the memo's first image, when it has one. */
|
||||
thumbnailUrl?: string;
|
||||
isCode: boolean;
|
||||
}
|
||||
|
||||
export interface CalendarDayImage {
|
||||
memoName: string;
|
||||
thumbnailUrl: string;
|
||||
}
|
||||
|
||||
export interface CalendarDaySummary {
|
||||
/** Every memo of the day in time order, including ones that yield no entry; the day panel renders these. */
|
||||
/** Every memo, including hidden ones, in chronological order for the day panel. */
|
||||
memos: Memo[];
|
||||
/** Grid rows in time order, capped at MAX_DAY_ENTRIES. */
|
||||
entries: CalendarDayEntry[];
|
||||
excerpt?: CalendarDayExcerpt;
|
||||
/** At most one image per memo, from the first two eligible image-bearing memos. */
|
||||
images: CalendarDayImage[];
|
||||
}
|
||||
|
||||
/** Day summaries keyed by ISO date (`YYYY-MM-DD`). Days without memos are absent. */
|
||||
export type CalendarMonthModel = Record<string, CalendarDaySummary>;
|
||||
|
||||
export interface BuildCalendarMonthModelOptions {
|
||||
/** Memos that must stay hidden in the grid (blurred tags): they count, but yield no entry. */
|
||||
/** Hidden memos count, but never contribute text, filenames, or images. */
|
||||
isRedacted?: (memo: Memo) => boolean;
|
||||
}
|
||||
|
||||
const firstLine = (text: string): string => {
|
||||
for (const line of text.split(/\r?\n/)) {
|
||||
const trimmed = line.trim();
|
||||
if (trimmed) return trimmed;
|
||||
}
|
||||
return "";
|
||||
const plainText = (node: RootContent): string => {
|
||||
if (node.type === "text" || node.type === "inlineCode" || node.type === "code") return node.value;
|
||||
if (node.type === "break") return "\n";
|
||||
// Image alt text and link definitions are not a written excerpt. Never render raw HTML.
|
||||
if (!("children" in node)) return "";
|
||||
const separator = ["list", "listItem", "blockquote", "table", "tableRow"].includes(node.type) ? "\n" : "";
|
||||
return node.children.map((child) => plainText(child as RootContent)).join(separator);
|
||||
};
|
||||
|
||||
/**
|
||||
* Fold a month's memos into one summary per day. Memos are walked in ascending time so the
|
||||
* rows read as the day unfolded, whatever order the API returned them in.
|
||||
*/
|
||||
const getExcerpt = (memo: Memo, tree: Root): CalendarDayExcerpt | undefined => {
|
||||
const blocks = tree.children;
|
||||
const readable = blocks.map((block) => ({ text: plainText(block).trim(), isCode: block.type === "code" })).filter(({ text }) => text);
|
||||
const text =
|
||||
readable
|
||||
.map((block) => block.text)
|
||||
.join("\n")
|
||||
.trim() || (!memo.content.trim() ? memo.snippet.trim() : "");
|
||||
if (!text) return undefined;
|
||||
return { memoName: memo.name, text: text.length > 280 ? `${text.slice(0, 280).trimEnd()}…` : text, isCode: readable[0]?.isCode ?? false };
|
||||
};
|
||||
|
||||
// Resolve reference-style images and apply the same src sanitization as the body renderer.
|
||||
// Raw HTML is deliberately excluded: only Markdown images contribute to this preview.
|
||||
const imageProcessor = unified()
|
||||
.use(remarkRehype)
|
||||
.use([[rehypeSanitize, SANITIZE_SCHEMA]]);
|
||||
|
||||
const imageKey = (source: string): string => {
|
||||
try {
|
||||
return new URL(source, window.location.href).href;
|
||||
} catch {
|
||||
return source;
|
||||
}
|
||||
};
|
||||
|
||||
const getImageCandidates = (memo: Memo, tree: Root): string[] => {
|
||||
const candidates: string[] = [];
|
||||
const attachments = memo.attachments.filter((attachment) => isImage(attachment.type));
|
||||
const html = imageProcessor.runSync(tree) as HtmlRoot;
|
||||
visit(html, "element", (node: Element) => {
|
||||
if (node.tagName !== "img" || typeof node.properties.src !== "string") return;
|
||||
const source = defaultUrlTransform(node.properties.src);
|
||||
if (!source) return;
|
||||
const classified = classifyManagedAttachmentImageURL(source);
|
||||
if (classified.kind === "invalid") return;
|
||||
const attachment = attachments.find((candidate) =>
|
||||
classified.kind === "managed"
|
||||
? extractAttachmentUIDFromName(candidate.name) === classified.uid
|
||||
: imageKey(getAttachmentUrl(candidate)) === imageKey(source),
|
||||
);
|
||||
// A managed image uses the attachment's thumbnail URL, just like an attached image.
|
||||
// Missing managed attachments must not be treated as external image URLs.
|
||||
if (classified.kind === "managed" && !attachment) return;
|
||||
candidates.push(attachment ? getAttachmentThumbnailUrl(attachment) : source);
|
||||
});
|
||||
candidates.push(...attachments.map(getAttachmentThumbnailUrl));
|
||||
return candidates;
|
||||
};
|
||||
|
||||
/** Fold the month into stable day snapshots, independent of API pagination/order. */
|
||||
export const buildCalendarMonthModel = (
|
||||
memos: Memo[],
|
||||
timeBasis: MemoTimeBasis,
|
||||
|
|
@ -51,23 +111,31 @@ export const buildCalendarMonthModel = (
|
|||
const dated = memos
|
||||
.map((memo) => ({ memo, time: getMemoSortTime(memo, timeBasis) }))
|
||||
.filter((entry): entry is { memo: Memo; time: Date } => entry.time !== undefined)
|
||||
.sort((a, b) => a.time.getTime() - b.time.getTime());
|
||||
.sort((a, b) => a.time.getTime() - b.time.getTime() || a.memo.name.localeCompare(b.memo.name));
|
||||
|
||||
const model: CalendarMonthModel = {};
|
||||
const fileFallbacks = new Map<string, CalendarDayExcerpt>();
|
||||
for (const { memo, time } of dated) {
|
||||
const date = dayjs(time).format(ISO_DATE_FORMAT);
|
||||
const summary = (model[date] ??= { memos: [], entries: [] });
|
||||
const summary = (model[date] ??= { memos: [], images: [] });
|
||||
summary.memos.push(memo);
|
||||
if (isRedacted?.(memo) || summary.entries.length >= MAX_DAY_ENTRIES) continue;
|
||||
|
||||
const image = memo.attachments.find((attachment) => isImage(attachment.type));
|
||||
const text = firstLine(memo.snippet) || firstLine(memo.content);
|
||||
if (!text && !image) continue;
|
||||
summary.entries.push({
|
||||
memoName: memo.name,
|
||||
text,
|
||||
thumbnailUrl: image ? getAttachmentThumbnailUrl(image) : undefined,
|
||||
});
|
||||
if (isRedacted?.(memo)) continue;
|
||||
const tree =
|
||||
!summary.excerpt || summary.images.length < 2
|
||||
? fromMarkdown(memo.content, { extensions: [gfm()], mdastExtensions: [gfmFromMarkdown()] })
|
||||
: undefined;
|
||||
if (!summary.excerpt && tree) summary.excerpt = getExcerpt(memo, tree);
|
||||
if (!fileFallbacks.has(date)) {
|
||||
const file = memo.attachments.find((attachment) => !isImage(attachment.type) && !attachment.motionMedia?.groupId);
|
||||
if (file?.filename) fileFallbacks.set(date, { memoName: memo.name, text: file.filename, isCode: false });
|
||||
}
|
||||
if (summary.images.length >= 2 || !tree) continue;
|
||||
const usedImages = new Set(summary.images.map((image) => imageKey(image.thumbnailUrl)));
|
||||
const thumbnailUrl = getImageCandidates(memo, tree).find((source) => !usedImages.has(imageKey(source)));
|
||||
if (thumbnailUrl) summary.images.push({ memoName: memo.name, thumbnailUrl });
|
||||
}
|
||||
for (const [date, summary] of Object.entries(model)) {
|
||||
summary.excerpt ??= fileFallbacks.get(date);
|
||||
}
|
||||
return model;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import { ChevronDownIcon } from "lucide-react";
|
|||
import { type FormEvent, useEffect, useState } from "react";
|
||||
import { toast } from "react-hot-toast";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import SpaceIconPicker from "@/components/SpaceIconPicker";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
|
||||
import { Input } from "@/components/ui/input";
|
||||
|
|
@ -12,7 +13,7 @@ import useCurrentUser from "@/hooks/useCurrentUser";
|
|||
import { useCreateSpace } from "@/hooks/useSpaceQueries";
|
||||
import { handleError } from "@/lib/error";
|
||||
import { cn } from "@/lib/utils";
|
||||
import type { Space } from "@/types/proto/api/v1/space_service_pb";
|
||||
import type { Space, Space_Icon } from "@/types/proto/api/v1/space_service_pb";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
|
||||
const SPACE_UID_PATTERN = /^[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,34}[a-zA-Z0-9])?$/;
|
||||
|
|
@ -30,6 +31,7 @@ function CreateSpaceDialog({ open, onOpenChange, onCreated, note }: Props) {
|
|||
const createSpace = useCreateSpace(currentUserName);
|
||||
const [title, setTitle] = useState("");
|
||||
const [description, setDescription] = useState("");
|
||||
const [icon, setIcon] = useState<Space_Icon>();
|
||||
const [spaceUid, setSpaceUid] = useState(() => uuidv4());
|
||||
const [showCustomId, setShowCustomId] = useState(false);
|
||||
const [spaceUidConflict, setSpaceUidConflict] = useState(false);
|
||||
|
|
@ -40,6 +42,7 @@ function CreateSpaceDialog({ open, onOpenChange, onCreated, note }: Props) {
|
|||
if (!open) {
|
||||
setTitle("");
|
||||
setDescription("");
|
||||
setIcon(undefined);
|
||||
setSpaceUid(uuidv4());
|
||||
setShowCustomId(false);
|
||||
setSpaceUidConflict(false);
|
||||
|
|
@ -60,6 +63,7 @@ function CreateSpaceDialog({ open, onOpenChange, onCreated, note }: Props) {
|
|||
title: trimmedTitle,
|
||||
description: description.trim() || undefined,
|
||||
spaceId: spaceUid,
|
||||
...(icon ? { icon } : {}),
|
||||
});
|
||||
} catch (error) {
|
||||
if (error instanceof ConnectError && error.code === Code.AlreadyExists) {
|
||||
|
|
@ -92,14 +96,17 @@ function CreateSpaceDialog({ open, onOpenChange, onCreated, note }: Props) {
|
|||
</DialogHeader>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="space-title">{t("common.name")}</Label>
|
||||
<Input
|
||||
id="space-title"
|
||||
value={title}
|
||||
onChange={(event) => setTitle(event.target.value)}
|
||||
placeholder={t("space.name-placeholder")}
|
||||
autoComplete="off"
|
||||
autoFocus
|
||||
/>
|
||||
<div className="flex items-center gap-2">
|
||||
<SpaceIconPicker value={icon} onChange={setIcon} disabled={createSpace.isPending} />
|
||||
<Input
|
||||
id="space-title"
|
||||
value={title}
|
||||
onChange={(event) => setTitle(event.target.value)}
|
||||
placeholder={t("space.name-placeholder")}
|
||||
autoComplete="off"
|
||||
autoFocus
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="space-description">{t("common.description")}</Label>
|
||||
|
|
|
|||
24
web/src/components/CustomIcon.tsx
Normal file
24
web/src/components/CustomIcon.tsx
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { AstroidIcon, type LucideIcon } from "lucide-react";
|
||||
import type { CustomIconValue } from "@/lib/custom-icons";
|
||||
import { getCustomSymbol } from "@/lib/custom-icons";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
interface Props {
|
||||
icon?: CustomIconValue;
|
||||
className?: string;
|
||||
fallback?: LucideIcon;
|
||||
}
|
||||
|
||||
function CustomIcon({ icon, className, fallback = AstroidIcon }: Props) {
|
||||
if (icon?.value.case === "emoji" && icon.value.value) {
|
||||
return (
|
||||
<span aria-hidden className={cn("inline-flex shrink-0 items-center justify-center leading-none", className)}>
|
||||
{icon.value.value}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
const IconComponent = getCustomSymbol(icon?.value.case === "lucide" ? icon.value.value : "", fallback);
|
||||
return <IconComponent aria-hidden className={cn("shrink-0", className)} strokeWidth={1.8} />;
|
||||
}
|
||||
|
||||
export default CustomIcon;
|
||||
192
web/src/components/CustomIconPicker.tsx
Normal file
192
web/src/components/CustomIconPicker.tsx
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
import { AstroidIcon, type LucideIcon, RotateCcwIcon, SearchIcon } from "lucide-react";
|
||||
import { type KeyboardEvent, useId, useRef, useState } from "react";
|
||||
import CustomIcon from "@/components/CustomIcon";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
|
||||
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import type { CustomIconValue } from "@/lib/custom-icons";
|
||||
import { CUSTOM_SYMBOLS, customIconsEqual } from "@/lib/custom-icons";
|
||||
import { SPACE_EMOJI } from "@/lib/space-emoji";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
import { FULLY_QUALIFIED_EMOJI } from "@/utils/tag-unicode-data";
|
||||
|
||||
const emojiSet = new Set(FULLY_QUALIFIED_EMOJI);
|
||||
const symbolLabels: Record<string, string> = {
|
||||
astroid: "Space",
|
||||
"book-open": "Book",
|
||||
"chart-no-axes-combined": "Chart",
|
||||
"check-check": "Checklist",
|
||||
"flask-conical": "Science",
|
||||
"flower-2": "Flower",
|
||||
"graduation-cap": "Education",
|
||||
"map-pin": "Location",
|
||||
"notebook-pen": "Notebook",
|
||||
};
|
||||
const symbols = Object.keys(CUSTOM_SYMBOLS).map((name) => ({
|
||||
label: symbolLabels[name] ?? name.replaceAll("-", " ").replace(/^./, (char) => char.toUpperCase()),
|
||||
icon: { value: { case: "lucide", value: name } } satisfies CustomIconValue,
|
||||
}));
|
||||
const emojis = SPACE_EMOJI.map(([emoji, label]) => ({ label, icon: { value: { case: "emoji", value: emoji } } satisfies CustomIconValue }));
|
||||
|
||||
interface Props {
|
||||
value?: CustomIconValue;
|
||||
onChange: (icon: CustomIconValue | undefined) => void;
|
||||
disabled?: boolean;
|
||||
label: string;
|
||||
fallback?: LucideIcon;
|
||||
}
|
||||
|
||||
function CustomIconPicker({ value, onChange, disabled, label, fallback = AstroidIcon }: Props) {
|
||||
const t = useTranslate();
|
||||
const id = useId();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [tab, setTab] = useState("icons");
|
||||
const [query, setQuery] = useState("");
|
||||
const [focusedIndex, setFocusedIndex] = useState(0);
|
||||
const searchRef = useRef<HTMLInputElement>(null);
|
||||
const gridRef = useRef<HTMLDivElement>(null);
|
||||
const search = query.trim().toLowerCase();
|
||||
const options: { label: string; icon: CustomIconValue }[] = (tab === "icons" ? symbols : emojis).filter(
|
||||
(option) => option.label.toLowerCase().includes(search) || option.icon.value.value?.includes(search),
|
||||
);
|
||||
const customEmoji = query.trim() || (value?.value.case === "emoji" ? value.value.value : "");
|
||||
if (tab === "emoji" && emojiSet.has(customEmoji) && !options.some((option) => option.icon.value.value === customEmoji)) {
|
||||
options.unshift({
|
||||
label: t("space.icon.use-emoji", { emoji: customEmoji }),
|
||||
icon: { value: { case: "emoji", value: customEmoji } },
|
||||
});
|
||||
}
|
||||
|
||||
const select = (icon?: CustomIconValue) => {
|
||||
onChange(icon);
|
||||
setOpen(false);
|
||||
};
|
||||
const changeTab = (next: string) => {
|
||||
setTab(next);
|
||||
setQuery("");
|
||||
setFocusedIndex(0);
|
||||
};
|
||||
const moveFocus = (event: KeyboardEvent<HTMLButtonElement>, index: number) => {
|
||||
const offsets: Record<string, number> = { ArrowLeft: -1, ArrowRight: 1, ArrowUp: -8, ArrowDown: 8 };
|
||||
let next = index;
|
||||
if (event.key in offsets) next = Math.max(0, Math.min(options.length - 1, index + offsets[event.key]));
|
||||
else if (event.key === "Home") next = 0;
|
||||
else if (event.key === "End") next = options.length - 1;
|
||||
else return;
|
||||
event.preventDefault();
|
||||
setFocusedIndex(next);
|
||||
gridRef.current?.querySelectorAll<HTMLButtonElement>("button")[next]?.focus();
|
||||
};
|
||||
|
||||
return (
|
||||
<Popover
|
||||
open={open}
|
||||
onOpenChange={(next) => {
|
||||
if (next) {
|
||||
changeTab(value?.value.case === "emoji" ? "emoji" : "icons");
|
||||
}
|
||||
setOpen(next);
|
||||
}}
|
||||
>
|
||||
<PopoverTrigger
|
||||
render={
|
||||
<Button type="button" variant="outline" size="icon" className="size-8 p-0" disabled={disabled} aria-label={label} title={label} />
|
||||
}
|
||||
>
|
||||
<CustomIcon icon={value} fallback={fallback} className="size-5 text-xl" />
|
||||
</PopoverTrigger>
|
||||
<PopoverContent align="start" className="w-[290px] max-w-[calc(100vw-2rem)] p-2" aria-label={label} initialFocus={searchRef}>
|
||||
<Tabs value={tab} onValueChange={changeTab}>
|
||||
<TabsList className="mb-2 rounded-md bg-muted/60 p-0.5" aria-label={t("space.icon.kind")}>
|
||||
{(["icons", "emoji"] as const).map((name) => (
|
||||
<TabsTrigger
|
||||
key={name}
|
||||
id={`${id}-${name}`}
|
||||
value={name}
|
||||
aria-controls={`${id}-panel`}
|
||||
tabIndex={tab === name ? 0 : -1}
|
||||
className="flex-1 py-1 text-xs"
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
|
||||
event.preventDefault();
|
||||
const next = name === "icons" ? "emoji" : "icons";
|
||||
changeTab(next);
|
||||
document.getElementById(`${id}-${next}`)?.focus();
|
||||
}
|
||||
}}
|
||||
>
|
||||
{t(`space.icon.${name}`)}
|
||||
</TabsTrigger>
|
||||
))}
|
||||
</TabsList>
|
||||
</Tabs>
|
||||
<div id={`${id}-panel`} role="tabpanel" aria-labelledby={`${id}-${tab}`}>
|
||||
<div className="relative mb-2">
|
||||
<SearchIcon aria-hidden className="pointer-events-none absolute start-2 top-2 size-4 text-muted-foreground" />
|
||||
<Input
|
||||
ref={searchRef}
|
||||
value={query}
|
||||
className="ps-8 text-sm"
|
||||
aria-label={t(tab === "icons" ? "space.icon.search-icons" : "space.icon.search-emoji")}
|
||||
placeholder={t(tab === "icons" ? "space.icon.search-icons" : "space.icon.search-emoji")}
|
||||
onChange={(event) => {
|
||||
setQuery(event.target.value);
|
||||
setFocusedIndex(0);
|
||||
}}
|
||||
onKeyDown={(event) => {
|
||||
if (event.nativeEvent.isComposing || event.keyCode === 229) return;
|
||||
if (event.key === "Enter") {
|
||||
event.preventDefault();
|
||||
if (options[0]) select(options[0].icon);
|
||||
} else if (event.key === "ArrowDown" && options.length) {
|
||||
event.preventDefault();
|
||||
setFocusedIndex(0);
|
||||
gridRef.current?.querySelector<HTMLButtonElement>("button")?.focus();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="max-h-56 overflow-y-auto overscroll-contain" ref={gridRef}>
|
||||
{options.length ? (
|
||||
<div className="grid grid-cols-8 gap-0.5">
|
||||
{options.map((option, index) => (
|
||||
<Button
|
||||
key={`${option.icon.value.case}:${option.icon.value.value}`}
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
aria-label={option.label}
|
||||
title={option.label}
|
||||
aria-pressed={customIconsEqual(value, option.icon)}
|
||||
tabIndex={index === Math.min(focusedIndex, options.length - 1) ? 0 : -1}
|
||||
onFocus={() => setFocusedIndex(index)}
|
||||
onKeyDown={(event) => moveFocus(event, index)}
|
||||
onClick={() => select(option.icon)}
|
||||
className={cn("rounded-md", customIconsEqual(value, option.icon) && "bg-accent ring-1 ring-inset ring-primary/40")}
|
||||
>
|
||||
<CustomIcon icon={option.icon} className={tab === "emoji" ? "size-5 text-xl" : "size-4"} />
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<p role="status" className="py-8 text-center text-xs text-muted-foreground">
|
||||
{t("space.icon.no-results")}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
{tab === "emoji" && <p className="px-1 pt-2 text-xs leading-4 text-muted-foreground">{t("space.icon.emoji-help")}</p>}
|
||||
</div>
|
||||
<div className="mt-2 border-t pt-1.5">
|
||||
<Button type="button" variant="quiet" size="sm" className="w-full justify-start" disabled={!value} onClick={() => select()}>
|
||||
<RotateCcwIcon aria-hidden className="size-3.5" />
|
||||
{t("space.icon.reset")}
|
||||
</Button>
|
||||
</div>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
);
|
||||
}
|
||||
|
||||
export default CustomIconPicker;
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue