From 9576bd53ac5922f3b8e680c03eb42be0d74252de Mon Sep 17 00:00:00 2001 From: Johnny Date: Thu, 22 Oct 2026 18:58:45 +0800 Subject: [PATCH] feat: filter memos by attachments and images (#6492) --- core/memopayload/runner.go | 157 +++++++++---- core/memopayload/runner_test.go | 98 ++++++++ docs/design/README.md | 4 + docs/design/memo-attachment-filters.md | 252 +++++++++++++++++++++ filter/MAINTENANCE.md | 4 + filter/README.md | 7 + filter/engine_test.go | 122 ++++++++++ filter/render.go | 60 +++++ filter/schema.go | 61 +++++ markdown/markdown.go | 6 + markdown/markdown_test.go | 33 +++ proto/api/memo_service.proto | 8 +- proto/gen/api/memo_service.pb.go | 25 +- proto/gen/openapi.yaml | 8 +- proto/gen/store/instance_setting.pb.go | 19 +- proto/gen/store/memo.pb.go | 22 +- proto/store/instance_setting.proto | 3 + proto/store/memo.proto | 2 + server/api/memo_service_converter.go | 1 + server/server.go | 28 +++ store/db/mysql/memo.go | 17 ++ store/db/postgres/memo.go | 16 ++ store/db/sqlite/memo.go | 16 ++ store/driver.go | 1 + store/memo.go | 47 +++- store/test/memo_payload_refresh_test.go | 83 +++++++ web/src/components/MemoFilters.tsx | 10 + web/src/contexts/MemoFilterContext.tsx | 4 +- web/src/hooks/useMemoFilters.ts | 4 + web/src/locales/ar.json | 2 + web/src/locales/az.json | 2 + web/src/locales/bg.json | 2 + web/src/locales/ca.json | 2 + web/src/locales/cs.json | 2 + web/src/locales/da.json | 2 + web/src/locales/de.json | 2 + web/src/locales/el.json | 2 + web/src/locales/en-GB.json | 2 + web/src/locales/en.json | 2 + web/src/locales/es.json | 2 + web/src/locales/et.json | 2 + web/src/locales/fa.json | 2 + web/src/locales/fi.json | 2 + web/src/locales/fr.json | 2 + web/src/locales/gl.json | 2 + web/src/locales/he.json | 2 + web/src/locales/hi.json | 2 + web/src/locales/hr.json | 2 + web/src/locales/hu.json | 2 + web/src/locales/id.json | 2 + web/src/locales/it.json | 2 + web/src/locales/ja.json | 2 + web/src/locales/ka-GE.json | 2 + web/src/locales/ko.json | 2 + web/src/locales/lt.json | 2 + web/src/locales/lv.json | 2 + web/src/locales/mr.json | 2 + web/src/locales/nb.json | 2 + web/src/locales/nl.json | 2 + web/src/locales/nn.json | 2 + web/src/locales/pl.json | 2 + web/src/locales/pt-BR.json | 2 + web/src/locales/pt-PT.json | 2 + web/src/locales/ro.json | 2 + web/src/locales/ru.json | 2 + web/src/locales/sk.json | 2 + web/src/locales/sl.json | 2 + web/src/locales/sr.json | 2 + web/src/locales/sv.json | 2 + web/src/locales/th.json | 2 + web/src/locales/tr.json | 2 + web/src/locales/uk.json | 2 + web/src/locales/vi.json | 2 + web/src/locales/zh-Hans.json | 2 + web/src/locales/zh-Hant.json | 2 + web/src/pages/MemoViews.tsx | 16 ++ web/src/types/proto/api/memo_service_pb.ts | 14 +- web/tests/memo-views.test.ts | 4 +- 78 files changed, 1182 insertions(+), 62 deletions(-) create mode 100644 core/memopayload/runner_test.go create mode 100644 docs/design/memo-attachment-filters.md create mode 100644 store/test/memo_payload_refresh_test.go diff --git a/core/memopayload/runner.go b/core/memopayload/runner.go index db88b3ced..1e9bbc8c0 100644 --- a/core/memopayload/runner.go +++ b/core/memopayload/runner.go @@ -1,3 +1,5 @@ +// Package memopayload computes the content-derived part of a memo payload and +// keeps stored payloads current when that computation changes. package memopayload import ( @@ -5,17 +7,31 @@ import ( "log/slog" "github.com/pkg/errors" + "google.golang.org/protobuf/proto" "github.com/usememos/memos/markdown" storepb "github.com/usememos/memos/proto/gen/store" "github.com/usememos/memos/store" ) +// Version identifies the content-derived part of a memo payload, the tags and +// property that RebuildMemoPayload takes from the Markdown extractor. Bump it +// whenever that output changes for existing content, so the server rebuilds +// every memo's payload once after upgrading. +// +// 1: Property.has_inline_image. +const Version = 1 + +// batchSize is how many memos the rebuild loads at a time. +const batchSize = 100 + +// Runner rebuilds stored memo payloads. type Runner struct { Store *store.Store MarkdownService markdown.Service } +// NewRunner returns a Runner over the store. func NewRunner(store *store.Store, markdownService markdown.Service) *Runner { return &Runner{ Store: store, @@ -23,54 +39,119 @@ func NewRunner(store *store.Store, markdownService markdown.Service) *Runner { } } -// RunOnce rebuilds the payload of all memos. -func (r *Runner) RunOnce(ctx context.Context) { - // Process memos in batches to avoid loading all memos into memory at once - const batchSize = 100 - offset := 0 - processed := 0 +// Backfill rebuilds every memo's content-derived payload once per Version. +// The version is recorded only after a pass in which every memo was written, +// so an interrupted or failed pass runs again on the next start. Rebuilding is +// idempotent, and each write is guarded against concurrent edits, so it is +// safe to run while the server takes traffic. +func (r *Runner) Backfill(ctx context.Context) error { + basicSetting, err := r.Store.GetInstanceBasicSetting(ctx) + if err != nil { + return errors.Wrap(err, "failed to get instance basic setting") + } + if basicSetting.PayloadVersion >= Version { + return nil + } + slog.Info("rebuilding memo payloads", + slog.Int("fromVersion", int(basicSetting.PayloadVersion)), + slog.Int("toVersion", Version)) + if err := r.RunOnce(ctx); err != nil { + return err + } - for { - limit := batchSize + // Re-read: the cache hands out a shared value, and the setting may have + // changed during the pass. + basicSetting, err = r.Store.GetInstanceBasicSetting(ctx) + if err != nil { + return errors.Wrap(err, "failed to get instance basic setting") + } + updated := proto.CloneOf(basicSetting) + updated.PayloadVersion = Version + if _, err := r.Store.UpsertInstanceSetting(ctx, &storepb.InstanceSetting{ + Key: storepb.InstanceSettingKey_BASIC, + Value: &storepb.InstanceSetting_BasicSetting{BasicSetting: updated}, + }); err != nil { + return errors.Wrap(err, "failed to record memo payload version") + } + return nil +} + +// RunOnce rebuilds the content-derived payload of every memo. It collects the +// memo IDs first, so memos created or deleted during the pass cannot shift the +// pages and skip a memo. Content that fails to parse is logged and skipped, +// since a retry cannot fix it; a failed write fails the pass after every memo +// has been tried. +func (r *Runner) RunOnce(ctx context.Context) error { + ids, err := r.listMemoIDs(ctx) + if err != nil { + return err + } + + refreshed, skipped, failed := 0, 0, 0 + for start := 0; start < len(ids); start += batchSize { + if err := ctx.Err(); err != nil { + return err + } + end := min(start+batchSize, len(ids)) + memos, err := r.Store.ListMemos(ctx, &store.FindMemo{IDList: ids[start:end]}) + if err != nil { + return errors.Wrap(err, "failed to list memos") + } + for _, memo := range memos { + data, err := r.MarkdownService.ExtractAll([]byte(memo.Content)) + if err != nil { + slog.Warn("skipping memo payload rebuild", slog.Int("memoID", int(memo.ID)), slog.String("error", err.Error())) + skipped++ + continue + } + if err := r.Store.RefreshMemoDerivedPayload(ctx, &store.RefreshMemoDerivedPayload{ + ID: memo.ID, + Content: memo.Content, + Tags: data.Tags, + Property: data.Property, + }); err != nil { + if ctx.Err() != nil { + return ctx.Err() + } + slog.Error("failed to rebuild memo payload", slog.Int("memoID", int(memo.ID)), slog.String("error", err.Error())) + failed++ + continue + } + refreshed++ + } + } + + slog.Info("rebuilt memo payloads", + slog.Int("refreshed", refreshed), slog.Int("skipped", skipped), slog.Int("failed", failed)) + if failed > 0 { + return errors.Errorf("failed to rebuild %d memo payloads", failed) + } + return nil +} + +func (r *Runner) listMemoIDs(ctx context.Context) ([]int32, error) { + ids := []int32{} + for offset := 0; ; offset += batchSize { + limit, pageOffset := batchSize, offset memos, err := r.Store.ListMemos(ctx, &store.FindMemo{ - Limit: &limit, - Offset: &offset, + ExcludeContent: true, + OrderByTimeAsc: true, + Limit: &limit, + Offset: &pageOffset, }) if err != nil { - slog.Error("failed to list memos", "err", err) - return + return nil, errors.Wrap(err, "failed to list memo IDs") } - - // Break if no more memos - if len(memos) == 0 { - break - } - - // Process batch - batchSuccessCount := 0 for _, memo := range memos { - if err := RebuildMemoPayload(ctx, memo, r.MarkdownService); err != nil { - slog.Error("failed to rebuild memo payload", "err", err, "memoID", memo.ID) - continue - } - if err := r.Store.UpdateMemo(ctx, &store.UpdateMemo{ - ID: memo.ID, - Payload: memo.Payload, - }); err != nil { - slog.Error("failed to update memo", "err", err, "memoID", memo.ID) - continue - } - batchSuccessCount++ + ids = append(ids, memo.ID) + } + if len(memos) < batchSize { + return ids, nil } - - processed += len(memos) - slog.Info("Processed memo batch", "batchSize", len(memos), "successCount", batchSuccessCount, "totalProcessed", processed) - - // Move to next batch - offset += len(memos) } } +// RebuildMemoPayload sets the memo's tags and property from its content. func RebuildMemoPayload(_ context.Context, memo *store.Memo, markdownService markdown.Service) error { if memo.Payload == nil { memo.Payload = &storepb.MemoPayload{} diff --git a/core/memopayload/runner_test.go b/core/memopayload/runner_test.go new file mode 100644 index 000000000..34e662f5e --- /dev/null +++ b/core/memopayload/runner_test.go @@ -0,0 +1,98 @@ +package memopayload_test + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/proto" + + "github.com/usememos/memos/core/memopayload" + "github.com/usememos/memos/markdown" + storepb "github.com/usememos/memos/proto/gen/store" + "github.com/usememos/memos/store" + teststore "github.com/usememos/memos/store/test" +) + +func TestBackfillRebuildsOncePerVersion(t *testing.T) { + ctx := context.Background() + st := teststore.NewTestingStore(ctx, t) + user, err := st.CreateUser(ctx, &store.User{Username: "payload-backfill", Role: store.RoleUser, PasswordHash: "hash"}) + require.NoError(t, err) + + // Payloads written before has_inline_image existed: the flag is missing. + location := &storepb.MemoPayload_Location{Placeholder: "Pier"} + external, err := st.CreateMemo(ctx, &store.Memo{ + UID: "backfill-external-image", CreatorID: user.ID, Visibility: store.Private, + Content: "![view](https://example.com/view.jpg) #travel", + Payload: &storepb.MemoPayload{Tags: []string{"travel"}, Location: location}, + }) + require.NoError(t, err) + plain, err := st.CreateMemo(ctx, &store.Memo{ + UID: "backfill-plain", CreatorID: user.ID, Visibility: store.Private, + Content: "no picture", + Payload: &storepb.MemoPayload{Property: &storepb.MemoPayload_Property{HasLink: true}}, + }) + require.NoError(t, err) + + runner := memopayload.NewRunner(st, newMarkdownService()) + require.NoError(t, runner.Backfill(ctx)) + + got, err := st.GetMemo(ctx, &store.FindMemo{ID: &external.ID}) + require.NoError(t, err) + require.True(t, got.Payload.GetProperty().GetHasInlineImage()) + require.Equal(t, []string{"travel"}, got.Payload.Tags) + require.Equal(t, "Pier", got.Payload.GetLocation().GetPlaceholder(), "the rebuild keeps the location") + got, err = st.GetMemo(ctx, &store.FindMemo{ID: &plain.ID}) + require.NoError(t, err) + require.False(t, got.Payload.GetProperty().GetHasLink(), "stale flags are recomputed from content") + + basic, err := st.GetInstanceBasicSetting(ctx) + require.NoError(t, err) + require.Equal(t, int32(memopayload.Version), basic.PayloadVersion) + require.NotEmpty(t, basic.SchemaVersion, "recording the version keeps the other basic setting fields") + + // A recorded version skips the pass: a payload changed after it stays. + stale := &storepb.MemoPayload{} + require.NoError(t, st.UpdateMemo(ctx, &store.UpdateMemo{ID: external.ID, Payload: stale})) + require.NoError(t, runner.Backfill(ctx)) + got, err = st.GetMemo(ctx, &store.FindMemo{ID: &external.ID}) + require.NoError(t, err) + require.False(t, got.Payload.GetProperty().GetHasInlineImage()) + + // An older recorded version runs the pass again. + older, ok := proto.Clone(basic).(*storepb.InstanceBasicSetting) + require.True(t, ok) + older.PayloadVersion = memopayload.Version - 1 + _, err = st.UpsertInstanceSetting(ctx, &storepb.InstanceSetting{ + Key: storepb.InstanceSettingKey_BASIC, + Value: &storepb.InstanceSetting_BasicSetting{BasicSetting: older}, + }) + require.NoError(t, err) + require.NoError(t, runner.Backfill(ctx)) + got, err = st.GetMemo(ctx, &store.FindMemo{ID: &external.ID}) + require.NoError(t, err) + require.True(t, got.Payload.GetProperty().GetHasInlineImage()) +} + +func TestBackfillStopsOnCancel(t *testing.T) { + ctx := context.Background() + st := teststore.NewTestingStore(ctx, t) + user, err := st.CreateUser(ctx, &store.User{Username: "payload-cancel", Role: store.RoleUser, PasswordHash: "hash"}) + require.NoError(t, err) + _, err = st.CreateMemo(ctx, &store.Memo{UID: "backfill-cancel", CreatorID: user.ID, Visibility: store.Private, Content: "x"}) + require.NoError(t, err) + + canceled, cancel := context.WithCancel(ctx) + cancel() + require.Error(t, memopayload.NewRunner(st, newMarkdownService()).Backfill(canceled)) + + basic, err := st.GetInstanceBasicSetting(ctx) + require.NoError(t, err) + require.Zero(t, basic.PayloadVersion, "an interrupted pass must not record the version") +} + +// newMarkdownService matches the extensions the server uses. +func newMarkdownService() markdown.Service { + return markdown.NewService(markdown.WithTagExtension(), markdown.WithMentionExtension()) +} diff --git a/docs/design/README.md b/docs/design/README.md index 963ce57ee..183ab6dc7 100644 --- a/docs/design/README.md +++ b/docs/design/README.md @@ -18,6 +18,10 @@ Drafts, merged but not yet released: - [User usage limits](user-usage-limits.md) +Drafts, implemented but not yet merged: + +- [Memo attachment and image filters](memo-attachment-filters.md) + Implemented and frozen: - [API abuse controls](api-abuse-controls.md) diff --git a/docs/design/memo-attachment-filters.md b/docs/design/memo-attachment-filters.md new file mode 100644 index 000000000..bbc2402ea --- /dev/null +++ b/docs/design/memo-attachment-filters.md @@ -0,0 +1,252 @@ +# Memo Attachment and Image Filters Design + +Status: Draft (implemented, not yet merged) + +Date: 2026-10-22 + +Existing domain language: [Memos context](../../CONTEXT.md) + +Related: [Multi-Spaces](multi-spaces.md) for the memo list query shape, `filter/README.md` and `filter/MAINTENANCE.md` for the filter engine. + +## Summary + +Memos can be filtered by facts derived from their content: `has_link`, `has_code`, `has_task_list`, `has_incomplete_tasks`, and +`has_location`. There is no way to ask for memos that carry a file, or memos that show a picture, although both are among the most +common ways people recognise a memo they are looking for. + +This design adds two filter fields: + +- `has_attachments`: the memo has at least one bound attachment, of any type. +- `has_image`: the memo shows an image when rendered, either because its content contains a Markdown image or because an image file is + attached to it. + +The two fields differ in where their truth lives, and the design keeps each fact in the one place that already owns it. Attachment +binding is a relation stored in `attachment.memo_id`, so both fields read it with an `EXISTS` subquery at query time. Markdown image +syntax is a content fact, so it becomes a new stored payload property, `has_inline_image`, computed by the same extractor that +computes `has_link`. Nothing about attachments is copied into the memo row, so there is nothing that can drift when an attachment is +added, moved, or deleted without the memo content changing. + +Existing memos get the new property from a one-time background rebuild, gated by a payload version recorded in the instance basic +setting. The same gate serves every later change to what the extractor stores. + +## Goals + +- `has_attachments` and `has_image` work in every place a memo filter is accepted: the list API, saved Views, the web search box, and + the MCP memo listing. +- Both fields support the same grammar as `has_location`: bare, negated, and compared with `true` or `false`. +- Results are correct immediately after any attachment change, with no rebuild step and no eventual consistency. +- Existing memos match after upgrade without being edited, and the upgrade does not delay serving. + +## Non-goals + +- Counting attachments or filtering by attachment size, name, or storage type. The attachment list API already filters attachments + directly. +- Sorting memos by these fields. Filter fields are predicates only. +- Exposing `has_image` as a memo property on the API. Clients that render a memo already hold its attachment list and can derive it. +- Treating raw HTML `` tags as images. The Markdown extractor already rejects managed attachment references in raw HTML, and the + renderer sanitises them; content that cannot show an image does not count as having one. +- A new database index. See [Query cost](#query-cost). + +## Behavior + +### `has_attachments` + +True when at least one row in `attachment` has `memo_id` equal to the memo's id. Comments are memos and can have attachments, so a +comment with a file matches like any other memo. An attachment that is uploaded but not yet bound to a memo matches nothing. + +A managed image embedded in the content, `![alt](/file/attachments/)`, is always backed by a bound attachment: the server refuses +to save content that references a managed attachment that is not bound to the memo, and requires that attachment to have an `image/*` +type. `has_attachments` therefore already covers inline managed images, and needs no content half. + +### `has_image` + +True when either of the following holds: + +1. The content contains a Markdown image. This covers managed attachment images and external images alike, since both render as a + picture. Images inside code spans and code blocks do not count; the parser does not produce image nodes there. +2. At least one bound attachment has a MIME type starting with `image/`, case-insensitively. This covers the common flow of uploading + a photo without referencing it in the text; such attachments render in the memo's attachment strip. + +From the user's side there is one question, "does this memo show a picture", and one field answers it. The two sources are an +implementation detail that the filter renderer hides. + +### Grammar + +Both fields are booleans with the comparison rules of `has_location`: + +| Expression | Meaning | +| --- | --- | +| `has_image` | memos that show an image | +| `!has_image` | memos that do not | +| `has_image == true`, `has_image != false` | same as the bare form | +| `has_image == false`, `has_image != true` | same as the negated form | +| `has_attachments && !has_image` | memos with files but no picture | + +Other operators are rejected at parse time, as they are for the existing boolean fields. + +## Storage + +### Stored payload: `has_inline_image` + +`MemoPayload.Property` in `proto/store/memo.proto` gains `bool has_inline_image = 6`. The Markdown extractor sets it when it visits an +image node, in both `ExtractAll` and `ExtractProperties`, next to `has_link`. Like the other flags it is omitted from the stored JSON +when false, so a missing key reads as false. + +The flag is named for what it measures, Markdown image syntax, and not `has_image`, because the stored property is also published on +the API as `Memo.property` and every field there is documented as a fact about the content. A stored `has_image` that is false on a +memo with three uploaded photos would be misleading, and would invite someone to "simplify" the filter down to the stored flag. + +`Memo.Property` in `proto/api/memo_service.proto` gains the matching `bool has_inline_image = 6`, documented as "Whether the content +contains a Markdown image." The API `Property` message stays a pure content summary. The change is additive, so +`proto/api/CHANGELOG.md` has no entry. + +### Payload version + +`InstanceBasicSetting` in `proto/store/instance_setting.proto` gains `int32 payload_version = 3`: the version every memo's +content-derived payload has been rebuilt to. The current version is the constant `memopayload.Version` in `core/memopayload`, next to +the rebuild that consumes it. It is `1`, for `has_inline_image`. Every later change to what the extractor stores for existing content +bumps it. The constant lives in `core/memopayload` and not in `markdown`, because the Markdown engine knows nothing about how memos are +stored or upgraded. + +There is no other schema change and no migration file. + +## Filter rendering + +The filter engine gains one field kind, `FieldKindExists`, for a boolean derived from the presence of related rows. A field of this +kind carries a `Related` description: + +- `Table`, `ForeignKey`, and `Owner`: the related table, its column that holds the owner's key, and the outer column it refers to, + `memo.id`. +- optionally `PrefixColumn` and `Prefix`: keep only related rows whose column starts with a schema constant, ignoring case. The + renderer rejects a prefix containing quotes or `LIKE` wildcards. + +It may also carry a `JSONPath`: a payload boolean that is OR-ed with the subquery. + +The renderer produces `EXISTS (SELECT 1 FROM WHERE
. = memo.id [AND LOWER(
.) LIKE '%'])`, with +dialect quoting through the existing column helpers. When a `JSONPath` is set, the result is `( OR EXISTS (...))`, +using the existing `jsonBoolPredicate` helper so the payload half keeps the dialect-specific handling of a missing key or a NULL +payload. Negation and `== false` wrap the whole expression in `NOT (...)`, which is already how `has_location` is rendered. Both halves +are two-valued, so a memo with no payload and no attachments is correctly excluded or included. The SQL carries no bound arguments. + +The two fields: + +| Field | Related | Prefix | JSONPath | +| --- | --- | --- | --- | +| `has_attachments` | `attachment.memo_id` = `memo.id` | none | none | +| `has_image` | `attachment.memo_id` = `memo.id` | `type` starts with `image/` | `property.hasInlineImage` | + +`LOWER` keeps the MIME check case-insensitive on SQLite and PostgreSQL, where `LIKE` is case-sensitive; on MySQL it is harmless. + +Both subquery contexts that compile memo filters select `FROM memo`: the memo list, and the memo-relation listing that wraps the +filter in `memo_id IN (SELECT id FROM memo WHERE ...)`. The correlated `memo.id` resolves correctly in both. + +### Query cost + +`attachment` is indexed on `creator_id` only, so the subquery finds a memo's attachments without an index on `memo_id`. PostgreSQL and +MySQL 8 plan a correlated `EXISTS` like this as a semi-join and can hash the attachment table once; SQLite can build a transient +automatic index for the subquery. An index on `attachment(memo_id)` was considered and deferred: it would also speed up the per-page +attachment load that the memo list already performs, and should be added in its own change if list latency with these filters is +measured to need it. + +## Backfill + +`has_attachments` needs none, and `has_image` matches every memo with an image attachment from the first request after upgrade. + +`has_inline_image` is stored, so memos saved before the upgrade lack it until their payload is rebuilt. Only memos whose only image is +an external URL are affected, because managed inline images are bound attachments and already match through the subquery. The +rebuild closes that gap. + +**When it runs.** After the HTTP server starts listening, the server starts `memopayload.Runner.Backfill` in the background. It reads +the basic setting and returns at once when `payload_version` is at least `memopayload.Version`, so a normal start does no work. A fresh +install runs the pass over zero memos and records the version. + +**What it writes.** For each memo, the runner extracts tags and property from the content and calls +`store.RefreshMemoDerivedPayload`. That write replaces only `$.tags` and `$.property` inside the payload JSON, through `JSON_SET` on +SQLite and MySQL and `jsonb_set` on PostgreSQL, and only `WHERE content = ?` with the content the values were computed from. On MySQL +the comparison is binary, so a case-insensitive collation cannot match an edit that only changed case. The location and every other +payload key stay as stored, and `updated_ts` does not change, so the rebuild never reorders recently updated memos. A memo that a user +edits during the pass is left alone; the edit already wrote a current payload. This guard is why the pass can run while the server +takes traffic. A plain `UpdateMemo` would write the whole payload read moments earlier, and could undo a concurrent tag or location +change. + +**Coverage.** The runner first collects every memo ID in creation order, then loads and rebuilds memos in batches of 100 by ID list. +Memos created or deleted during the pass cannot shift a page boundary and skip a memo; memos created during the pass already carry the +current payload. + +**Recording the version.** The version is written to the basic setting only after a pass in which every memo was written. A failed +write fails the pass after all memos have been tried, and the next start runs it again. Content the extractor cannot parse is logged +and skipped, since a retry cannot fix it and must not make every start repeat the pass. The runner clones the cached basic setting +before writing, so the schema version and secret are kept. On shutdown the server cancels the pass and waits for it before closing the +store; a canceled pass does not record the version. Rebuilding is idempotent, so a repeated or concurrent pass, for example from two +replicas, is harmless. + +## Surfaces + +| Surface | Change | +| --- | --- | +| `proto/store/memo.proto`, `proto/api/memo_service.proto` | `has_inline_image = 6` on both `Property` messages; the `ListMemosRequest.filter` field list names `has_attachments` and `has_image` | +| `proto/store/instance_setting.proto` | `payload_version = 3` on `InstanceBasicSetting` | +| `markdown/markdown.go` | set `HasInlineImage` on image nodes in both extraction walks | +| `server/api/memo_service_converter.go` | map the property to the API | +| `filter/schema.go`, `filter/render.go`, `filter/README.md`, `filter/MAINTENANCE.md` | `FieldKindExists`, `RelatedRows`, the two fields, and the documented grammar | +| `store/memo.go`, `store/driver.go`, `store/db/{sqlite,mysql,postgres}/memo.go` | `RefreshMemoDerivedPayload` | +| `core/memopayload/runner.go` | `Version`, `Backfill`, and the ID-first `RunOnce` | +| `server/server.go` | start the backfill after listening; cancel and wait for it on shutdown | +| `web/src/contexts/MemoFilterContext.tsx`, `web/src/components/MemoFilters.tsx`, `web/src/hooks/useMemoFilters.ts` | `property.hasAttachments` and `property.hasImage` factors with chips, following the `property.hasLocation` precedent for a non-content field | +| `web/src/pages/MemoViews.tsx` | two view examples, "With attachments" (`has_attachments`) and "Photos" (`has_image`), and both names in the field reference list | +| `web/src/locales/*.json` | `memo.filters.has-attachments` and `memo.filters.has-image` in every locale, as the parity test requires | + +The MCP tools are generated from the OpenAPI document, so the updated filter description reaches the MCP memo listing with no change +there. The web chips exist for parity with the other property factors; today nothing in the UI sets those factors, and users reach +the fields through the search box and saved Views. A sidebar entry point is a separate UI decision. + +## Verification + +| Check | Covers | +| --- | --- | +| `go test ./markdown/... -run TestExtractInlineImage` | the flag for external, managed, reference-style, and linked images; not for code or raw HTML; both walks agree | +| `go test ./filter/...` | per-dialect goldens for the six comparison forms of both fields, rejected operators, and a SQLite behavioural test over real `memo` and `attachment` tables | +| `DRIVER= go test ./store/test/ -run TestRefreshMemoDerivedPayload` | the guarded write on SQLite, MySQL, and PostgreSQL: location and `updated_ts` kept, a case-only content edit not matched, the refreshed flag visible to `has_image` | +| `go test ./core/memopayload/...` | the version gate: rebuild once, skip when recorded, rerun when older, keep other basic setting fields, no version on cancel | +| `cd web && pnpm lint && pnpm test` | factors, chips, view examples, and locale parity | + +## Alternatives considered + +**Store `has_attachments` in the payload next to `has_link`.** Rejected. The payload properties are rebuilt from content, in one +place, on content writes. Attachment binding changes in at least six places that never touch content: setting a memo's attachments, +creating an attachment against a memo, deleting an attachment, deleting a memo, importing an archive, and storage cleanup. Each would +have to rewrite the memo row, and the rebuild would have to start querying the attachment table. The single column +`attachment.memo_id` already answers the question exactly; a copy of it can only be equal or wrong. + +**One field, `has_image`, defined by content alone.** Rejected. The most common way a photo reaches a memo is an upload that is never +referenced in the text, and a content-only flag would miss every one of those. Users asking for "memos with a picture" mean the +rendered memo, not the Markdown source. + +**Name the stored flag `has_image`.** Rejected. It is published on the API as a content property and would be false on memos that +plainly show images. `has_inline_image` says what it measures and parallels `has_link` and `has_code`. + +**Expose `has_inline_image` as a filter field too.** Deferred. Users think in "has image"; offering both invites the wrong pick. It +can be added later for "external images only" without any storage change. + +**Keep the payload version in the `markdown` package.** Rejected. The version describes how memos are stored and upgraded, which the +Markdown engine does not know about. It sits with the rebuild in `core/memopayload`. + +**Rebuild synchronously before serving.** Rejected. It is simple and race-free, but blocks startup for as long as the pass takes, which +on a large instance can exceed a container health check. The guarded write makes a background pass safe instead. + +**Rebuild with the existing `UpdateMemo`.** Rejected. It writes the whole payload as read, so a user's tag or location change made +between the read and the write would be lost. + +**Add an index on `attachment(memo_id)` now.** Deferred; see [Query cost](#query-cost). + +## Future work + +The `FieldKindExists` kind makes further relation-backed flags one schema entry each, with no storage change: + +- `has_comments`: `memo_relation` rows with `related_memo_id = memo.id AND type = 'COMMENT'`, already served by + `idx_memo_relation_related_type_memo`. This needs an equality condition alongside the prefix one. +- `has_reactions`: `reaction.memo_id`. +- `has_video`, `has_audio`: the `has_image` subquery with a different MIME prefix and no content half. + +`title`, which the payload already stores, is still not a filter field. A scalar JSON string field would allow `title.contains(...)` +and a `has_title` presence flag; it is a content fact and belongs in the payload where it already is. diff --git a/filter/MAINTENANCE.md b/filter/MAINTENANCE.md index 7c8140eb7..2b3bda2ff 100644 --- a/filter/MAINTENANCE.md +++ b/filter/MAINTENANCE.md @@ -11,6 +11,10 @@ extending or debugging the package. - Define the backing column (`Column`), JSON path (if applicable), type, and allowed operators. - Include the CEL variable in `EnvOptions`. + - Choose the kind by where the truth lives: a payload flag + (`FieldKindJSONBool`) only for facts computed from the content; a fact about + related rows, such as attachments, uses `FieldKindExists` with `Related`, + never a payload copy. 2. **Adjust parser or renderer (if needed)** - For non-scalar fields (JSON booleans, lists), add handling in `parser.go` or extend the renderer helpers. diff --git a/filter/README.md b/filter/README.md index c52c57b1d..bf39ca2a3 100644 --- a/filter/README.md +++ b/filter/README.md @@ -68,6 +68,13 @@ stmt, _ := engine.CompileToStatement(ctx, `has_task_list && visibility == "PUBLI count as absent on every dialect; any other value — including an empty object — counts as present. Only `==`/`!=` against a boolean literal (or bare/negated use) is allowed. +- **Related-Row Flags** — `has_attachments` renders as `EXISTS` over + `attachment` rows whose `memo_id` is the memo. `has_image` ORs the payload + flag `property.hasInlineImage` (Markdown image syntax in the content) with an + `EXISTS` over attachments whose `type` starts with `image/`, ignoring case. + These facts are read at query time because attachment binding changes without + the content changing; never copy them into the payload. Comparisons follow the + presence flags. - **String Matching** — `content.contains(x)`, `content.startsWith(x)`, and `content.endsWith(x)` render as case-insensitive `LIKE`/`ILIKE` with LIKE metacharacters (`%`, `_`, `\`) escaped. Available on scalar string fields whose diff --git a/filter/engine_test.go b/filter/engine_test.go index 575487b48..86bb31e10 100644 --- a/filter/engine_test.go +++ b/filter/engine_test.go @@ -755,6 +755,128 @@ func TestJSONBoolComparisonSQLiteBehavior(t *testing.T) { } } +func TestRenderExistsComparisonsPerDialect(t *testing.T) { + t.Parallel() + + engine, err := NewEngine(NewSchema()) + require.NoError(t, err) + + predicates := map[string]map[DialectName]string{ + "has_attachments": { + DialectSQLite: "EXISTS (SELECT 1 FROM `attachment` WHERE `attachment`.`memo_id` = `memo`.`id`)", + DialectMySQL: "EXISTS (SELECT 1 FROM `attachment` WHERE `attachment`.`memo_id` = `memo`.`id`)", + DialectPostgres: "EXISTS (SELECT 1 FROM attachment WHERE attachment.memo_id = memo.id)", + }, + "has_image": { + DialectSQLite: "(JSON_EXTRACT(`memo`.`payload`, '$.property.hasInlineImage') IS TRUE OR " + + "EXISTS (SELECT 1 FROM `attachment` WHERE `attachment`.`memo_id` = `memo`.`id` AND LOWER(`attachment`.`type`) LIKE 'image/%'))", + DialectMySQL: "(COALESCE(JSON_EXTRACT(`memo`.`payload`, '$.property.hasInlineImage'), CAST('false' AS JSON)) = CAST('true' AS JSON) OR " + + "EXISTS (SELECT 1 FROM `attachment` WHERE `attachment`.`memo_id` = `memo`.`id` AND LOWER(`attachment`.`type`) LIKE 'image/%'))", + DialectPostgres: "((memo.payload->'property'->>'hasInlineImage')::boolean IS TRUE OR " + + "EXISTS (SELECT 1 FROM attachment WHERE attachment.memo_id = memo.id AND LOWER(attachment.type) LIKE 'image/%'))", + }, + } + for field, byDialect := range predicates { + for dialect, predicate := range byDialect { + cases := []struct { + expr string + sql string + }{ + {field, predicate}, + {"!" + field, "NOT (" + predicate + ")"}, + {field + " == true", predicate}, + {field + " == false", "NOT (" + predicate + ")"}, + {field + " != true", "NOT (" + predicate + ")"}, + {field + " != false", predicate}, + } + for _, tc := range cases { + stmt, err := engine.CompileToStatement(context.Background(), tc.expr, RenderOptions{Dialect: dialect}) + require.NoError(t, err, dialect, tc.expr) + require.Equal(t, tc.sql, stmt.SQL, dialect, tc.expr) + require.Empty(t, stmt.Args, dialect, tc.expr) + } + } + } +} + +func TestRenderExistsRejectsUnsupportedOperators(t *testing.T) { + t.Parallel() + + engine, err := NewEngine(NewSchema()) + require.NoError(t, err) + for _, expr := range []string{`has_image > false`, `has_attachments == "yes"`, `"image" in has_image`} { + _, err := engine.CompileToStatement(context.Background(), expr, RenderOptions{Dialect: DialectSQLite}) + require.Error(t, err, expr) + } +} + +// TestExistsSQLiteBehavior pins has_attachments and has_image against real +// tables: has_attachments follows attachment.memo_id alone, and has_image is +// true for Markdown image syntax or an attached image/* file, whatever the +// MIME type's case, and false for other attachments and unbound uploads. +func TestExistsSQLiteBehavior(t *testing.T) { + db, err := sql.Open("sqlite", ":memory:") + require.NoError(t, err) + db.SetMaxOpenConns(1) + t.Cleanup(func() { require.NoError(t, db.Close()) }) + + _, err = db.Exec(`CREATE TABLE memo (id INTEGER PRIMARY KEY, payload TEXT)`) + require.NoError(t, err) + _, err = db.Exec(`CREATE TABLE attachment (id INTEGER PRIMARY KEY, memo_id INTEGER, type TEXT NOT NULL DEFAULT '')`) + require.NoError(t, err) + + for _, fixture := range []struct { + id int + payload any + }{ + {1, `{}`}, // nothing + {2, `{"property":{"hasInlineImage":true}}`}, // external image in content, no attachment + {3, `{}`}, // uploaded photo, not referenced in content + {4, `{}`}, // PDF attachment only + {5, `{"property":{"hasInlineImage":true}}`}, // managed inline image, also bound + {6, nil}, // NULL payload, upper-case MIME image + {7, `{"property":{"hasInlineImage":false}}`}, // explicit false flag, nothing attached + } { + _, err = db.Exec(`INSERT INTO memo (id, payload) VALUES (?, ?)`, fixture.id, fixture.payload) + require.NoError(t, err) + } + for _, attachment := range []struct { + memoID any + mimeType string + }{ + {3, "image/jpeg"}, + {4, "application/pdf"}, + {5, "image/png"}, + {6, "IMAGE/HEIC"}, + {nil, "image/png"}, // uploaded but not bound to any memo + } { + _, err = db.Exec(`INSERT INTO attachment (memo_id, type) VALUES (?, ?)`, attachment.memoID, attachment.mimeType) + require.NoError(t, err) + } + + engine, err := NewEngine(NewSchema()) + require.NoError(t, err) + + cases := []struct { + expr string + want []int + }{ + {`has_attachments`, []int{3, 4, 5, 6}}, + {`!has_attachments`, []int{1, 2, 7}}, + {`has_attachments == false`, []int{1, 2, 7}}, + {`has_image`, []int{2, 3, 5, 6}}, + {`!has_image`, []int{1, 4, 7}}, + {`has_image != true`, []int{1, 4, 7}}, + {`has_attachments && !has_image`, []int{4}}, + {`has_image && !has_attachments`, []int{2}}, + } + for _, tc := range cases { + stmt, err := engine.CompileToStatement(context.Background(), tc.expr, RenderOptions{Dialect: DialectSQLite}) + require.NoError(t, err, tc.expr) + require.Equal(t, tc.want, selectMemoIDs(t, db, stmt), tc.expr) + } +} + func TestCompileRejectsOversizedExpression(t *testing.T) { t.Parallel() engine, err := NewEngine(NewSchema()) diff --git a/filter/render.go b/filter/render.go index 018e5206f..f178294b3 100644 --- a/filter/render.go +++ b/filter/render.go @@ -196,6 +196,12 @@ func (r *renderer) renderFieldPredicate(cond *FieldPredicateCondition) (renderRe return renderResult{}, errors.Wrap(err, "failed to render JSON existence predicate") } return renderResult{sql: sql}, nil + case FieldKindExists: + sql, err := r.existsPredicate(field) + if err != nil { + return renderResult{}, errors.Wrap(err, "failed to render existence predicate") + } + return renderResult{sql: sql}, nil default: return renderResult{}, errors.Errorf("field %q cannot be used as a predicate", cond.Field) } @@ -215,6 +221,8 @@ func (r *renderer) renderComparison(cond *ComparisonCondition) (renderResult, er return r.renderJSONBoolComparison(field, cond.Operator, cond.Right) case FieldKindJSONExists: return r.renderJSONExistsComparison(field, cond.Operator, cond.Right) + case FieldKindExists: + return r.renderExistsComparison(field, cond.Operator, cond.Right) case FieldKindScalar: return r.renderScalarComparison(field, cond.Operator, cond.Right) default: @@ -773,6 +781,49 @@ func (r *renderer) renderJSONExistsComparison(field Field, op ComparisonOperator return renderPredicateComparison(field, op, value, existsSQL) } +// existsPredicate renders a FieldKindExists field: an EXISTS subquery over the +// related rows, OR-ed with the field's JSON boolean flag when it has one. The +// flag goes through jsonBoolPredicate, so a missing key or NULL payload reads +// as false and the whole expression stays two-valued under NOT. +func (r *renderer) existsPredicate(field Field) (string, error) { + related := field.Related + if related == nil { + return "", errors.Errorf("field %q has no related rows", field.Name) + } + where := fmt.Sprintf("%s = %s", + qualifyColumn(r.dialect, Column{Table: related.Table, Name: related.ForeignKey}), + qualifyColumn(r.dialect, related.Owner)) + if related.PrefixColumn != "" { + if related.Prefix == "" || strings.ContainsAny(related.Prefix, `'"%_\`) { + return "", errors.Errorf("field %q has an unsafe prefix %q", field.Name, related.Prefix) + } + where += fmt.Sprintf(" AND LOWER(%s) LIKE '%s%%'", + qualifyColumn(r.dialect, Column{Table: related.Table, Name: related.PrefixColumn}), + strings.ToLower(related.Prefix)) + } + exists := fmt.Sprintf("EXISTS (SELECT 1 FROM %s WHERE %s)", quoteTable(r.dialect, related.Table), where) + if len(field.JSONPath) == 0 { + return exists, nil + } + flag, err := r.jsonBoolPredicate(field) + if err != nil { + return "", err + } + return fmt.Sprintf("(%s OR %s)", flag, exists), nil +} + +func (r *renderer) renderExistsComparison(field Field, op ComparisonOperator, right ValueExpr) (renderResult, error) { + value, err := expectBool(right) + if err != nil { + return renderResult{}, errors.Wrap(err, "existence comparison requires a boolean value") + } + predicate, err := r.existsPredicate(field) + if err != nil { + return renderResult{}, errors.Wrap(err, "failed to render existence comparison") + } + return renderPredicateComparison(field, op, value, predicate) +} + // renderPredicateComparison renders `field == value` or `field != value` for a // field whose truth is fully described by predicate: the predicate itself when // the comparison asks for true, its negation when it asks for false. @@ -882,6 +933,15 @@ func sqlOperator(op ComparisonOperator) string { return string(op) } +func quoteTable(d DialectName, table string) string { + switch d { + case DialectPostgres: + return table + default: + return fmt.Sprintf("`%s`", table) + } +} + func qualifyColumn(d DialectName, col Column) string { switch d { case DialectPostgres: diff --git a/filter/schema.go b/filter/schema.go index 9ead7b256..9510f1801 100644 --- a/filter/schema.go +++ b/filter/schema.go @@ -37,6 +37,9 @@ const ( FieldKindJSONExists FieldKind = "json_exists" FieldKindJSONList FieldKind = "json_list" FieldKindVirtualAlias FieldKind = "virtual_alias" + // FieldKindExists represents a boolean derived from the presence of related + // rows in another table, optionally OR-ed with a JSON boolean flag. + FieldKindExists FieldKind = "exists" ) // Column identifies the backing table column. @@ -45,6 +48,22 @@ type Column struct { Name string } +// RelatedRows identifies the rows of another table that belong to a record, +// for fields of kind FieldKindExists. +type RelatedRows struct { + // Table is the related table. + Table string + // ForeignKey is the column of Table that holds the owner's key. + ForeignKey string + // Owner is the outer column ForeignKey refers to, such as memo.id. + Owner Column + // PrefixColumn and Prefix, when set, keep only related rows whose + // PrefixColumn starts with Prefix, ignoring case. Prefix is a schema + // constant and must not contain quotes or LIKE wildcards. + PrefixColumn string + Prefix string +} + // Field captures the schema metadata for an exposed CEL identifier. type Field struct { Name string @@ -52,6 +71,7 @@ type Field struct { Type FieldType Column Column JSONPath []string + Related *RelatedRows AliasFor string SupportsContains bool Expressions map[DialectName]string @@ -254,6 +274,45 @@ func NewSchema() Schema { CompareNeq: true, }, }, + // Attachment binding lives in attachment.memo_id and changes without the + // memo content changing, so it is read at query time, never copied into + // the memo payload. + "has_attachments": { + Name: "has_attachments", + Kind: FieldKindExists, + Type: FieldTypeBool, + Related: &RelatedRows{ + Table: "attachment", + ForeignKey: "memo_id", + Owner: Column{Table: "memo", Name: "id"}, + }, + AllowedComparisonOps: map[ComparisonOperator]bool{ + CompareEq: true, + CompareNeq: true, + }, + }, + // has_image answers "does the memo show a picture": Markdown image syntax + // in the content (the stored hasInlineImage flag) or an attached image + // file that renders in the attachment strip. Both halves are needed; the + // stored flag alone misses photos that are uploaded but not referenced. + "has_image": { + Name: "has_image", + Kind: FieldKindExists, + Type: FieldTypeBool, + Column: Column{Table: "memo", Name: "payload"}, + JSONPath: []string{"property", "hasInlineImage"}, + Related: &RelatedRows{ + Table: "attachment", + ForeignKey: "memo_id", + Owner: Column{Table: "memo", Name: "id"}, + PrefixColumn: "type", + Prefix: "image/", + }, + AllowedComparisonOps: map[ComparisonOperator]bool{ + CompareEq: true, + CompareNeq: true, + }, + }, } envOptions := []cel.EnvOption{ @@ -273,6 +332,8 @@ func NewSchema() Schema { cel.Variable("has_code", cel.BoolType), cel.Variable("has_incomplete_tasks", cel.BoolType), cel.Variable("has_location", cel.BoolType), + cel.Variable("has_attachments", cel.BoolType), + cel.Variable("has_image", cel.BoolType), cel.Variable("now", cel.TimestampType), ext.Sets(), cel.ASTValidators(cel.ValidateRegexLiterals()), diff --git a/markdown/markdown.go b/markdown/markdown.go index f76d985ca..12d7aca44 100644 --- a/markdown/markdown.go +++ b/markdown/markdown.go @@ -251,6 +251,9 @@ func (s *service) ExtractProperties(content []byte) (*storepb.MemoPayload_Proper case gast.KindCodeBlock, gast.KindFencedCodeBlock, gast.KindCodeSpan: prop.HasCode = true + case gast.KindImage: + prop.HasInlineImage = true + case east.KindTaskCheckBox: prop.HasTaskList = true if checkBox, ok := n.(*east.TaskCheckBox); ok { @@ -482,6 +485,9 @@ func (s *service) ExtractAll(content []byte) (*ExtractedData, error) { case gast.KindCodeBlock, gast.KindFencedCodeBlock, gast.KindCodeSpan: data.Property.HasCode = true + case gast.KindImage: + data.Property.HasInlineImage = true + case east.KindTaskCheckBox: data.Property.HasTaskList = true if checkBox, ok := n.(*east.TaskCheckBox); ok { diff --git a/markdown/markdown_test.go b/markdown/markdown_test.go index d34fc2ea4..43f4f0b6b 100644 --- a/markdown/markdown_test.go +++ b/markdown/markdown_test.go @@ -345,6 +345,39 @@ func TestExtractProperties(t *testing.T) { } } +// TestExtractInlineImage pins HasInlineImage to Markdown image syntax, managed +// or external, and keeps both property walks in agreement. +func TestExtractInlineImage(t *testing.T) { + tests := []struct { + name string + content string + want bool + }{ + {name: "plain text", content: "No pictures here", want: false}, + {name: "link is not an image", content: "[photo](https://example.com/a.png)", want: false}, + {name: "external image", content: "![sunset](https://example.com/sunset.jpg)", want: true}, + {name: "managed attachment image", content: "![](/file/attachments/abc123)", want: true}, + {name: "reference-style image", content: "![logo][l]\n\n[l]: https://example.com/logo.svg", want: true}, + {name: "image inside a link", content: "[![badge](https://example.com/b.svg)](https://example.com)", want: true}, + {name: "image syntax in a code span", content: "`![x](https://example.com/x.png)`", want: false}, + {name: "image syntax in a code block", content: "```\n![x](https://example.com/x.png)\n```", want: false}, + {name: "raw HTML img", content: ``, want: false}, + } + + svc := NewService() + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + props, err := svc.ExtractProperties([]byte(tt.content)) + require.NoError(t, err) + assert.Equal(t, tt.want, props.HasInlineImage, "ExtractProperties") + + data, err := svc.ExtractAll([]byte(tt.content)) + require.NoError(t, err) + assert.Equal(t, tt.want, data.Property.HasInlineImage, "ExtractAll") + }) + } +} + func TestExtractAllTitle(t *testing.T) { svc := NewService(WithTagExtension()) diff --git a/proto/api/memo_service.proto b/proto/api/memo_service.proto index 75a7e00d7..3b6ad6a3f 100644 --- a/proto/api/memo_service.proto +++ b/proto/api/memo_service.proto @@ -299,6 +299,9 @@ message Memo { // Whether the content contains an unchecked task. bool has_incomplete_tasks = 5; + + // Whether the content contains a Markdown image. + bool has_inline_image = 6; } } @@ -321,7 +324,10 @@ message ListMemosRequest { // supports == and comparisons against null, e.g. space != null), // tags (list; match with `"work" in tags`, not `tag == "work"`), // has_task_list / has_link / has_code / has_incomplete_tasks (bool), - // has_location (bool; true when the memo has a location attached). + // has_location (bool; true when the memo has a location attached), + // has_attachments (bool; true when a file is attached to the memo), + // has_image (bool; true when the content contains a Markdown image or an + // image file is attached). // Note: the time fields here are created_ts / updated_ts, which differ from // the create_time / update_time names used by order_by. // Examples: diff --git a/proto/gen/api/memo_service.pb.go b/proto/gen/api/memo_service.pb.go index 0b5416495..3e03e4d05 100644 --- a/proto/gen/api/memo_service.pb.go +++ b/proto/gen/api/memo_service.pb.go @@ -362,7 +362,10 @@ type ListMemosRequest struct { // supports == and comparisons against null, e.g. space != null), // tags (list; match with `"work" in tags`, not `tag == "work"`), // has_task_list / has_link / has_code / has_incomplete_tasks (bool), - // has_location (bool; true when the memo has a location attached). + // has_location (bool; true when the memo has a location attached), + // has_attachments (bool; true when a file is attached to the memo), + // has_image (bool; true when the content contains a Markdown image or an + // image file is attached). // // Note: the time fields here are created_ts / updated_ts, which differ from // the create_time / update_time names used by order_by. @@ -2252,8 +2255,10 @@ type Memo_Property struct { HasTaskList bool `protobuf:"varint,4,opt,name=has_task_list,json=hasTaskList,proto3" json:"has_task_list,omitempty"` // Whether the content contains an unchecked task. HasIncompleteTasks bool `protobuf:"varint,5,opt,name=has_incomplete_tasks,json=hasIncompleteTasks,proto3" json:"has_incomplete_tasks,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + // Whether the content contains a Markdown image. + HasInlineImage bool `protobuf:"varint,6,opt,name=has_inline_image,json=hasInlineImage,proto3" json:"has_inline_image,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *Memo_Property) Reset() { @@ -2321,6 +2326,13 @@ func (x *Memo_Property) GetHasIncompleteTasks() bool { return false } +func (x *Memo_Property) GetHasInlineImage() bool { + if x != nil { + return x.HasInlineImage + } + return false +} + // MemoRef identifies a memo in a relation. type MemoRelation_MemoRef struct { state protoimpl.MessageState `protogen:"open.v1"` @@ -2382,7 +2394,7 @@ var File_api_memo_service_proto protoreflect.FileDescriptor const file_api_memo_service_proto_rawDesc = "" + "\n" + - "\x16api/memo_service.proto\x12\tmemos.api\x1a\x1capi/attachment_service.proto\x1a\x10api/common.proto\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\x1a\x1fgoogle/protobuf/timestamp.proto\"\xc4\b\n" + + "\x16api/memo_service.proto\x12\tmemos.api\x1a\x1capi/attachment_service.proto\x1a\x10api/common.proto\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\x1a\x1fgoogle/protobuf/timestamp.proto\"\xee\b\n" + "\x04Memo\x12\x17\n" + "\x04name\x18\x01 \x01(\tB\x03\xe0A\bR\x04name\x120\n" + "\acreator\x18\x02 \x01(\tB\x16\xe0A\x03\xfaA\x10\n" + @@ -2408,13 +2420,14 @@ const file_api_memo_service_proto_rawDesc = "" + "\vcreate_time\x18\x10 \x01(\v2\x1a.google.protobuf.TimestampB\x03\xe0A\x01R\n" + "createTime\x12@\n" + "\vupdate_time\x18\x11 \x01(\v2\x1a.google.protobuf.TimestampB\x03\xe0A\x01R\n" + - "updateTime\x1a\xac\x01\n" + + "updateTime\x1a\xd6\x01\n" + "\bProperty\x12\x14\n" + "\x05title\x18\x01 \x01(\tR\x05title\x12\x19\n" + "\bhas_link\x18\x02 \x01(\bR\ahasLink\x12\x19\n" + "\bhas_code\x18\x03 \x01(\bR\ahasCode\x12\"\n" + "\rhas_task_list\x18\x04 \x01(\bR\vhasTaskList\x120\n" + - "\x14has_incomplete_tasks\x18\x05 \x01(\bR\x12hasIncompleteTasks:.\xeaA+\n" + + "\x14has_incomplete_tasks\x18\x05 \x01(\bR\x12hasIncompleteTasks\x12(\n" + + "\x10has_inline_image\x18\x06 \x01(\bR\x0ehasInlineImage:.\xeaA+\n" + "\x0ememos.api/Memo\x12\fmemos/{memo}*\x05memos2\x04memoB\b\n" + "\x06_spaceB\v\n" + "\t_locationB\t\n" + diff --git a/proto/gen/openapi.yaml b/proto/gen/openapi.yaml index 627ea7082..7baac2c62 100644 --- a/proto/gen/openapi.yaml +++ b/proto/gen/openapi.yaml @@ -697,7 +697,10 @@ paths: supports == and comparisons against null, e.g. space != null), tags (list; match with `"work" in tags`, not `tag == "work"`), has_task_list / has_link / has_code / has_incomplete_tasks (bool), - has_location (bool; true when the memo has a location attached). + has_location (bool; true when the memo has a location attached), + has_attachments (bool; true when a file is attached to the memo), + has_image (bool; true when the content contains a Markdown image or an + image file is attached). Note: the time fields here are created_ts / updated_ts, which differ from the create_time / update_time names used by order_by. Examples: @@ -4733,6 +4736,9 @@ components: hasIncompleteTasks: type: boolean description: Whether the content contains an unchecked task. + hasInlineImage: + type: boolean + description: Whether the content contains a Markdown image. description: Property holds properties computed from the memo content. MotionMedia: type: object diff --git a/proto/gen/store/instance_setting.pb.go b/proto/gen/store/instance_setting.pb.go index 6a986eea0..2d606c492 100644 --- a/proto/gen/store/instance_setting.pb.go +++ b/proto/gen/store/instance_setting.pb.go @@ -519,8 +519,11 @@ type InstanceBasicSetting struct { SecretKey string `protobuf:"bytes,1,opt,name=secret_key,json=secretKey,proto3" json:"secret_key,omitempty"` // The current schema version of database. SchemaVersion string `protobuf:"bytes,2,opt,name=schema_version,json=schemaVersion,proto3" json:"schema_version,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + // The memopayload.Version every memo's content-derived payload has been + // rebuilt to. A lower value makes the server rebuild them in the background. + PayloadVersion int32 `protobuf:"varint,3,opt,name=payload_version,json=payloadVersion,proto3" json:"payload_version,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *InstanceBasicSetting) Reset() { @@ -567,6 +570,13 @@ func (x *InstanceBasicSetting) GetSchemaVersion() string { return "" } +func (x *InstanceBasicSetting) GetPayloadVersion() int32 { + if x != nil { + return x.PayloadVersion + } + return 0 +} + type InstanceGeneralSetting struct { state protoimpl.MessageState `protogen:"open.v1"` // disallow_user_registration disallows user registration. @@ -1740,11 +1750,12 @@ const file_store_instance_setting_proto_rawDesc = "" + "\x0eaccess_setting\x18\t \x01(\v2\".memos.store.InstanceAccessSettingH\x00R\raccessSetting\x12[\n" + "\x14usage_limits_setting\x18\n" + " \x01(\v2'.memos.store.InstanceUsageLimitsSettingH\x00R\x12usageLimitsSettingB\a\n" + - "\x05value\"\\\n" + + "\x05value\"\x85\x01\n" + "\x14InstanceBasicSetting\x12\x1d\n" + "\n" + "secret_key\x18\x01 \x01(\tR\tsecretKey\x12%\n" + - "\x0eschema_version\x18\x02 \x01(\tR\rschemaVersion\"\xd6\x03\n" + + "\x0eschema_version\x18\x02 \x01(\tR\rschemaVersion\x12'\n" + + "\x0fpayload_version\x18\x03 \x01(\x05R\x0epayloadVersion\"\xd6\x03\n" + "\x16InstanceGeneralSetting\x12<\n" + "\x1adisallow_user_registration\x18\x01 \x01(\bR\x18disallowUserRegistration\x124\n" + "\x16disallow_password_auth\x18\x02 \x01(\bR\x14disallowPasswordAuth\x12+\n" + diff --git a/proto/gen/store/memo.pb.go b/proto/gen/store/memo.pb.go index 1b9669523..1e70c3ad8 100644 --- a/proto/gen/store/memo.pb.go +++ b/proto/gen/store/memo.pb.go @@ -89,9 +89,11 @@ type MemoPayload_Property struct { HasCode bool `protobuf:"varint,3,opt,name=has_code,json=hasCode,proto3" json:"has_code,omitempty"` HasIncompleteTasks bool `protobuf:"varint,4,opt,name=has_incomplete_tasks,json=hasIncompleteTasks,proto3" json:"has_incomplete_tasks,omitempty"` // The title extracted from the first H1 heading, if present. - Title string `protobuf:"bytes,5,opt,name=title,proto3" json:"title,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + Title string `protobuf:"bytes,5,opt,name=title,proto3" json:"title,omitempty"` + // Whether the content contains a Markdown image. + HasInlineImage bool `protobuf:"varint,6,opt,name=has_inline_image,json=hasInlineImage,proto3" json:"has_inline_image,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *MemoPayload_Property) Reset() { @@ -159,6 +161,13 @@ func (x *MemoPayload_Property) GetTitle() string { return "" } +func (x *MemoPayload_Property) GetHasInlineImage() bool { + if x != nil { + return x.HasInlineImage + } + return false +} + type MemoPayload_Location struct { state protoimpl.MessageState `protogen:"open.v1"` Placeholder string `protobuf:"bytes,1,opt,name=placeholder,proto3" json:"placeholder,omitempty"` @@ -223,17 +232,18 @@ var File_store_memo_proto protoreflect.FileDescriptor const file_store_memo_proto_rawDesc = "" + "\n" + - "\x10store/memo.proto\x12\vmemos.store\"\xb6\x03\n" + + "\x10store/memo.proto\x12\vmemos.store\"\xe0\x03\n" + "\vMemoPayload\x12=\n" + "\bproperty\x18\x01 \x01(\v2!.memos.store.MemoPayload.PropertyR\bproperty\x12=\n" + "\blocation\x18\x02 \x01(\v2!.memos.store.MemoPayload.LocationR\blocation\x12\x12\n" + - "\x04tags\x18\x03 \x03(\tR\x04tags\x1a\xac\x01\n" + + "\x04tags\x18\x03 \x03(\tR\x04tags\x1a\xd6\x01\n" + "\bProperty\x12\x19\n" + "\bhas_link\x18\x01 \x01(\bR\ahasLink\x12\"\n" + "\rhas_task_list\x18\x02 \x01(\bR\vhasTaskList\x12\x19\n" + "\bhas_code\x18\x03 \x01(\bR\ahasCode\x120\n" + "\x14has_incomplete_tasks\x18\x04 \x01(\bR\x12hasIncompleteTasks\x12\x14\n" + - "\x05title\x18\x05 \x01(\tR\x05title\x1af\n" + + "\x05title\x18\x05 \x01(\tR\x05title\x12(\n" + + "\x10has_inline_image\x18\x06 \x01(\bR\x0ehasInlineImage\x1af\n" + "\bLocation\x12 \n" + "\vplaceholder\x18\x01 \x01(\tR\vplaceholder\x12\x1a\n" + "\blatitude\x18\x02 \x01(\x01R\blatitude\x12\x1c\n" + diff --git a/proto/store/instance_setting.proto b/proto/store/instance_setting.proto index 13b9a94fb..2ec5efb76 100644 --- a/proto/store/instance_setting.proto +++ b/proto/store/instance_setting.proto @@ -49,6 +49,9 @@ message InstanceBasicSetting { string secret_key = 1; // The current schema version of database. string schema_version = 2; + // The memopayload.Version every memo's content-derived payload has been + // rebuilt to. A lower value makes the server rebuild them in the background. + int32 payload_version = 3; } message InstanceGeneralSetting { diff --git a/proto/store/memo.proto b/proto/store/memo.proto index 6e0eb7c86..7758347fa 100644 --- a/proto/store/memo.proto +++ b/proto/store/memo.proto @@ -19,6 +19,8 @@ message MemoPayload { bool has_incomplete_tasks = 4; // The title extracted from the first H1 heading, if present. string title = 5; + // Whether the content contains a Markdown image. + bool has_inline_image = 6; } message Location { diff --git a/server/api/memo_service_converter.go b/server/api/memo_service_converter.go index 591b6a116..e7ecb2adf 100644 --- a/server/api/memo_service_converter.go +++ b/server/api/memo_service_converter.go @@ -367,6 +367,7 @@ func convertMemoPropertyFromStore(property *storepb.MemoPayload_Property) *apipb HasTaskList: property.HasTaskList, HasCode: property.HasCode, HasIncompleteTasks: property.HasIncompleteTasks, + HasInlineImage: property.HasInlineImage, Title: property.Title, } } diff --git a/server/server.go b/server/server.go index c9b1341f3..372a3a650 100644 --- a/server/server.go +++ b/server/server.go @@ -8,11 +8,13 @@ import ( "net/http" "os" "path" + "sync" "time" "uuid" "github.com/pkg/errors" + "github.com/usememos/memos/core/memopayload" "github.com/usememos/memos/internal/clientip" "github.com/usememos/memos/internal/httphandler" "github.com/usememos/memos/internal/profile" @@ -47,6 +49,11 @@ type Server struct { handler http.Handler httpServer *http.Server apiService *api.APIService + + // backgroundCancel stops the startup jobs, and backgroundJobs waits for + // them, before the store closes. + backgroundCancel context.CancelFunc + backgroundJobs sync.WaitGroup } func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store) (*Server, error) { @@ -152,9 +159,29 @@ func (s *Server) Start() error { } }() + s.startBackgroundJobs() return nil } +// startBackgroundJobs runs one-off data jobs that must not delay serving. +func (s *Server) startBackgroundJobs() { + ctx, cancel := context.WithCancel(context.Background()) + s.backgroundCancel = cancel + runner := memopayload.NewRunner(s.Store, s.apiService.MarkdownService) + s.backgroundJobs.Go(func() { + if err := runner.Backfill(ctx); err != nil && ctx.Err() == nil { + slog.Error("failed to rebuild memo payloads; retrying on next start", slog.String("error", err.Error())) + } + }) +} + +func (s *Server) stopBackgroundJobs() { + if s.backgroundCancel != nil { + s.backgroundCancel() + } + s.backgroundJobs.Wait() +} + func (s *Server) Shutdown(ctx context.Context) { ctx, cancel := context.WithTimeout(ctx, shutdownTimeout) defer cancel() @@ -164,6 +191,7 @@ func (s *Server) Shutdown(ctx context.Context) { s.closeLongLivedConnections() s.shutdownHTTPServer(ctx) s.apiService.CloseUploads() + s.stopBackgroundJobs() // Close database connection. if err := s.Store.Close(); err != nil { diff --git a/store/db/mysql/memo.go b/store/db/mysql/memo.go index 7927a6cbb..eae473197 100644 --- a/store/db/mysql/memo.go +++ b/store/db/mysql/memo.go @@ -354,3 +354,20 @@ func (d *DB) DeleteMemo(ctx context.Context, delete *store.DeleteMemo) error { } return nil } + +// RefreshMemoDerivedPayload sets the payload's tags and property while the +// content is unchanged; JSON_SET keeps every other payload key. The content +// comparison is binary so a case-insensitive collation cannot match an edit. +func (d *DB) RefreshMemoDerivedPayload(ctx context.Context, refresh *store.RefreshMemoDerivedPayload) error { + tags, property, err := refresh.JSON() + if err != nil { + return err + } + if _, err := d.db.ExecContext(ctx, + "UPDATE `memo` SET `payload` = JSON_SET(COALESCE(`payload`, JSON_OBJECT()), '$.tags', CAST(? AS JSON), '$.property', CAST(? AS JSON)) WHERE `id` = ? AND CAST(`content` AS BINARY) = CAST(? AS BINARY)", + tags, property, refresh.ID, refresh.Content, + ); err != nil { + return errors.Wrap(err, "failed to refresh memo payload") + } + return nil +} diff --git a/store/db/postgres/memo.go b/store/db/postgres/memo.go index 8cf1b760f..9dcbffa2a 100644 --- a/store/db/postgres/memo.go +++ b/store/db/postgres/memo.go @@ -333,3 +333,19 @@ func (d *DB) DeleteMemo(ctx context.Context, delete *store.DeleteMemo) error { } return nil } + +// RefreshMemoDerivedPayload sets the payload's tags and property while the +// content is unchanged; jsonb_set keeps every other payload key. +func (d *DB) RefreshMemoDerivedPayload(ctx context.Context, refresh *store.RefreshMemoDerivedPayload) error { + tags, property, err := refresh.JSON() + if err != nil { + return err + } + if _, err := d.db.ExecContext(ctx, + "UPDATE memo SET payload = jsonb_set(jsonb_set(COALESCE(payload, '{}'::jsonb), '{tags}', "+placeholder(1)+"::jsonb), '{property}', "+placeholder(2)+"::jsonb) WHERE id = "+placeholder(3)+" AND content = "+placeholder(4), + tags, property, refresh.ID, refresh.Content, + ); err != nil { + return errors.Wrap(err, "failed to refresh memo payload") + } + return nil +} diff --git a/store/db/sqlite/memo.go b/store/db/sqlite/memo.go index 321eb6d7b..fc2afdf73 100644 --- a/store/db/sqlite/memo.go +++ b/store/db/sqlite/memo.go @@ -324,3 +324,19 @@ func (d *DB) DeleteMemo(ctx context.Context, delete *store.DeleteMemo) error { } return nil } + +// RefreshMemoDerivedPayload sets the payload's tags and property while the +// content is unchanged; JSON_SET keeps every other payload key. +func (d *DB) RefreshMemoDerivedPayload(ctx context.Context, refresh *store.RefreshMemoDerivedPayload) error { + tags, property, err := refresh.JSON() + if err != nil { + return err + } + if _, err := d.db.ExecContext(ctx, + "UPDATE `memo` SET `payload` = JSON_SET(COALESCE(NULLIF(`payload`, ''), '{}'), '$.tags', JSON(?), '$.property', JSON(?)) WHERE `id` = ? AND `content` = ?", + tags, property, refresh.ID, refresh.Content, + ); err != nil { + return errors.Wrap(err, "failed to refresh memo payload") + } + return nil +} diff --git a/store/driver.go b/store/driver.go index 24f77a1cb..4868a6f3d 100644 --- a/store/driver.go +++ b/store/driver.go @@ -32,6 +32,7 @@ type Driver interface { CreateMemo(ctx context.Context, create *Memo) (*Memo, error) ListMemos(ctx context.Context, find *FindMemo) ([]*Memo, error) UpdateMemo(ctx context.Context, update *UpdateMemo) error + RefreshMemoDerivedPayload(ctx context.Context, refresh *RefreshMemoDerivedPayload) error DeleteMemo(ctx context.Context, delete *DeleteMemo) error DeleteMemoWithPolicy(ctx context.Context, delete *DeleteMemoWithPolicy) (*DeleteMemoWithPolicyResult, error) // CountUserMemos counts the memos a user created, comments included, in every row status and Space. diff --git a/store/memo.go b/store/memo.go index 313de9639..a908f3317 100644 --- a/store/memo.go +++ b/store/memo.go @@ -3,10 +3,12 @@ package store import ( "context" "database/sql" - "errors" + "encoding/json" + + "github.com/pkg/errors" + "google.golang.org/protobuf/encoding/protojson" "github.com/usememos/memos/internal/identifier" - storepb "github.com/usememos/memos/proto/gen/store" ) @@ -105,6 +107,38 @@ type FindMemoPayload struct { HasIncompleteTasks bool } +// RefreshMemoDerivedPayload replaces the content-derived part of a memo's +// payload, its tags and property, computed from Content. +type RefreshMemoDerivedPayload struct { + ID int32 + // Content is the memo content the tags and property were computed from. + // The refresh applies only while the stored content still equals it. + Content string + Tags []string + Property *storepb.MemoPayload_Property +} + +// JSON returns the tags and property encoded the way memo payloads are stored. +func (r *RefreshMemoDerivedPayload) JSON() (tags string, property string, err error) { + tagList := r.Tags + if tagList == nil { + tagList = []string{} + } + tagBytes, err := json.Marshal(tagList) + if err != nil { + return "", "", errors.Wrap(err, "failed to marshal memo tags") + } + prop := r.Property + if prop == nil { + prop = &storepb.MemoPayload_Property{} + } + propertyBytes, err := protojson.Marshal(prop) + if err != nil { + return "", "", errors.Wrap(err, "failed to marshal memo property") + } + return string(tagBytes), string(propertyBytes), nil +} + type UpdateMemo struct { ID int32 UID *string @@ -267,6 +301,15 @@ func (s *Store) UpdateMemo(ctx context.Context, update *UpdateMemo) error { return s.driver.UpdateMemo(ctx, update) } +// RefreshMemoDerivedPayload rewrites a memo's payload tags and property in +// place, and only if the memo's content has not changed since it was read. It +// leaves every other payload field, such as the location, and updated_ts as +// they are, so a background rebuild can never undo a concurrent edit. A memo +// that was edited or deleted in the meantime is left alone. +func (s *Store) RefreshMemoDerivedPayload(ctx context.Context, refresh *RefreshMemoDerivedPayload) error { + return s.driver.RefreshMemoDerivedPayload(ctx, refresh) +} + func validateMemoWritePolicy(policy *MemoWritePolicy) error { if policy == nil { return nil diff --git a/store/test/memo_payload_refresh_test.go b/store/test/memo_payload_refresh_test.go new file mode 100644 index 000000000..e6e55316f --- /dev/null +++ b/store/test/memo_payload_refresh_test.go @@ -0,0 +1,83 @@ +package test + +import ( + "context" + "testing" + + "github.com/stretchr/testify/require" + + storepb "github.com/usememos/memos/proto/gen/store" + "github.com/usememos/memos/store" +) + +// TestRefreshMemoDerivedPayload pins the guarded rebuild write: it replaces +// tags and property only while the content is unchanged, and keeps the +// location and updated_ts, so a background rebuild cannot undo an edit. +func TestRefreshMemoDerivedPayload(t *testing.T) { + t.Parallel() + ctx := context.Background() + ts := NewTestingStore(ctx, t) + user, err := createTestingHostUser(ctx, ts) + require.NoError(t, err) + + location := &storepb.MemoPayload_Location{Placeholder: "Harbour", Latitude: 1.5, Longitude: 2.5} + memo, err := ts.CreateMemo(ctx, &store.Memo{ + UID: "payload-refresh", + CreatorID: user.ID, + Content: "Ünïcode ![sunset](https://example.com/s.jpg) #trip", + Visibility: store.Private, + // Fixed past timestamps, so a refresh that touched updated_ts within + // the same second as the fixture could not go unnoticed. + CreatedTs: 1700000000, + UpdatedTs: 1700000100, + Payload: &storepb.MemoPayload{ + Tags: []string{"stale"}, + Property: &storepb.MemoPayload_Property{HasCode: true}, + Location: location, + }, + }) + require.NoError(t, err) + + t.Run("matching content refreshes tags and property only", func(t *testing.T) { + require.NoError(t, ts.RefreshMemoDerivedPayload(ctx, &store.RefreshMemoDerivedPayload{ + ID: memo.ID, + Content: memo.Content, + Tags: []string{"trip"}, + Property: &storepb.MemoPayload_Property{HasInlineImage: true}, + })) + got, err := ts.GetMemo(ctx, &store.FindMemo{ID: &memo.ID}) + require.NoError(t, err) + require.Equal(t, []string{"trip"}, got.Payload.Tags) + require.True(t, got.Payload.Property.HasInlineImage) + require.False(t, got.Payload.Property.HasCode) + require.Equal(t, location.Placeholder, got.Payload.Location.GetPlaceholder()) + require.InDelta(t, location.Latitude, got.Payload.Location.GetLatitude(), 1e-9) + require.Equal(t, int64(1700000100), got.UpdatedTs) + + images, err := ts.ListMemos(ctx, &store.FindMemo{IDList: []int32{memo.ID}, Filters: []string{"has_image"}}) + require.NoError(t, err) + require.Len(t, images, 1, "the refreshed flag must be visible to the filter") + }) + + t.Run("edited content is left alone", func(t *testing.T) { + require.NoError(t, ts.RefreshMemoDerivedPayload(ctx, &store.RefreshMemoDerivedPayload{ + ID: memo.ID, + Content: "ünïcode ![sunset](https://example.com/s.jpg) #trip", + Tags: []string{"wrong"}, + Property: &storepb.MemoPayload_Property{HasLink: true}, + })) + got, err := ts.GetMemo(ctx, &store.FindMemo{ID: &memo.ID}) + require.NoError(t, err) + require.Equal(t, []string{"trip"}, got.Payload.Tags, "a case-only difference must not match") + require.False(t, got.Payload.Property.HasLink) + }) + + t.Run("empty tags and property clear the stored values", func(t *testing.T) { + require.NoError(t, ts.RefreshMemoDerivedPayload(ctx, &store.RefreshMemoDerivedPayload{ID: memo.ID, Content: memo.Content})) + got, err := ts.GetMemo(ctx, &store.FindMemo{ID: &memo.ID}) + require.NoError(t, err) + require.Empty(t, got.Payload.Tags) + require.False(t, got.Payload.GetProperty().GetHasInlineImage()) + require.Equal(t, location.Placeholder, got.Payload.Location.GetPlaceholder()) + }) +} diff --git a/web/src/components/MemoFilters.tsx b/web/src/components/MemoFilters.tsx index ace90b2b4..f5b24d8da 100644 --- a/web/src/components/MemoFilters.tsx +++ b/web/src/components/MemoFilters.tsx @@ -7,9 +7,11 @@ import { CodeIcon, EyeIcon, HashIcon, + ImageIcon, LinkIcon, type LucideIcon, MapPinIcon, + PaperclipIcon, SearchIcon, XIcon, } from "lucide-react"; @@ -79,6 +81,14 @@ const FILTER_CONFIGS: Record = { icon: MapPinIcon, getLabel: (_, t) => t("memo.filters.has-location"), }, + "property.hasAttachments": { + icon: PaperclipIcon, + getLabel: (_, t) => t("memo.filters.has-attachments"), + }, + "property.hasImage": { + icon: ImageIcon, + getLabel: (_, t) => t("memo.filters.has-image"), + }, }; interface FilterChipProps { diff --git a/web/src/contexts/MemoFilterContext.tsx b/web/src/contexts/MemoFilterContext.tsx index d3e1b6b29..95d3c8b29 100644 --- a/web/src/contexts/MemoFilterContext.tsx +++ b/web/src/contexts/MemoFilterContext.tsx @@ -12,7 +12,9 @@ export type FilterFactor = | "property.hasLink" | "property.hasTaskList" | "property.hasCode" - | "property.hasLocation"; + | "property.hasLocation" + | "property.hasAttachments" + | "property.hasImage"; export interface MemoFilter { factor: FilterFactor; diff --git a/web/src/hooks/useMemoFilters.ts b/web/src/hooks/useMemoFilters.ts index 2db37f70c..1b3bd28e2 100644 --- a/web/src/hooks/useMemoFilters.ts +++ b/web/src/hooks/useMemoFilters.ts @@ -68,6 +68,10 @@ export const buildMemoFilter = ({ conditions.push(`has_code`); } else if (filter.factor === "property.hasLocation") { conditions.push(`has_location`); + } else if (filter.factor === "property.hasAttachments") { + conditions.push(`has_attachments`); + } else if (filter.factor === "property.hasImage") { + conditions.push(`has_image`); } else if (filter.factor === "displayTime") { const range = getLocalDayTimestampRange(filter.value); if (range) { diff --git a/web/src/locales/ar.json b/web/src/locales/ar.json index aa1116b5e..b9ea1aa4d 100644 --- a/web/src/locales/ar.json +++ b/web/src/locales/ar.json @@ -283,7 +283,9 @@ "delete-confirm-description": "هذا الإجراء لا رجعة فيه. ستتم إزالة المرفقات والروابط والمراجع أيضًا.", "direction": "الاتجاه", "filters": { + "has-attachments": "يحتوي على مرفقات", "has-code": "يحتوي على كود", + "has-image": "يحتوي على صورة", "has-link": "يحتوي على رابط", "has-location": "يحتوي على موقع", "has-task-list": "يحتوي على قائمة مهام" diff --git a/web/src/locales/az.json b/web/src/locales/az.json index a18aa9601..7fb5423f0 100644 --- a/web/src/locales/az.json +++ b/web/src/locales/az.json @@ -392,7 +392,9 @@ "delete-confirm-description": "Bu əməliyyat geri qaytarıla bilməz. Qoşmalar, keçidlər və istinadlar da çıxarılacaq.", "direction": "İstiqamət", "filters": { + "has-attachments": "Qoşma var", "has-code": "Kod var", + "has-image": "Şəkil var", "has-link": "Keçid var", "has-location": "Məkan var", "has-task-list": "Tapşırıq siyahısı var" diff --git a/web/src/locales/bg.json b/web/src/locales/bg.json index f24971018..8d189fe60 100644 --- a/web/src/locales/bg.json +++ b/web/src/locales/bg.json @@ -327,7 +327,9 @@ "delete-confirm-description": "Това действие е необратимо. Прикачените файлове, връзките и препратките също ще бъдат премахнати.", "direction": "Посока", "filters": { + "has-attachments": "има прикачени файлове", "has-code": "hasCode", + "has-image": "има изображение", "has-link": "hasLink", "has-location": "има местоположение", "has-task-list": "hasTaskList" diff --git a/web/src/locales/ca.json b/web/src/locales/ca.json index 6c9de63c1..5f7dff2e2 100644 --- a/web/src/locales/ca.json +++ b/web/src/locales/ca.json @@ -288,7 +288,9 @@ "delete-confirm-description": "Aquesta acció és irreversible. Els adjunts, enllaços i referències també s'eliminaran.", "direction": "Direcció", "filters": { + "has-attachments": "té adjunts", "has-code": "téCodi", + "has-image": "té imatge", "has-link": "téEnllaç", "has-location": "té ubicació", "has-task-list": "téLlistaTasques" diff --git a/web/src/locales/cs.json b/web/src/locales/cs.json index 665fa9c3a..06af1b145 100644 --- a/web/src/locales/cs.json +++ b/web/src/locales/cs.json @@ -288,7 +288,9 @@ "delete-confirm-description": "Tato akce je nevratná. Přílohy, odkazy a reference budou také odstraněny.", "direction": "Směr", "filters": { + "has-attachments": "má přílohy", "has-code": "maKod", + "has-image": "má obrázek", "has-link": "maOdkaz", "has-location": "má polohu", "has-task-list": "maSeznamUkolu" diff --git a/web/src/locales/da.json b/web/src/locales/da.json index 0ea360304..a3065fdd4 100644 --- a/web/src/locales/da.json +++ b/web/src/locales/da.json @@ -327,7 +327,9 @@ "delete-confirm-description": "Denne handling er irreversibel. Vedhæftede filer, links og referencer vil også blive fjernet.", "direction": "Retning", "filters": { + "has-attachments": "har vedhæftninger", "has-code": "hasCode", + "has-image": "har billede", "has-link": "harLink", "has-location": "har placering", "has-task-list": "har Opgaveliste" diff --git a/web/src/locales/de.json b/web/src/locales/de.json index 3c2924930..62d3c395e 100644 --- a/web/src/locales/de.json +++ b/web/src/locales/de.json @@ -288,7 +288,9 @@ "delete-confirm-description": "Dieser Vorgang ist nicht rückgängig zu machen. Anhänge, Links und Verknüpfungen werden ebenfalls gelöscht.", "direction": "Richtung", "filters": { + "has-attachments": "hat Anhänge", "has-code": "hatCode", + "has-image": "hat Bild", "has-link": "hatLink", "has-location": "hat Standort", "has-task-list": "hatAufgabenliste" diff --git a/web/src/locales/el.json b/web/src/locales/el.json index cef04dc1d..a0737d8f5 100644 --- a/web/src/locales/el.json +++ b/web/src/locales/el.json @@ -327,7 +327,9 @@ "delete-confirm-description": "Αυτή η ενέργεια είναι μη αναστρέψιμη. Τα συνημμένα, οι σύνδεσμοι και οι αναφορές θα αφαιρεθούν επίσης.", "direction": "Κατεύθυνση", "filters": { + "has-attachments": "έχει συνημμένα", "has-code": "έχει Κώδικα", + "has-image": "έχει εικόνα", "has-link": "έχει Σύνδεσμο", "has-location": "έχει τοποθεσία", "has-task-list": "hasTaskList" diff --git a/web/src/locales/en-GB.json b/web/src/locales/en-GB.json index 4ad556b6c..acfceb099 100644 --- a/web/src/locales/en-GB.json +++ b/web/src/locales/en-GB.json @@ -288,7 +288,9 @@ "delete-confirm-description": "This action is irreversible. Attachments, links, and references will also be removed.", "direction": "Direction", "filters": { + "has-attachments": "hasAttachments", "has-code": "hasCode", + "has-image": "hasImage", "has-link": "hasLink", "has-location": "hasLocation", "has-task-list": "hasTaskList" diff --git a/web/src/locales/en.json b/web/src/locales/en.json index 13826c211..e057926a5 100644 --- a/web/src/locales/en.json +++ b/web/src/locales/en.json @@ -392,7 +392,9 @@ "delete-confirm-description": "This action is irreversible. Attachments, links, and references will also be removed.", "direction": "Direction", "filters": { + "has-attachments": "hasAttachments", "has-code": "hasCode", + "has-image": "hasImage", "has-link": "hasLink", "has-location": "hasLocation", "has-task-list": "hasTaskList" diff --git a/web/src/locales/es.json b/web/src/locales/es.json index 7e20e2972..f3be21e3c 100644 --- a/web/src/locales/es.json +++ b/web/src/locales/es.json @@ -288,7 +288,9 @@ "delete-confirm-description": "Esta acción es irreversible. Los adjuntos, enlaces y referencias también se eliminarán.", "direction": "Dirección", "filters": { + "has-attachments": "tiene adjuntos", "has-code": "tieneCódigo", + "has-image": "tiene imagen", "has-link": "tieneEnlace", "has-location": "tiene ubicación", "has-task-list": "tieneListaTareas" diff --git a/web/src/locales/et.json b/web/src/locales/et.json index 114dd55d3..a3f673c17 100644 --- a/web/src/locales/et.json +++ b/web/src/locales/et.json @@ -327,7 +327,9 @@ "delete-confirm-description": "See toiming on pöördumatu. Samuti eemaldatakse manused, lingid ja viited.", "direction": "Suund", "filters": { + "has-attachments": "on manuseid", "has-code": "hasCode", + "has-image": "on pilt", "has-link": "hasLink", "has-location": "on asukoht", "has-task-list": "hasTaskList" diff --git a/web/src/locales/fa.json b/web/src/locales/fa.json index 41dcff7b2..8c9887e38 100644 --- a/web/src/locales/fa.json +++ b/web/src/locales/fa.json @@ -283,7 +283,9 @@ "delete-confirm-description": "این عمل غیرقابل بازگشت است. پیوست‌ها، پیوندها و ارجاعات نیز حذف خواهند شد.", "direction": "جهت", "filters": { + "has-attachments": "دارای پیوست", "has-code": "دارای کد", + "has-image": "دارای تصویر", "has-link": "دارای پیوند", "has-location": "دارای موقعیت", "has-task-list": "دارای لیست کارها" diff --git a/web/src/locales/fi.json b/web/src/locales/fi.json index 92345c951..5442c138d 100644 --- a/web/src/locales/fi.json +++ b/web/src/locales/fi.json @@ -327,7 +327,9 @@ "delete-confirm-description": "Tämä toimenpide on peruuttamaton. Myös liitteet, linkit ja viittaukset poistetaan.", "direction": "Suunta", "filters": { + "has-attachments": "on liitteitä", "has-code": "hasCode", + "has-image": "on kuva", "has-link": "hasLink", "has-location": "on sijainti", "has-task-list": "hasTaskList" diff --git a/web/src/locales/fr.json b/web/src/locales/fr.json index 495490589..a0624dd95 100644 --- a/web/src/locales/fr.json +++ b/web/src/locales/fr.json @@ -288,7 +288,9 @@ "delete-confirm-description": "Cette action est irréversible. Les pièces jointes, liens et références seront également supprimés.", "direction": "Direction", "filters": { + "has-attachments": "a des pièces jointes", "has-code": "aCode", + "has-image": "a une image", "has-link": "aLien", "has-location": "a une localisation", "has-task-list": "aListeTâches" diff --git a/web/src/locales/gl.json b/web/src/locales/gl.json index 1bdecd2f4..6bc44c5fe 100644 --- a/web/src/locales/gl.json +++ b/web/src/locales/gl.json @@ -288,7 +288,9 @@ "delete-confirm-description": "Esta acción non se pode desfacer. Vanse eliminar tamén as ligazóns e referencias.", "direction": "Dirección", "filters": { + "has-attachments": "ten anexos", "has-code": "hasCode", + "has-image": "ten imaxe", "has-link": "hasLink", "has-location": "ten localización", "has-task-list": "hasTaskList" diff --git a/web/src/locales/he.json b/web/src/locales/he.json index 7c6eaf019..fdad66d82 100644 --- a/web/src/locales/he.json +++ b/web/src/locales/he.json @@ -360,7 +360,9 @@ "delete-confirm-description": "פעולה זו אינה הפיכה. גם קבצים מצורפים, קישורים והפניות יוסרו.", "direction": "כיוון", "filters": { + "has-attachments": "מכיל קבצים מצורפים", "has-code": "מכיל קוד", + "has-image": "מכיל תמונה", "has-link": "מכיל קישור", "has-location": "מכיל מיקום", "has-task-list": "מכיל רשימת משימות" diff --git a/web/src/locales/hi.json b/web/src/locales/hi.json index 55aa8ed87..6faa2229f 100644 --- a/web/src/locales/hi.json +++ b/web/src/locales/hi.json @@ -283,7 +283,9 @@ "delete-confirm-description": "यह कार्रवाई वापस नहीं की जा सकती। संलग्नक, लिंक और संदर्भ भी हटा दिए जाएंगे।", "direction": "दिशा", "filters": { + "has-attachments": "अटैचमेंट है", "has-code": "कोड है", + "has-image": "छवि है", "has-link": "लिंक है", "has-location": "स्थान है", "has-task-list": "टास्क लिस्ट है" diff --git a/web/src/locales/hr.json b/web/src/locales/hr.json index 73b463796..d4e5127fc 100644 --- a/web/src/locales/hr.json +++ b/web/src/locales/hr.json @@ -288,7 +288,9 @@ "delete-confirm-description": "Ova akcija je nepovratna. Privici, linkovi i reference će također biti uklonjeni.", "direction": "Smjer", "filters": { + "has-attachments": "ima privitke", "has-code": "imaKod", + "has-image": "ima sliku", "has-link": "imaLink", "has-location": "ima lokaciju", "has-task-list": "imaZadatke" diff --git a/web/src/locales/hu.json b/web/src/locales/hu.json index 25dce3e8f..feae1dbe5 100644 --- a/web/src/locales/hu.json +++ b/web/src/locales/hu.json @@ -288,7 +288,9 @@ "delete-confirm-description": "Ez a művelet visszafordíthatatlan. A mellékletek, hivatkozások és referenciák is törlődnek.", "direction": "Irány", "filters": { + "has-attachments": "van melléklet", "has-code": "vanKód", + "has-image": "van kép", "has-link": "vanLink", "has-location": "van helyadat", "has-task-list": "vanFeladatLista" diff --git a/web/src/locales/id.json b/web/src/locales/id.json index 3fd3c4f6e..4eae90b5e 100644 --- a/web/src/locales/id.json +++ b/web/src/locales/id.json @@ -283,7 +283,9 @@ "delete-confirm-description": "Tindakan ini tidak dapat dibatalkan. Lampiran, tautan, dan referensi juga akan dihapus.", "direction": "Arah", "filters": { + "has-attachments": "Memiliki lampiran", "has-code": "Memiliki kode", + "has-image": "Memiliki gambar", "has-link": "Memiliki tautan", "has-location": "Memiliki lokasi", "has-task-list": "Memiliki daftar tugas" diff --git a/web/src/locales/it.json b/web/src/locales/it.json index 98bbbe534..775f80cbb 100644 --- a/web/src/locales/it.json +++ b/web/src/locales/it.json @@ -288,7 +288,9 @@ "delete-confirm-description": "Questa azione è irreversibile. Allegati, link e riferimenti saranno rimossi.", "direction": "Direzione", "filters": { + "has-attachments": "ha allegati", "has-code": "haCodice", + "has-image": "ha un'immagine", "has-link": "haLink", "has-location": "ha una posizione", "has-task-list": "haListaCompiti" diff --git a/web/src/locales/ja.json b/web/src/locales/ja.json index 98016ef10..7421858ce 100644 --- a/web/src/locales/ja.json +++ b/web/src/locales/ja.json @@ -288,7 +288,9 @@ "delete-confirm-description": "この操作は元に戻せません。添付ファイル、リンク、参照も削除されます。", "direction": "並び順", "filters": { + "has-attachments": "添付ファイルあり", "has-code": "コードあり", + "has-image": "画像あり", "has-link": "リンクあり", "has-location": "位置情報あり", "has-task-list": "タスクリストあり" diff --git a/web/src/locales/ka-GE.json b/web/src/locales/ka-GE.json index 926ab9749..98adec48b 100644 --- a/web/src/locales/ka-GE.json +++ b/web/src/locales/ka-GE.json @@ -288,7 +288,9 @@ "delete-confirm-description": "ეს ქმედება შეუქცევადია. დანართები, ლინკები და რეფერენციებიც წაიშლება.", "direction": "მიმართულება", "filters": { + "has-attachments": "აქვს დანართები", "has-code": "კოდიარის", + "has-image": "აქვს სურათი", "has-link": "ლინკიარის", "has-location": "აქვს მდებარეობა", "has-task-list": "სიისამოცანებია" diff --git a/web/src/locales/ko.json b/web/src/locales/ko.json index 407eb8b36..15f471a62 100644 --- a/web/src/locales/ko.json +++ b/web/src/locales/ko.json @@ -283,7 +283,9 @@ "delete-confirm-description": "이 행동은 되돌릴 수 없으며, 첨부파일, 링크 및 참조가 삭제됩니다.", "direction": "정렬", "filters": { + "has-attachments": "첨부 파일 있음", "has-code": "코드있음", + "has-image": "이미지 있음", "has-link": "링크있음", "has-location": "위치 있음", "has-task-list": "할일목록있음" diff --git a/web/src/locales/lt.json b/web/src/locales/lt.json index bcb857f93..72118d5e0 100644 --- a/web/src/locales/lt.json +++ b/web/src/locales/lt.json @@ -327,7 +327,9 @@ "delete-confirm-description": "Šis veiksmas yra negrįžtamas. Taip pat bus pašalinti priedai, nuorodos ir nuorodos.", "direction": "Kryptis", "filters": { + "has-attachments": "turi priedų", "has-code": "hasCode", + "has-image": "turi paveikslėlį", "has-link": "hasLink", "has-location": "turi vietą", "has-task-list": "turiTaskList" diff --git a/web/src/locales/lv.json b/web/src/locales/lv.json index 165d4808c..576e3a61b 100644 --- a/web/src/locales/lv.json +++ b/web/src/locales/lv.json @@ -327,7 +327,9 @@ "delete-confirm-description": "Šī darbība ir neatgriezeniska. Tiks noņemti arī pielikumi, saites un atsauces.", "direction": "Virziens", "filters": { + "has-attachments": "ir pielikumi", "has-code": "hasCode", + "has-image": "ir attēls", "has-link": "hasLink", "has-location": "ir atrašanās vieta", "has-task-list": "hasTaskList" diff --git a/web/src/locales/mr.json b/web/src/locales/mr.json index e589e8d7d..e001cfddd 100644 --- a/web/src/locales/mr.json +++ b/web/src/locales/mr.json @@ -283,7 +283,9 @@ "delete-confirm-description": "ही क्रिया अपरिवर्तनीय आहे. संलग्नक, लिंक आणि संदर्भ देखील काढून टाकले जातील.", "direction": "दिशा", "filters": { + "has-attachments": "संलग्नक आहे", "has-code": "कोड आहे", + "has-image": "प्रतिमा आहे", "has-link": "लिंक आहे", "has-location": "स्थान आहे", "has-task-list": "कार्यसूची आहे" diff --git a/web/src/locales/nb.json b/web/src/locales/nb.json index cae29bf35..9a59940d9 100644 --- a/web/src/locales/nb.json +++ b/web/src/locales/nb.json @@ -288,7 +288,9 @@ "delete-confirm-description": "Denne handlingen kan ikke angres. Vedlegg, lenker og referanser vil også bli fjernet.", "direction": "Retning", "filters": { + "has-attachments": "har vedlegg", "has-code": "harKode", + "has-image": "har bilde", "has-link": "harLink", "has-location": "har posisjon", "has-task-list": "harGjøremålsListe" diff --git a/web/src/locales/nl.json b/web/src/locales/nl.json index 06c2fc64b..75b9f5b41 100644 --- a/web/src/locales/nl.json +++ b/web/src/locales/nl.json @@ -288,7 +288,9 @@ "delete-confirm-description": "Deze actie is onomkeerelijk. Bijlagen, links en referenties worden ook verwijderd.", "direction": "Richting", "filters": { + "has-attachments": "heeft bijlagen", "has-code": "heeftCode", + "has-image": "heeft afbeelding", "has-link": "heeftLink", "has-location": "heeft locatie", "has-task-list": "heeftTakenlijst" diff --git a/web/src/locales/nn.json b/web/src/locales/nn.json index cb4fa911c..bc8b91044 100644 --- a/web/src/locales/nn.json +++ b/web/src/locales/nn.json @@ -388,7 +388,9 @@ "delete-confirm-description": "Denne handlinga kan ikkje gjerast om. Vedlegg, lenkjer og tilvisingar vert òg fjerna.", "direction": "Retning", "filters": { + "has-attachments": "Har vedlegg", "has-code": "Har kode", + "has-image": "Har bilete", "has-link": "Har lenkje", "has-location": "Har stad", "has-task-list": "Har gjeremålsliste" diff --git a/web/src/locales/pl.json b/web/src/locales/pl.json index 5e719ef5c..09f94f734 100644 --- a/web/src/locales/pl.json +++ b/web/src/locales/pl.json @@ -288,7 +288,9 @@ "delete-confirm-description": "Czy na pewno chcesz usunąć tę notatkę? Załączniki, linki i odnośniki także będą usunięte. TA AKCJA JEST NIEODWRACALNA", "direction": "Kierunek", "filters": { + "has-attachments": "ma załączniki", "has-code": "ma kod", + "has-image": "ma obraz", "has-link": "ma link", "has-location": "ma lokalizację", "has-task-list": "ma listę zadań" diff --git a/web/src/locales/pt-BR.json b/web/src/locales/pt-BR.json index 9e0e5aa62..9038da248 100644 --- a/web/src/locales/pt-BR.json +++ b/web/src/locales/pt-BR.json @@ -283,7 +283,9 @@ "delete-confirm-description": "Esta ação é irreversível. Anexos, links e referências também serão removidos.", "direction": "Sentido", "filters": { + "has-attachments": "tem anexos", "has-code": "temCódigo", + "has-image": "tem imagem", "has-link": "temLink", "has-location": "tem localização", "has-task-list": "temListaDeTarefas" diff --git a/web/src/locales/pt-PT.json b/web/src/locales/pt-PT.json index 26a0f34c6..2af9d8392 100644 --- a/web/src/locales/pt-PT.json +++ b/web/src/locales/pt-PT.json @@ -288,7 +288,9 @@ "delete-confirm-description": "Esta ação é irreversível. Os anexos, links e referências também serão removidos.", "direction": "Direção", "filters": { + "has-attachments": "tem anexos", "has-code": "temCódigo", + "has-image": "tem imagem", "has-link": "temLink", "has-location": "tem localização", "has-task-list": "temListaDeTarefas" diff --git a/web/src/locales/ro.json b/web/src/locales/ro.json index e4b091f82..6a728067f 100644 --- a/web/src/locales/ro.json +++ b/web/src/locales/ro.json @@ -327,7 +327,9 @@ "delete-confirm-description": "Această acțiune este ireversibilă. Atașamentele, linkurile și referințele vor fi, de asemenea, eliminate.", "direction": "Direcţie", "filters": { + "has-attachments": "are atașamente", "has-code": "areCode", + "has-image": "are imagine", "has-link": "areLink", "has-location": "are locație", "has-task-list": "areTaskList" diff --git a/web/src/locales/ru.json b/web/src/locales/ru.json index c50986fab..3c75cdb4f 100644 --- a/web/src/locales/ru.json +++ b/web/src/locales/ru.json @@ -288,7 +288,9 @@ "delete-confirm-description": "Это действие нельзя отменить. Вложения, ссылки и упоминания также будут удалены.", "direction": "Сортировка", "filters": { + "has-attachments": "есть вложения", "has-code": "hasCode", + "has-image": "есть изображение", "has-link": "hasLink", "has-location": "есть местоположение", "has-task-list": "hasTaskList" diff --git a/web/src/locales/sk.json b/web/src/locales/sk.json index 6d47f2316..822f8e3f0 100644 --- a/web/src/locales/sk.json +++ b/web/src/locales/sk.json @@ -327,7 +327,9 @@ "delete-confirm-description": "Táto akcia je nezvratná. Odstránia sa aj prílohy, odkazy a referencie.", "direction": "Smer", "filters": { + "has-attachments": "má prílohy", "has-code": "hasCode", + "has-image": "má obrázok", "has-link": "hasLink", "has-location": "má polohu", "has-task-list": "hasTaskList" diff --git a/web/src/locales/sl.json b/web/src/locales/sl.json index ed4d2f8da..9ac41e7cb 100644 --- a/web/src/locales/sl.json +++ b/web/src/locales/sl.json @@ -288,7 +288,9 @@ "delete-confirm-description": "To dejanje je nepovratno. Priložene datoteke, povezave in reference bodo prav tako odstranjene.", "direction": "Smer", "filters": { + "has-attachments": "ima priloge", "has-code": "imaKodo", + "has-image": "ima sliko", "has-link": "imaPovezavo", "has-location": "imaLokacijo", "has-task-list": "imaSeznamOpravil" diff --git a/web/src/locales/sr.json b/web/src/locales/sr.json index c46acd8fa..5920aca33 100644 --- a/web/src/locales/sr.json +++ b/web/src/locales/sr.json @@ -327,7 +327,9 @@ "delete-confirm-description": "Ова акција је неповратна. Прилози, везе и референце ће такође бити уклоњени.", "direction": "Правац", "filters": { + "has-attachments": "има прилоге", "has-code": "хасЦоде", + "has-image": "има слику", "has-link": "хасЛинк", "has-location": "има локацију", "has-task-list": "хасТаскЛист" diff --git a/web/src/locales/sv.json b/web/src/locales/sv.json index dfb05ffbd..29c9ff63a 100644 --- a/web/src/locales/sv.json +++ b/web/src/locales/sv.json @@ -288,7 +288,9 @@ "delete-confirm-description": "Denna åtgärd är oåterkallelig. Bilagor, länk och referenser kommer också att tas bort.", "direction": "Riktning", "filters": { + "has-attachments": "har bilagor", "has-code": "harKod", + "has-image": "har bild", "has-link": "harLänk", "has-location": "har plats", "has-task-list": "harAttGöraLista" diff --git a/web/src/locales/th.json b/web/src/locales/th.json index 32b6b7f20..9cf612d1e 100644 --- a/web/src/locales/th.json +++ b/web/src/locales/th.json @@ -283,7 +283,9 @@ "delete-confirm-description": "การดำเนินการนี้ไม่สามารถย้อนกลับได้ ไฟล์แนบ ลิงก์ และการอ้างอิงจะถูกลบออกด้วย", "direction": "ทิศทาง", "filters": { + "has-attachments": "มีไฟล์แนบ", "has-code": "มีโค้ด", + "has-image": "มีรูปภาพ", "has-link": "มีลิงก์", "has-location": "มีตำแหน่ง", "has-task-list": "มีรายการที่ต้องทำ" diff --git a/web/src/locales/tr.json b/web/src/locales/tr.json index 57e11cfa0..a88b1f17c 100644 --- a/web/src/locales/tr.json +++ b/web/src/locales/tr.json @@ -320,7 +320,9 @@ "delete-confirm-description": "Bu işlem geri alınamaz. Ekler, bağlantılar ve referanslar da kaldırılacaktır.", "direction": "Yön", "filters": { + "has-attachments": "Ek içerir", "has-code": "Kod içerir", + "has-image": "Görsel içerir", "has-link": "Bağlantı içerir", "has-location": "Konum içerir", "has-task-list": "Yapılacaklar listesi içerir" diff --git a/web/src/locales/uk.json b/web/src/locales/uk.json index d73bb09b6..75b108fd5 100644 --- a/web/src/locales/uk.json +++ b/web/src/locales/uk.json @@ -288,7 +288,9 @@ "delete-confirm-description": "Ця дія є незворотною. Вкладення, посилання та посилання також буде видалено.", "direction": "Напрямок", "filters": { + "has-attachments": "є вкладення", "has-code": "єКод", + "has-image": "є зображення", "has-link": "єПосилання", "has-location": "є розташування", "has-task-list": "єСписокЗавдань" diff --git a/web/src/locales/vi.json b/web/src/locales/vi.json index 39181ebe9..056223fd5 100644 --- a/web/src/locales/vi.json +++ b/web/src/locales/vi.json @@ -283,7 +283,9 @@ "delete-confirm-description": "Hành động này không thể hoàn tác. Tệp đính kèm, liên kết và tham chiếu cũng sẽ bị xóa.", "direction": "Hướng", "filters": { + "has-attachments": "có tệp đính kèm", "has-code": "cóMã", + "has-image": "có hình ảnh", "has-link": "cóLiênKết", "has-location": "có vị trí", "has-task-list": "cóDanhSáchViệc" diff --git a/web/src/locales/zh-Hans.json b/web/src/locales/zh-Hans.json index b52bc92a7..d07204146 100644 --- a/web/src/locales/zh-Hans.json +++ b/web/src/locales/zh-Hans.json @@ -315,7 +315,9 @@ "delete-confirm-description": "此操作是不可逆的,附件、链接和引用也会被删除。", "direction": "排序方式", "filters": { + "has-attachments": "有附件", "has-code": "有代码", + "has-image": "有图片", "has-link": "有链接", "has-location": "有位置", "has-task-list": "有待办" diff --git a/web/src/locales/zh-Hant.json b/web/src/locales/zh-Hant.json index 84ac8198f..eae179c24 100644 --- a/web/src/locales/zh-Hant.json +++ b/web/src/locales/zh-Hant.json @@ -368,7 +368,9 @@ "delete-confirm-description": "此操作無法恢復。附件、連結和引用將一併被移除。", "direction": "排序", "filters": { + "has-attachments": "有附件", "has-code": "有程式碼", + "has-image": "有圖片", "has-link": "有連結", "has-location": "有位置", "has-task-list": "有待辦事項" diff --git a/web/src/pages/MemoViews.tsx b/web/src/pages/MemoViews.tsx index 630ee7601..c90a66dcf 100644 --- a/web/src/pages/MemoViews.tsx +++ b/web/src/pages/MemoViews.tsx @@ -8,8 +8,10 @@ import { Clock3Icon, ExternalLinkIcon, FilterIcon, + ImageIcon, MapPinIcon, MoreVerticalIcon, + PaperclipIcon, ParenthesesIcon, PencilIcon, PinIcon, @@ -111,6 +113,18 @@ const memoViewExamples = [ description: "Memos without an attached location.", icon: MapPinIcon, }, + { + title: "With attachments", + filter: "has_attachments", + description: "Memos with at least one attached file.", + icon: PaperclipIcon, + }, + { + title: "Photos", + filter: "has_image", + description: "Memos that show an image, in the content or as an attached file.", + icon: ImageIcon, + }, { title: "Content search", filter: 'content.contains("TODO")', @@ -197,6 +211,8 @@ const filterFields = [ "has_link", "has_code", "has_location", + "has_attachments", + "has_image", 'created_ts >= now - duration("24h")', "created_ts.getFullYear() == ...", "created_ts.getMonth() == ... (0 = Jan)", diff --git a/web/src/types/proto/api/memo_service_pb.ts b/web/src/types/proto/api/memo_service_pb.ts index aade25599..ab3ac85cd 100644 --- a/web/src/types/proto/api/memo_service_pb.ts +++ b/web/src/types/proto/api/memo_service_pb.ts @@ -20,7 +20,7 @@ import type { Message } from "@bufbuild/protobuf"; * Describes the file api/memo_service.proto. */ export const file_api_memo_service: GenFile = /*@__PURE__*/ - fileDesc("ChZhcGkvbWVtb19zZXJ2aWNlLnByb3RvEgltZW1vcy5hcGki6QYKBE1lbW8SEQoEbmFtZRgBIAEoCUID4EEIEicKB2NyZWF0b3IYAiABKAlCFuBBA/pBEAoObWVtb3MuYXBpL1VzZXISKwoFc3BhY2UYAyABKAlCF+BBAfpBEQoPbWVtb3MuYXBpL1NwYWNlSACIAQESFAoHY29udGVudBgEIAEoCUID4EECEi8KCGxvY2F0aW9uGAUgASgLMhMubWVtb3MuYXBpLkxvY2F0aW9uQgPgQQFIAYgBARIuCgp2aXNpYmlsaXR5GAYgASgOMhUubWVtb3MuYXBpLlZpc2liaWxpdHlCA+BBAhIkCgVzdGF0ZRgHIAEoDjIQLm1lbW9zLmFwaS5TdGF0ZUID4EECEhMKBnBpbm5lZBgIIAEoCEID4EEBEi8KC2F0dGFjaG1lbnRzGAkgAygLMhUubWVtb3MuYXBpLkF0dGFjaG1lbnRCA+BBARIvCglyZWxhdGlvbnMYCiADKAsyFy5tZW1vcy5hcGkuTWVtb1JlbGF0aW9uQgPgQQESKwoJcmVhY3Rpb25zGAsgAygLMhMubWVtb3MuYXBpLlJlYWN0aW9uQgPgQQMSKwoGcGFyZW50GAwgASgJQhbgQQP6QRAKDm1lbW9zLmFwaS9NZW1vSAKIAQESEQoEdGFncxgNIAMoCUID4EEDEi8KCHByb3BlcnR5GA4gASgLMhgubWVtb3MuYXBpLk1lbW8uUHJvcGVydHlCA+BBAxIUCgdzbmlwcGV0GA8gASgJQgPgQQMSNAoLY3JlYXRlX3RpbWUYECABKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wQgPgQQESNAoLdXBkYXRlX3RpbWUYESABKAsyGi5nb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oNY29tLm1lbW9zLmFwaUIQTWVtb1NlcnZpY2VQcm90b1ABWidnaXRodWIuY29tL3VzZW1lbW9zL21lbW9zL3Byb3RvL2dlbi9hcGmiAgNNQViqAglNZW1vcy5BcGnKAglNZW1vc1xBcGniAhVNZW1vc1xBcGlcR1BCTWV0YWRhdGHqAgpNZW1vczo6QXBpYgZwcm90bzM", [file_api_attachment_service, file_api_common, file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_empty, file_google_protobuf_field_mask, file_google_protobuf_timestamp]); + fileDesc("ChZhcGkvbWVtb19zZXJ2aWNlLnByb3RvEgltZW1vcy5hcGkihAcKBE1lbW8SEQoEbmFtZRgBIAEoCUID4EEIEicKB2NyZWF0b3IYAiABKAlCFuBBA/pBEAoObWVtb3MuYXBpL1VzZXISKwoFc3BhY2UYAyABKAlCF+BBAfpBEQoPbWVtb3MuYXBpL1NwYWNlSACIAQESFAoHY29udGVudBgEIAEoCUID4EECEi8KCGxvY2F0aW9uGAUgASgLMhMubWVtb3MuYXBpLkxvY2F0aW9uQgPgQQFIAYgBARIuCgp2aXNpYmlsaXR5GAYgASgOMhUubWVtb3MuYXBpLlZpc2liaWxpdHlCA+BBAhIkCgVzdGF0ZRgHIAEoDjIQLm1lbW9zLmFwaS5TdGF0ZUID4EECEhMKBnBpbm5lZBgIIAEoCEID4EEBEi8KC2F0dGFjaG1lbnRzGAkgAygLMhUubWVtb3MuYXBpLkF0dGFjaG1lbnRCA+BBARIvCglyZWxhdGlvbnMYCiADKAsyFy5tZW1vcy5hcGkuTWVtb1JlbGF0aW9uQgPgQQESKwoJcmVhY3Rpb25zGAsgAygLMhMubWVtb3MuYXBpLlJlYWN0aW9uQgPgQQMSKwoGcGFyZW50GAwgASgJQhbgQQP6QRAKDm1lbW9zLmFwaS9NZW1vSAKIAQESEQoEdGFncxgNIAMoCUID4EEDEi8KCHByb3BlcnR5GA4gASgLMhgubWVtb3MuYXBpLk1lbW8uUHJvcGVydH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cGkuQmF0Y2hHZXRMaW5rTWV0YWRhdGFSZXF1ZXN0GicubWVtb3MuYXBpLkJhdGNoR2V0TGlua01ldGFkYXRhUmVzcG9uc2UiLYLT5JMCJzoBKiIiL2FwaS9tZW1vcy8tL2xpbmtNZXRhZGF0YTpiYXRjaEdldEKPAQoNY29tLm1lbW9zLmFwaUIQTWVtb1NlcnZpY2VQcm90b1ABWidnaXRodWIuY29tL3VzZW1lbW9zL21lbW9zL3Byb3RvL2dlbi9hcGmiAgNNQViqAglNZW1vcy5BcGnKAglNZW1vc1xBcGniAhVNZW1vc1xBcGlcR1BCTWV0YWRhdGHqAgpNZW1vczo6QXBpYgZwcm90bzM", [file_api_attachment_service, file_api_common, file_google_api_annotations, file_google_api_client, file_google_api_field_behavior, file_google_api_resource, file_google_protobuf_empty, file_google_protobuf_field_mask, file_google_protobuf_timestamp]); /** * Memo is a Markdown note written by a user. @@ -210,6 +210,13 @@ export type Memo_Property = Message<"memos.api.Memo.Property"> & { * @generated from field: bool has_incomplete_tasks = 5; */ hasIncompleteTasks: boolean; + + /** + * Whether the content contains a Markdown image. + * + * @generated from field: bool has_inline_image = 6; + */ + hasInlineImage: boolean; }; /** @@ -251,7 +258,10 @@ export type ListMemosRequest = Message<"memos.api.ListMemosRequest"> & { * supports == and comparisons against null, e.g. space != null), * tags (list; match with `"work" in tags`, not `tag == "work"`), * has_task_list / has_link / has_code / has_incomplete_tasks (bool), - * has_location (bool; true when the memo has a location attached). + * has_location (bool; true when the memo has a location attached), + * has_attachments (bool; true when a file is attached to the memo), + * has_image (bool; true when the content contains a Markdown image or an + * image file is attached). * Note: the time fields here are created_ts / updated_ts, which differ from * the create_time / update_time names used by order_by. * Examples: diff --git a/web/tests/memo-views.test.ts b/web/tests/memo-views.test.ts index de34b5df2..b56dae443 100644 --- a/web/tests/memo-views.test.ts +++ b/web/tests/memo-views.test.ts @@ -89,10 +89,12 @@ describe("memo views", () => { { factor: "property.hasTaskList", value: "" }, { factor: "property.hasCode", value: "" }, { factor: "property.hasLocation", value: "" }, + { factor: "property.hasAttachments", value: "" }, + { factor: "property.hasImage", value: "" }, ], includePinned: false, }), - ).toBe("(has_link) && (has_task_list) && (has_code) && (has_location)"); + ).toBe("(has_link) && (has_task_list) && (has_code) && (has_location) && (has_attachments) && (has_image)"); }); it("uses a saved memo view filter", () => {