feat: persist and display client media metadata (#6180)
This commit is contained in:
parent
38bc02c3cc
commit
da81b6b48f
52 changed files with 3782 additions and 200 deletions
24
internal/testutil/image.go
Normal file
24
internal/testutil/image.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package testutil
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/jpeg"
|
||||
)
|
||||
|
||||
// BuildJPEG returns a solid-color width×height JPEG blob for tests.
|
||||
func BuildJPEG(width, height int) []byte {
|
||||
img := image.NewRGBA(image.Rect(0, 0, width, height))
|
||||
for y := range height {
|
||||
for x := range width {
|
||||
img.Set(x, y, color.RGBA{R: 80, G: 120, B: 160, A: 255})
|
||||
}
|
||||
}
|
||||
var buffer bytes.Buffer
|
||||
if err := jpeg.Encode(&buffer, img, &jpeg.Options{Quality: 90}); err != nil {
|
||||
// Encoding an in-memory RGBA image cannot fail with valid dimensions.
|
||||
panic(err)
|
||||
}
|
||||
return buffer.Bytes()
|
||||
}
|
||||
|
|
@ -73,6 +73,58 @@ message MotionMedia {
|
|||
bool has_embedded_video = 5;
|
||||
}
|
||||
|
||||
// MediaMetadata contains normalized metadata explicitly supplied by a client.
|
||||
// The server validates and stores this data but does not extract it from the media file.
|
||||
message MediaMetadata {
|
||||
// Optional. Display-oriented width in pixels.
|
||||
optional int32 width = 1;
|
||||
// Optional. Display-oriented height in pixels.
|
||||
optional int32 height = 2;
|
||||
|
||||
oneof details {
|
||||
PhotoMetadata photo = 3;
|
||||
VideoMetadata video = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message PhotoMetadata {
|
||||
// Optional. Capture time as recorded by the source media.
|
||||
MediaCaptureTime capture_time = 1;
|
||||
// Optional. Geographic location recorded by the source media.
|
||||
MediaLocation location = 2;
|
||||
// Optional. EXIF orientation value from 1 through 8 as recorded by the source file.
|
||||
// This value is informational and must not be reapplied to the stored attachment;
|
||||
// width and height already describe its display-oriented dimensions.
|
||||
optional int32 source_exif_orientation = 3;
|
||||
string camera_make = 4;
|
||||
string camera_model = 5;
|
||||
string lens_model = 6;
|
||||
optional double f_number = 7;
|
||||
optional double exposure_time_seconds = 8;
|
||||
optional int32 iso = 9;
|
||||
optional double focal_length_mm = 10;
|
||||
}
|
||||
|
||||
message MediaCaptureTime {
|
||||
// Local date and time without a time zone, formatted as YYYY-MM-DDTHH:mm:ss[.fraction].
|
||||
string local_date_time = 1;
|
||||
// Optional. UTC offset formatted as Z or +/-HH:MM.
|
||||
optional string utc_offset = 2;
|
||||
}
|
||||
|
||||
message MediaLocation {
|
||||
// Optional. WGS84 latitude in decimal degrees. Must be provided with longitude.
|
||||
optional double latitude = 1;
|
||||
// Optional. WGS84 longitude in decimal degrees. Must be provided with latitude.
|
||||
optional double longitude = 2;
|
||||
// Optional. Signed altitude in meters relative to sea level.
|
||||
optional double altitude_meters = 3;
|
||||
}
|
||||
|
||||
message VideoMetadata {
|
||||
optional double duration_seconds = 1;
|
||||
}
|
||||
|
||||
message Attachment {
|
||||
option (google.api.resource) = {
|
||||
type: "memos.api.v1/Attachment"
|
||||
|
|
@ -109,6 +161,12 @@ message Attachment {
|
|||
|
||||
// Optional. Motion media metadata.
|
||||
MotionMedia motion_media = 9 [(google.api.field_behavior) = OPTIONAL];
|
||||
|
||||
// Optional. Immutable normalized media metadata explicitly supplied by the client at creation time.
|
||||
MediaMetadata media_metadata = 10 [
|
||||
(google.api.field_behavior) = OPTIONAL,
|
||||
(google.api.field_behavior) = IMMUTABLE
|
||||
];
|
||||
}
|
||||
|
||||
message CreateAttachmentRequest {
|
||||
|
|
|
|||
|
|
@ -456,6 +456,8 @@ message UserSetting {
|
|||
// This references a CSS file in the web/public/themes/ directory.
|
||||
// If not set, the default theme will be used.
|
||||
string theme = 4 [(google.api.field_behavior) = OPTIONAL];
|
||||
// Whether the official client should save metadata from future media uploads.
|
||||
bool save_media_metadata = 5 [(google.api.field_behavior) = OPTIONAL];
|
||||
}
|
||||
|
||||
// Tag metadata for user-specific display rules.
|
||||
|
|
|
|||
|
|
@ -202,6 +202,390 @@ func (x *MotionMedia) GetHasEmbeddedVideo() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// MediaMetadata contains normalized metadata explicitly supplied by a client.
|
||||
// The server validates and stores this data but does not extract it from the media file.
|
||||
type MediaMetadata struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Optional. Display-oriented width in pixels.
|
||||
Width *int32 `protobuf:"varint,1,opt,name=width,proto3,oneof" json:"width,omitempty"`
|
||||
// Optional. Display-oriented height in pixels.
|
||||
Height *int32 `protobuf:"varint,2,opt,name=height,proto3,oneof" json:"height,omitempty"`
|
||||
// Types that are valid to be assigned to Details:
|
||||
//
|
||||
// *MediaMetadata_Photo
|
||||
// *MediaMetadata_Video
|
||||
Details isMediaMetadata_Details `protobuf_oneof:"details"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *MediaMetadata) Reset() {
|
||||
*x = MediaMetadata{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *MediaMetadata) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*MediaMetadata) ProtoMessage() {}
|
||||
|
||||
func (x *MediaMetadata) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use MediaMetadata.ProtoReflect.Descriptor instead.
|
||||
func (*MediaMetadata) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *MediaMetadata) GetWidth() int32 {
|
||||
if x != nil && x.Width != nil {
|
||||
return *x.Width
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *MediaMetadata) GetHeight() int32 {
|
||||
if x != nil && x.Height != nil {
|
||||
return *x.Height
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *MediaMetadata) GetDetails() isMediaMetadata_Details {
|
||||
if x != nil {
|
||||
return x.Details
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *MediaMetadata) GetPhoto() *PhotoMetadata {
|
||||
if x != nil {
|
||||
if x, ok := x.Details.(*MediaMetadata_Photo); ok {
|
||||
return x.Photo
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *MediaMetadata) GetVideo() *VideoMetadata {
|
||||
if x != nil {
|
||||
if x, ok := x.Details.(*MediaMetadata_Video); ok {
|
||||
return x.Video
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type isMediaMetadata_Details interface {
|
||||
isMediaMetadata_Details()
|
||||
}
|
||||
|
||||
type MediaMetadata_Photo struct {
|
||||
Photo *PhotoMetadata `protobuf:"bytes,3,opt,name=photo,proto3,oneof"`
|
||||
}
|
||||
|
||||
type MediaMetadata_Video struct {
|
||||
Video *VideoMetadata `protobuf:"bytes,4,opt,name=video,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*MediaMetadata_Photo) isMediaMetadata_Details() {}
|
||||
|
||||
func (*MediaMetadata_Video) isMediaMetadata_Details() {}
|
||||
|
||||
type PhotoMetadata struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Optional. Capture time as recorded by the source media.
|
||||
CaptureTime *MediaCaptureTime `protobuf:"bytes,1,opt,name=capture_time,json=captureTime,proto3" json:"capture_time,omitempty"`
|
||||
// Optional. Geographic location recorded by the source media.
|
||||
Location *MediaLocation `protobuf:"bytes,2,opt,name=location,proto3" json:"location,omitempty"`
|
||||
// Optional. EXIF orientation value from 1 through 8 as recorded by the source file.
|
||||
// This value is informational and must not be reapplied to the stored attachment;
|
||||
// width and height already describe its display-oriented dimensions.
|
||||
SourceExifOrientation *int32 `protobuf:"varint,3,opt,name=source_exif_orientation,json=sourceExifOrientation,proto3,oneof" json:"source_exif_orientation,omitempty"`
|
||||
CameraMake string `protobuf:"bytes,4,opt,name=camera_make,json=cameraMake,proto3" json:"camera_make,omitempty"`
|
||||
CameraModel string `protobuf:"bytes,5,opt,name=camera_model,json=cameraModel,proto3" json:"camera_model,omitempty"`
|
||||
LensModel string `protobuf:"bytes,6,opt,name=lens_model,json=lensModel,proto3" json:"lens_model,omitempty"`
|
||||
FNumber *float64 `protobuf:"fixed64,7,opt,name=f_number,json=fNumber,proto3,oneof" json:"f_number,omitempty"`
|
||||
ExposureTimeSeconds *float64 `protobuf:"fixed64,8,opt,name=exposure_time_seconds,json=exposureTimeSeconds,proto3,oneof" json:"exposure_time_seconds,omitempty"`
|
||||
Iso *int32 `protobuf:"varint,9,opt,name=iso,proto3,oneof" json:"iso,omitempty"`
|
||||
FocalLengthMm *float64 `protobuf:"fixed64,10,opt,name=focal_length_mm,json=focalLengthMm,proto3,oneof" json:"focal_length_mm,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) Reset() {
|
||||
*x = PhotoMetadata{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PhotoMetadata) ProtoMessage() {}
|
||||
|
||||
func (x *PhotoMetadata) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use PhotoMetadata.ProtoReflect.Descriptor instead.
|
||||
func (*PhotoMetadata) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetCaptureTime() *MediaCaptureTime {
|
||||
if x != nil {
|
||||
return x.CaptureTime
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetLocation() *MediaLocation {
|
||||
if x != nil {
|
||||
return x.Location
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetSourceExifOrientation() int32 {
|
||||
if x != nil && x.SourceExifOrientation != nil {
|
||||
return *x.SourceExifOrientation
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetCameraMake() string {
|
||||
if x != nil {
|
||||
return x.CameraMake
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetCameraModel() string {
|
||||
if x != nil {
|
||||
return x.CameraModel
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetLensModel() string {
|
||||
if x != nil {
|
||||
return x.LensModel
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetFNumber() float64 {
|
||||
if x != nil && x.FNumber != nil {
|
||||
return *x.FNumber
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetExposureTimeSeconds() float64 {
|
||||
if x != nil && x.ExposureTimeSeconds != nil {
|
||||
return *x.ExposureTimeSeconds
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetIso() int32 {
|
||||
if x != nil && x.Iso != nil {
|
||||
return *x.Iso
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetFocalLengthMm() float64 {
|
||||
if x != nil && x.FocalLengthMm != nil {
|
||||
return *x.FocalLengthMm
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type MediaCaptureTime struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Local date and time without a time zone, formatted as YYYY-MM-DDTHH:mm:ss[.fraction].
|
||||
LocalDateTime string `protobuf:"bytes,1,opt,name=local_date_time,json=localDateTime,proto3" json:"local_date_time,omitempty"`
|
||||
// Optional. UTC offset formatted as Z or +/-HH:MM.
|
||||
UtcOffset *string `protobuf:"bytes,2,opt,name=utc_offset,json=utcOffset,proto3,oneof" json:"utc_offset,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *MediaCaptureTime) Reset() {
|
||||
*x = MediaCaptureTime{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *MediaCaptureTime) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*MediaCaptureTime) ProtoMessage() {}
|
||||
|
||||
func (x *MediaCaptureTime) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use MediaCaptureTime.ProtoReflect.Descriptor instead.
|
||||
func (*MediaCaptureTime) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *MediaCaptureTime) GetLocalDateTime() string {
|
||||
if x != nil {
|
||||
return x.LocalDateTime
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MediaCaptureTime) GetUtcOffset() string {
|
||||
if x != nil && x.UtcOffset != nil {
|
||||
return *x.UtcOffset
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type MediaLocation struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Optional. WGS84 latitude in decimal degrees. Must be provided with longitude.
|
||||
Latitude *float64 `protobuf:"fixed64,1,opt,name=latitude,proto3,oneof" json:"latitude,omitempty"`
|
||||
// Optional. WGS84 longitude in decimal degrees. Must be provided with latitude.
|
||||
Longitude *float64 `protobuf:"fixed64,2,opt,name=longitude,proto3,oneof" json:"longitude,omitempty"`
|
||||
// Optional. Signed altitude in meters relative to sea level.
|
||||
AltitudeMeters *float64 `protobuf:"fixed64,3,opt,name=altitude_meters,json=altitudeMeters,proto3,oneof" json:"altitude_meters,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *MediaLocation) Reset() {
|
||||
*x = MediaLocation{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *MediaLocation) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*MediaLocation) ProtoMessage() {}
|
||||
|
||||
func (x *MediaLocation) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use MediaLocation.ProtoReflect.Descriptor instead.
|
||||
func (*MediaLocation) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *MediaLocation) GetLatitude() float64 {
|
||||
if x != nil && x.Latitude != nil {
|
||||
return *x.Latitude
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *MediaLocation) GetLongitude() float64 {
|
||||
if x != nil && x.Longitude != nil {
|
||||
return *x.Longitude
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *MediaLocation) GetAltitudeMeters() float64 {
|
||||
if x != nil && x.AltitudeMeters != nil {
|
||||
return *x.AltitudeMeters
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type VideoMetadata struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
DurationSeconds *float64 `protobuf:"fixed64,1,opt,name=duration_seconds,json=durationSeconds,proto3,oneof" json:"duration_seconds,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *VideoMetadata) Reset() {
|
||||
*x = VideoMetadata{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *VideoMetadata) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*VideoMetadata) ProtoMessage() {}
|
||||
|
||||
func (x *VideoMetadata) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[5]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use VideoMetadata.ProtoReflect.Descriptor instead.
|
||||
func (*VideoMetadata) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *VideoMetadata) GetDurationSeconds() float64 {
|
||||
if x != nil && x.DurationSeconds != nil {
|
||||
return *x.DurationSeconds
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type Attachment struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// The name of the attachment.
|
||||
|
|
@ -223,14 +607,16 @@ type Attachment struct {
|
|||
// Format: memos/{memo}
|
||||
Memo *string `protobuf:"bytes,8,opt,name=memo,proto3,oneof" json:"memo,omitempty"`
|
||||
// Optional. Motion media metadata.
|
||||
MotionMedia *MotionMedia `protobuf:"bytes,9,opt,name=motion_media,json=motionMedia,proto3" json:"motion_media,omitempty"`
|
||||
MotionMedia *MotionMedia `protobuf:"bytes,9,opt,name=motion_media,json=motionMedia,proto3" json:"motion_media,omitempty"`
|
||||
// Optional. Immutable normalized media metadata explicitly supplied by the client at creation time.
|
||||
MediaMetadata *MediaMetadata `protobuf:"bytes,10,opt,name=media_metadata,json=mediaMetadata,proto3" json:"media_metadata,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Attachment) Reset() {
|
||||
*x = Attachment{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[1]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -242,7 +628,7 @@ func (x *Attachment) String() string {
|
|||
func (*Attachment) ProtoMessage() {}
|
||||
|
||||
func (x *Attachment) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[1]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[6]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -255,7 +641,7 @@ func (x *Attachment) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use Attachment.ProtoReflect.Descriptor instead.
|
||||
func (*Attachment) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{1}
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *Attachment) GetName() string {
|
||||
|
|
@ -321,6 +707,13 @@ func (x *Attachment) GetMotionMedia() *MotionMedia {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (x *Attachment) GetMediaMetadata() *MediaMetadata {
|
||||
if x != nil {
|
||||
return x.MediaMetadata
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type CreateAttachmentRequest struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Required. The attachment to create.
|
||||
|
|
@ -335,7 +728,7 @@ type CreateAttachmentRequest struct {
|
|||
|
||||
func (x *CreateAttachmentRequest) Reset() {
|
||||
*x = CreateAttachmentRequest{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[2]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -347,7 +740,7 @@ func (x *CreateAttachmentRequest) String() string {
|
|||
func (*CreateAttachmentRequest) ProtoMessage() {}
|
||||
|
||||
func (x *CreateAttachmentRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[2]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[7]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -360,7 +753,7 @@ func (x *CreateAttachmentRequest) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use CreateAttachmentRequest.ProtoReflect.Descriptor instead.
|
||||
func (*CreateAttachmentRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{2}
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *CreateAttachmentRequest) GetAttachment() *Attachment {
|
||||
|
|
@ -401,7 +794,7 @@ type ListAttachmentsRequest struct {
|
|||
|
||||
func (x *ListAttachmentsRequest) Reset() {
|
||||
*x = ListAttachmentsRequest{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[3]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[8]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -413,7 +806,7 @@ func (x *ListAttachmentsRequest) String() string {
|
|||
func (*ListAttachmentsRequest) ProtoMessage() {}
|
||||
|
||||
func (x *ListAttachmentsRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[3]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[8]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -426,7 +819,7 @@ func (x *ListAttachmentsRequest) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use ListAttachmentsRequest.ProtoReflect.Descriptor instead.
|
||||
func (*ListAttachmentsRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{3}
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{8}
|
||||
}
|
||||
|
||||
func (x *ListAttachmentsRequest) GetPageSize() int32 {
|
||||
|
|
@ -470,7 +863,7 @@ type ListAttachmentsResponse struct {
|
|||
|
||||
func (x *ListAttachmentsResponse) Reset() {
|
||||
*x = ListAttachmentsResponse{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[4]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[9]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -482,7 +875,7 @@ func (x *ListAttachmentsResponse) String() string {
|
|||
func (*ListAttachmentsResponse) ProtoMessage() {}
|
||||
|
||||
func (x *ListAttachmentsResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[4]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[9]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -495,7 +888,7 @@ func (x *ListAttachmentsResponse) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use ListAttachmentsResponse.ProtoReflect.Descriptor instead.
|
||||
func (*ListAttachmentsResponse) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{4}
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{9}
|
||||
}
|
||||
|
||||
func (x *ListAttachmentsResponse) GetAttachments() []*Attachment {
|
||||
|
|
@ -523,7 +916,7 @@ type GetAttachmentRequest struct {
|
|||
|
||||
func (x *GetAttachmentRequest) Reset() {
|
||||
*x = GetAttachmentRequest{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[5]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[10]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -535,7 +928,7 @@ func (x *GetAttachmentRequest) String() string {
|
|||
func (*GetAttachmentRequest) ProtoMessage() {}
|
||||
|
||||
func (x *GetAttachmentRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[5]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[10]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -548,7 +941,7 @@ func (x *GetAttachmentRequest) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use GetAttachmentRequest.ProtoReflect.Descriptor instead.
|
||||
func (*GetAttachmentRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{5}
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{10}
|
||||
}
|
||||
|
||||
func (x *GetAttachmentRequest) GetName() string {
|
||||
|
|
@ -570,7 +963,7 @@ type UpdateAttachmentRequest struct {
|
|||
|
||||
func (x *UpdateAttachmentRequest) Reset() {
|
||||
*x = UpdateAttachmentRequest{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[6]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[11]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -582,7 +975,7 @@ func (x *UpdateAttachmentRequest) String() string {
|
|||
func (*UpdateAttachmentRequest) ProtoMessage() {}
|
||||
|
||||
func (x *UpdateAttachmentRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[6]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[11]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -595,7 +988,7 @@ func (x *UpdateAttachmentRequest) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use UpdateAttachmentRequest.ProtoReflect.Descriptor instead.
|
||||
func (*UpdateAttachmentRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{6}
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{11}
|
||||
}
|
||||
|
||||
func (x *UpdateAttachmentRequest) GetAttachment() *Attachment {
|
||||
|
|
@ -623,7 +1016,7 @@ type DeleteAttachmentRequest struct {
|
|||
|
||||
func (x *DeleteAttachmentRequest) Reset() {
|
||||
*x = DeleteAttachmentRequest{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[7]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[12]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -635,7 +1028,7 @@ func (x *DeleteAttachmentRequest) String() string {
|
|||
func (*DeleteAttachmentRequest) ProtoMessage() {}
|
||||
|
||||
func (x *DeleteAttachmentRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[7]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[12]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -648,7 +1041,7 @@ func (x *DeleteAttachmentRequest) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use DeleteAttachmentRequest.ProtoReflect.Descriptor instead.
|
||||
func (*DeleteAttachmentRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{7}
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{12}
|
||||
}
|
||||
|
||||
func (x *DeleteAttachmentRequest) GetName() string {
|
||||
|
|
@ -667,7 +1060,7 @@ type BatchDeleteAttachmentsRequest struct {
|
|||
|
||||
func (x *BatchDeleteAttachmentsRequest) Reset() {
|
||||
*x = BatchDeleteAttachmentsRequest{}
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[8]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[13]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -679,7 +1072,7 @@ func (x *BatchDeleteAttachmentsRequest) String() string {
|
|||
func (*BatchDeleteAttachmentsRequest) ProtoMessage() {}
|
||||
|
||||
func (x *BatchDeleteAttachmentsRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[8]
|
||||
mi := &file_api_v1_attachment_service_proto_msgTypes[13]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -692,7 +1085,7 @@ func (x *BatchDeleteAttachmentsRequest) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use BatchDeleteAttachmentsRequest.ProtoReflect.Descriptor instead.
|
||||
func (*BatchDeleteAttachmentsRequest) Descriptor() ([]byte, []int) {
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{8}
|
||||
return file_api_v1_attachment_service_proto_rawDescGZIP(), []int{13}
|
||||
}
|
||||
|
||||
func (x *BatchDeleteAttachmentsRequest) GetNames() []string {
|
||||
|
|
@ -712,7 +1105,50 @@ const file_api_v1_attachment_service_proto_rawDesc = "" +
|
|||
"\x04role\x18\x02 \x01(\x0e2\x1d.memos.api.v1.MotionMediaRoleR\x04role\x12\x19\n" +
|
||||
"\bgroup_id\x18\x03 \x01(\tR\agroupId\x12:\n" +
|
||||
"\x19presentation_timestamp_us\x18\x04 \x01(\x03R\x17presentationTimestampUs\x12,\n" +
|
||||
"\x12has_embedded_video\x18\x05 \x01(\bR\x10hasEmbeddedVideo\"\xbe\x03\n" +
|
||||
"\x12has_embedded_video\x18\x05 \x01(\bR\x10hasEmbeddedVideo\"\xd1\x01\n" +
|
||||
"\rMediaMetadata\x12\x19\n" +
|
||||
"\x05width\x18\x01 \x01(\x05H\x01R\x05width\x88\x01\x01\x12\x1b\n" +
|
||||
"\x06height\x18\x02 \x01(\x05H\x02R\x06height\x88\x01\x01\x123\n" +
|
||||
"\x05photo\x18\x03 \x01(\v2\x1b.memos.api.v1.PhotoMetadataH\x00R\x05photo\x123\n" +
|
||||
"\x05video\x18\x04 \x01(\v2\x1b.memos.api.v1.VideoMetadataH\x00R\x05videoB\t\n" +
|
||||
"\adetailsB\b\n" +
|
||||
"\x06_widthB\t\n" +
|
||||
"\a_height\"\xa7\x04\n" +
|
||||
"\rPhotoMetadata\x12A\n" +
|
||||
"\fcapture_time\x18\x01 \x01(\v2\x1e.memos.api.v1.MediaCaptureTimeR\vcaptureTime\x127\n" +
|
||||
"\blocation\x18\x02 \x01(\v2\x1b.memos.api.v1.MediaLocationR\blocation\x12;\n" +
|
||||
"\x17source_exif_orientation\x18\x03 \x01(\x05H\x00R\x15sourceExifOrientation\x88\x01\x01\x12\x1f\n" +
|
||||
"\vcamera_make\x18\x04 \x01(\tR\n" +
|
||||
"cameraMake\x12!\n" +
|
||||
"\fcamera_model\x18\x05 \x01(\tR\vcameraModel\x12\x1d\n" +
|
||||
"\n" +
|
||||
"lens_model\x18\x06 \x01(\tR\tlensModel\x12\x1e\n" +
|
||||
"\bf_number\x18\a \x01(\x01H\x01R\afNumber\x88\x01\x01\x127\n" +
|
||||
"\x15exposure_time_seconds\x18\b \x01(\x01H\x02R\x13exposureTimeSeconds\x88\x01\x01\x12\x15\n" +
|
||||
"\x03iso\x18\t \x01(\x05H\x03R\x03iso\x88\x01\x01\x12+\n" +
|
||||
"\x0ffocal_length_mm\x18\n" +
|
||||
" \x01(\x01H\x04R\rfocalLengthMm\x88\x01\x01B\x1a\n" +
|
||||
"\x18_source_exif_orientationB\v\n" +
|
||||
"\t_f_numberB\x18\n" +
|
||||
"\x16_exposure_time_secondsB\x06\n" +
|
||||
"\x04_isoB\x12\n" +
|
||||
"\x10_focal_length_mm\"m\n" +
|
||||
"\x10MediaCaptureTime\x12&\n" +
|
||||
"\x0flocal_date_time\x18\x01 \x01(\tR\rlocalDateTime\x12\"\n" +
|
||||
"\n" +
|
||||
"utc_offset\x18\x02 \x01(\tH\x00R\tutcOffset\x88\x01\x01B\r\n" +
|
||||
"\v_utc_offset\"\xb0\x01\n" +
|
||||
"\rMediaLocation\x12\x1f\n" +
|
||||
"\blatitude\x18\x01 \x01(\x01H\x00R\blatitude\x88\x01\x01\x12!\n" +
|
||||
"\tlongitude\x18\x02 \x01(\x01H\x01R\tlongitude\x88\x01\x01\x12,\n" +
|
||||
"\x0faltitude_meters\x18\x03 \x01(\x01H\x02R\x0ealtitudeMeters\x88\x01\x01B\v\n" +
|
||||
"\t_latitudeB\f\n" +
|
||||
"\n" +
|
||||
"_longitudeB\x12\n" +
|
||||
"\x10_altitude_meters\"T\n" +
|
||||
"\rVideoMetadata\x12.\n" +
|
||||
"\x10duration_seconds\x18\x01 \x01(\x01H\x00R\x0fdurationSeconds\x88\x01\x01B\x13\n" +
|
||||
"\x11_duration_seconds\"\x8a\x04\n" +
|
||||
"\n" +
|
||||
"Attachment\x12\x17\n" +
|
||||
"\x04name\x18\x01 \x01(\tB\x03\xe0A\bR\x04name\x12@\n" +
|
||||
|
|
@ -724,7 +1160,9 @@ const file_api_v1_attachment_service_proto_rawDesc = "" +
|
|||
"\x04type\x18\x06 \x01(\tB\x03\xe0A\x02R\x04type\x12\x17\n" +
|
||||
"\x04size\x18\a \x01(\x03B\x03\xe0A\x03R\x04size\x12\x1c\n" +
|
||||
"\x04memo\x18\b \x01(\tB\x03\xe0A\x01H\x00R\x04memo\x88\x01\x01\x12A\n" +
|
||||
"\fmotion_media\x18\t \x01(\v2\x19.memos.api.v1.MotionMediaB\x03\xe0A\x01R\vmotionMedia:O\xeaAL\n" +
|
||||
"\fmotion_media\x18\t \x01(\v2\x19.memos.api.v1.MotionMediaB\x03\xe0A\x01R\vmotionMedia\x12J\n" +
|
||||
"\x0emedia_metadata\x18\n" +
|
||||
" \x01(\v2\x1b.memos.api.v1.MediaMetadataB\x06\xe0A\x01\xe0A\x05R\rmediaMetadata:O\xeaAL\n" +
|
||||
"\x17memos.api.v1/Attachment\x12\x18attachments/{attachment}*\vattachments2\n" +
|
||||
"attachmentB\a\n" +
|
||||
"\x05_memo\"\x82\x01\n" +
|
||||
|
|
@ -790,49 +1228,59 @@ func file_api_v1_attachment_service_proto_rawDescGZIP() []byte {
|
|||
}
|
||||
|
||||
var file_api_v1_attachment_service_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
||||
var file_api_v1_attachment_service_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
|
||||
var file_api_v1_attachment_service_proto_msgTypes = make([]protoimpl.MessageInfo, 14)
|
||||
var file_api_v1_attachment_service_proto_goTypes = []any{
|
||||
(MotionMediaFamily)(0), // 0: memos.api.v1.MotionMediaFamily
|
||||
(MotionMediaRole)(0), // 1: memos.api.v1.MotionMediaRole
|
||||
(*MotionMedia)(nil), // 2: memos.api.v1.MotionMedia
|
||||
(*Attachment)(nil), // 3: memos.api.v1.Attachment
|
||||
(*CreateAttachmentRequest)(nil), // 4: memos.api.v1.CreateAttachmentRequest
|
||||
(*ListAttachmentsRequest)(nil), // 5: memos.api.v1.ListAttachmentsRequest
|
||||
(*ListAttachmentsResponse)(nil), // 6: memos.api.v1.ListAttachmentsResponse
|
||||
(*GetAttachmentRequest)(nil), // 7: memos.api.v1.GetAttachmentRequest
|
||||
(*UpdateAttachmentRequest)(nil), // 8: memos.api.v1.UpdateAttachmentRequest
|
||||
(*DeleteAttachmentRequest)(nil), // 9: memos.api.v1.DeleteAttachmentRequest
|
||||
(*BatchDeleteAttachmentsRequest)(nil), // 10: memos.api.v1.BatchDeleteAttachmentsRequest
|
||||
(*timestamppb.Timestamp)(nil), // 11: google.protobuf.Timestamp
|
||||
(*fieldmaskpb.FieldMask)(nil), // 12: google.protobuf.FieldMask
|
||||
(*emptypb.Empty)(nil), // 13: google.protobuf.Empty
|
||||
(*MediaMetadata)(nil), // 3: memos.api.v1.MediaMetadata
|
||||
(*PhotoMetadata)(nil), // 4: memos.api.v1.PhotoMetadata
|
||||
(*MediaCaptureTime)(nil), // 5: memos.api.v1.MediaCaptureTime
|
||||
(*MediaLocation)(nil), // 6: memos.api.v1.MediaLocation
|
||||
(*VideoMetadata)(nil), // 7: memos.api.v1.VideoMetadata
|
||||
(*Attachment)(nil), // 8: memos.api.v1.Attachment
|
||||
(*CreateAttachmentRequest)(nil), // 9: memos.api.v1.CreateAttachmentRequest
|
||||
(*ListAttachmentsRequest)(nil), // 10: memos.api.v1.ListAttachmentsRequest
|
||||
(*ListAttachmentsResponse)(nil), // 11: memos.api.v1.ListAttachmentsResponse
|
||||
(*GetAttachmentRequest)(nil), // 12: memos.api.v1.GetAttachmentRequest
|
||||
(*UpdateAttachmentRequest)(nil), // 13: memos.api.v1.UpdateAttachmentRequest
|
||||
(*DeleteAttachmentRequest)(nil), // 14: memos.api.v1.DeleteAttachmentRequest
|
||||
(*BatchDeleteAttachmentsRequest)(nil), // 15: memos.api.v1.BatchDeleteAttachmentsRequest
|
||||
(*timestamppb.Timestamp)(nil), // 16: google.protobuf.Timestamp
|
||||
(*fieldmaskpb.FieldMask)(nil), // 17: google.protobuf.FieldMask
|
||||
(*emptypb.Empty)(nil), // 18: google.protobuf.Empty
|
||||
}
|
||||
var file_api_v1_attachment_service_proto_depIdxs = []int32{
|
||||
0, // 0: memos.api.v1.MotionMedia.family:type_name -> memos.api.v1.MotionMediaFamily
|
||||
1, // 1: memos.api.v1.MotionMedia.role:type_name -> memos.api.v1.MotionMediaRole
|
||||
11, // 2: memos.api.v1.Attachment.create_time:type_name -> google.protobuf.Timestamp
|
||||
2, // 3: memos.api.v1.Attachment.motion_media:type_name -> memos.api.v1.MotionMedia
|
||||
3, // 4: memos.api.v1.CreateAttachmentRequest.attachment:type_name -> memos.api.v1.Attachment
|
||||
3, // 5: memos.api.v1.ListAttachmentsResponse.attachments:type_name -> memos.api.v1.Attachment
|
||||
3, // 6: memos.api.v1.UpdateAttachmentRequest.attachment:type_name -> memos.api.v1.Attachment
|
||||
12, // 7: memos.api.v1.UpdateAttachmentRequest.update_mask:type_name -> google.protobuf.FieldMask
|
||||
4, // 8: memos.api.v1.AttachmentService.CreateAttachment:input_type -> memos.api.v1.CreateAttachmentRequest
|
||||
5, // 9: memos.api.v1.AttachmentService.ListAttachments:input_type -> memos.api.v1.ListAttachmentsRequest
|
||||
7, // 10: memos.api.v1.AttachmentService.GetAttachment:input_type -> memos.api.v1.GetAttachmentRequest
|
||||
8, // 11: memos.api.v1.AttachmentService.UpdateAttachment:input_type -> memos.api.v1.UpdateAttachmentRequest
|
||||
9, // 12: memos.api.v1.AttachmentService.DeleteAttachment:input_type -> memos.api.v1.DeleteAttachmentRequest
|
||||
10, // 13: memos.api.v1.AttachmentService.BatchDeleteAttachments:input_type -> memos.api.v1.BatchDeleteAttachmentsRequest
|
||||
3, // 14: memos.api.v1.AttachmentService.CreateAttachment:output_type -> memos.api.v1.Attachment
|
||||
6, // 15: memos.api.v1.AttachmentService.ListAttachments:output_type -> memos.api.v1.ListAttachmentsResponse
|
||||
3, // 16: memos.api.v1.AttachmentService.GetAttachment:output_type -> memos.api.v1.Attachment
|
||||
3, // 17: memos.api.v1.AttachmentService.UpdateAttachment:output_type -> memos.api.v1.Attachment
|
||||
13, // 18: memos.api.v1.AttachmentService.DeleteAttachment:output_type -> google.protobuf.Empty
|
||||
13, // 19: memos.api.v1.AttachmentService.BatchDeleteAttachments:output_type -> google.protobuf.Empty
|
||||
14, // [14:20] is the sub-list for method output_type
|
||||
8, // [8:14] is the sub-list for method input_type
|
||||
8, // [8:8] is the sub-list for extension type_name
|
||||
8, // [8:8] is the sub-list for extension extendee
|
||||
0, // [0:8] is the sub-list for field type_name
|
||||
4, // 2: memos.api.v1.MediaMetadata.photo:type_name -> memos.api.v1.PhotoMetadata
|
||||
7, // 3: memos.api.v1.MediaMetadata.video:type_name -> memos.api.v1.VideoMetadata
|
||||
5, // 4: memos.api.v1.PhotoMetadata.capture_time:type_name -> memos.api.v1.MediaCaptureTime
|
||||
6, // 5: memos.api.v1.PhotoMetadata.location:type_name -> memos.api.v1.MediaLocation
|
||||
16, // 6: memos.api.v1.Attachment.create_time:type_name -> google.protobuf.Timestamp
|
||||
2, // 7: memos.api.v1.Attachment.motion_media:type_name -> memos.api.v1.MotionMedia
|
||||
3, // 8: memos.api.v1.Attachment.media_metadata:type_name -> memos.api.v1.MediaMetadata
|
||||
8, // 9: memos.api.v1.CreateAttachmentRequest.attachment:type_name -> memos.api.v1.Attachment
|
||||
8, // 10: memos.api.v1.ListAttachmentsResponse.attachments:type_name -> memos.api.v1.Attachment
|
||||
8, // 11: memos.api.v1.UpdateAttachmentRequest.attachment:type_name -> memos.api.v1.Attachment
|
||||
17, // 12: memos.api.v1.UpdateAttachmentRequest.update_mask:type_name -> google.protobuf.FieldMask
|
||||
9, // 13: memos.api.v1.AttachmentService.CreateAttachment:input_type -> memos.api.v1.CreateAttachmentRequest
|
||||
10, // 14: memos.api.v1.AttachmentService.ListAttachments:input_type -> memos.api.v1.ListAttachmentsRequest
|
||||
12, // 15: memos.api.v1.AttachmentService.GetAttachment:input_type -> memos.api.v1.GetAttachmentRequest
|
||||
13, // 16: memos.api.v1.AttachmentService.UpdateAttachment:input_type -> memos.api.v1.UpdateAttachmentRequest
|
||||
14, // 17: memos.api.v1.AttachmentService.DeleteAttachment:input_type -> memos.api.v1.DeleteAttachmentRequest
|
||||
15, // 18: memos.api.v1.AttachmentService.BatchDeleteAttachments:input_type -> memos.api.v1.BatchDeleteAttachmentsRequest
|
||||
8, // 19: memos.api.v1.AttachmentService.CreateAttachment:output_type -> memos.api.v1.Attachment
|
||||
11, // 20: memos.api.v1.AttachmentService.ListAttachments:output_type -> memos.api.v1.ListAttachmentsResponse
|
||||
8, // 21: memos.api.v1.AttachmentService.GetAttachment:output_type -> memos.api.v1.Attachment
|
||||
8, // 22: memos.api.v1.AttachmentService.UpdateAttachment:output_type -> memos.api.v1.Attachment
|
||||
18, // 23: memos.api.v1.AttachmentService.DeleteAttachment:output_type -> google.protobuf.Empty
|
||||
18, // 24: memos.api.v1.AttachmentService.BatchDeleteAttachments:output_type -> google.protobuf.Empty
|
||||
19, // [19:25] is the sub-list for method output_type
|
||||
13, // [13:19] is the sub-list for method input_type
|
||||
13, // [13:13] is the sub-list for extension type_name
|
||||
13, // [13:13] is the sub-list for extension extendee
|
||||
0, // [0:13] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_api_v1_attachment_service_proto_init() }
|
||||
|
|
@ -840,14 +1288,22 @@ func file_api_v1_attachment_service_proto_init() {
|
|||
if File_api_v1_attachment_service_proto != nil {
|
||||
return
|
||||
}
|
||||
file_api_v1_attachment_service_proto_msgTypes[1].OneofWrappers = []any{}
|
||||
file_api_v1_attachment_service_proto_msgTypes[1].OneofWrappers = []any{
|
||||
(*MediaMetadata_Photo)(nil),
|
||||
(*MediaMetadata_Video)(nil),
|
||||
}
|
||||
file_api_v1_attachment_service_proto_msgTypes[2].OneofWrappers = []any{}
|
||||
file_api_v1_attachment_service_proto_msgTypes[3].OneofWrappers = []any{}
|
||||
file_api_v1_attachment_service_proto_msgTypes[4].OneofWrappers = []any{}
|
||||
file_api_v1_attachment_service_proto_msgTypes[5].OneofWrappers = []any{}
|
||||
file_api_v1_attachment_service_proto_msgTypes[6].OneofWrappers = []any{}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_api_v1_attachment_service_proto_rawDesc), len(file_api_v1_attachment_service_proto_rawDesc)),
|
||||
NumEnums: 2,
|
||||
NumMessages: 9,
|
||||
NumMessages: 14,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2997,9 +2997,11 @@ type UserSetting_GeneralSetting struct {
|
|||
// The preferred theme of the user.
|
||||
// This references a CSS file in the web/public/themes/ directory.
|
||||
// If not set, the default theme will be used.
|
||||
Theme string `protobuf:"bytes,4,opt,name=theme,proto3" json:"theme,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
Theme string `protobuf:"bytes,4,opt,name=theme,proto3" json:"theme,omitempty"`
|
||||
// Whether the official client should save metadata from future media uploads.
|
||||
SaveMediaMetadata bool `protobuf:"varint,5,opt,name=save_media_metadata,json=saveMediaMetadata,proto3" json:"save_media_metadata,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *UserSetting_GeneralSetting) Reset() {
|
||||
|
|
@ -3053,6 +3055,13 @@ func (x *UserSetting_GeneralSetting) GetTheme() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (x *UserSetting_GeneralSetting) GetSaveMediaMetadata() bool {
|
||||
if x != nil {
|
||||
return x.SaveMediaMetadata
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Tag metadata for user-specific display rules.
|
||||
type UserSetting_TagMetadata struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
|
|
@ -3437,16 +3446,17 @@ const file_api_v1_user_service_proto_rawDesc = "" +
|
|||
"\x05state\x18\x01 \x01(\x0e2\x13.memos.api.v1.StateB\x03\xe0A\x01R\x05state\x12\x1b\n" +
|
||||
"\x06filter\x18\x02 \x01(\tB\x03\xe0A\x01R\x06filter\"I\n" +
|
||||
"\x18ListAllUserStatsResponse\x12-\n" +
|
||||
"\x05stats\x18\x01 \x03(\v2\x17.memos.api.v1.UserStatsR\x05stats\"\xbb\a\n" +
|
||||
"\x05stats\x18\x01 \x03(\v2\x17.memos.api.v1.UserStatsR\x05stats\"\xf1\a\n" +
|
||||
"\vUserSetting\x12\x17\n" +
|
||||
"\x04name\x18\x01 \x01(\tB\x03\xe0A\bR\x04name\x12S\n" +
|
||||
"\x0fgeneral_setting\x18\x02 \x01(\v2(.memos.api.v1.UserSetting.GeneralSettingH\x00R\x0egeneralSetting\x12V\n" +
|
||||
"\x10webhooks_setting\x18\x05 \x01(\v2).memos.api.v1.UserSetting.WebhooksSettingH\x00R\x0fwebhooksSetting\x12J\n" +
|
||||
"\ftags_setting\x18\x06 \x01(\v2%.memos.api.v1.UserSetting.TagsSettingH\x00R\vtagsSetting\x1av\n" +
|
||||
"\ftags_setting\x18\x06 \x01(\v2%.memos.api.v1.UserSetting.TagsSettingH\x00R\vtagsSetting\x1a\xab\x01\n" +
|
||||
"\x0eGeneralSetting\x12\x1b\n" +
|
||||
"\x06locale\x18\x01 \x01(\tB\x03\xe0A\x01R\x06locale\x12,\n" +
|
||||
"\x0fmemo_visibility\x18\x03 \x01(\tB\x03\xe0A\x01R\x0ememoVisibility\x12\x19\n" +
|
||||
"\x05theme\x18\x04 \x01(\tB\x03\xe0A\x01R\x05theme\x1ay\n" +
|
||||
"\x05theme\x18\x04 \x01(\tB\x03\xe0A\x01R\x05theme\x123\n" +
|
||||
"\x13save_media_metadata\x18\x05 \x01(\bB\x03\xe0A\x01R\x11saveMediaMetadata\x1ay\n" +
|
||||
"\vTagMetadata\x12B\n" +
|
||||
"\x10background_color\x18\x01 \x01(\v2\x12.google.type.ColorB\x03\xe0A\x01R\x0fbackgroundColor\x12&\n" +
|
||||
"\fblur_content\x18\x02 \x01(\bB\x03\xe0A\x01R\vblurContent\x1a\xb7\x01\n" +
|
||||
|
|
|
|||
|
|
@ -2406,6 +2406,10 @@ components:
|
|||
allOf:
|
||||
- $ref: '#/components/schemas/MotionMedia'
|
||||
description: Optional. Motion media metadata.
|
||||
mediaMetadata:
|
||||
allOf:
|
||||
- $ref: '#/components/schemas/MediaMetadata'
|
||||
description: Optional. Immutable normalized media metadata explicitly supplied by the client at creation time.
|
||||
BatchDeleteAttachmentsRequest:
|
||||
required:
|
||||
- names
|
||||
|
|
@ -3219,6 +3223,38 @@ components:
|
|||
type: number
|
||||
description: The longitude of the location.
|
||||
format: double
|
||||
MediaCaptureTime:
|
||||
type: object
|
||||
properties:
|
||||
localDateTime:
|
||||
type: string
|
||||
utcOffset:
|
||||
type: string
|
||||
MediaLocation:
|
||||
type: object
|
||||
properties:
|
||||
latitude:
|
||||
type: number
|
||||
format: double
|
||||
longitude:
|
||||
type: number
|
||||
format: double
|
||||
altitudeMeters:
|
||||
type: number
|
||||
format: double
|
||||
MediaMetadata:
|
||||
type: object
|
||||
properties:
|
||||
width:
|
||||
type: integer
|
||||
format: int32
|
||||
height:
|
||||
type: integer
|
||||
format: int32
|
||||
photo:
|
||||
$ref: '#/components/schemas/PhotoMetadata'
|
||||
video:
|
||||
$ref: '#/components/schemas/VideoMetadata'
|
||||
Memo:
|
||||
required:
|
||||
- state
|
||||
|
|
@ -3504,6 +3540,34 @@ components:
|
|||
description: |-
|
||||
PersonalAccessToken represents a long-lived token for API/script access.
|
||||
PATs are distinct from short-lived JWT access tokens used for session authentication.
|
||||
PhotoMetadata:
|
||||
type: object
|
||||
properties:
|
||||
captureTime:
|
||||
$ref: '#/components/schemas/MediaCaptureTime'
|
||||
location:
|
||||
$ref: '#/components/schemas/MediaLocation'
|
||||
sourceExifOrientation:
|
||||
type: integer
|
||||
format: int32
|
||||
cameraMake:
|
||||
type: string
|
||||
cameraModel:
|
||||
type: string
|
||||
lensModel:
|
||||
type: string
|
||||
fNumber:
|
||||
type: number
|
||||
format: double
|
||||
exposureTimeSeconds:
|
||||
type: number
|
||||
format: double
|
||||
iso:
|
||||
type: integer
|
||||
format: int32
|
||||
focalLengthMm:
|
||||
type: number
|
||||
format: double
|
||||
Reaction:
|
||||
required:
|
||||
- contentId
|
||||
|
|
@ -3922,6 +3986,9 @@ components:
|
|||
The preferred theme of the user.
|
||||
This references a CSS file in the web/public/themes/ directory.
|
||||
If not set, the default theme will be used.
|
||||
saveMediaMetadata:
|
||||
type: boolean
|
||||
description: Whether the official client should save metadata from future media uploads.
|
||||
description: General user settings configuration.
|
||||
UserSetting_TagMetadata:
|
||||
type: object
|
||||
|
|
@ -4050,6 +4117,12 @@ components:
|
|||
type: boolean
|
||||
description: Whether a signing secret is configured for this webhook.
|
||||
description: UserWebhook represents a webhook owned by a user.
|
||||
VideoMetadata:
|
||||
type: object
|
||||
properties:
|
||||
durationSeconds:
|
||||
type: number
|
||||
format: double
|
||||
tags:
|
||||
- name: AIService
|
||||
- name: AttachmentService
|
||||
|
|
|
|||
|
|
@ -254,6 +254,376 @@ func (x *MotionMedia) GetHasEmbeddedVideo() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
type MediaMetadata struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Width *int32 `protobuf:"varint,1,opt,name=width,proto3,oneof" json:"width,omitempty"`
|
||||
Height *int32 `protobuf:"varint,2,opt,name=height,proto3,oneof" json:"height,omitempty"`
|
||||
// Types that are valid to be assigned to Details:
|
||||
//
|
||||
// *MediaMetadata_Photo
|
||||
// *MediaMetadata_Video
|
||||
Details isMediaMetadata_Details `protobuf_oneof:"details"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *MediaMetadata) Reset() {
|
||||
*x = MediaMetadata{}
|
||||
mi := &file_store_attachment_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *MediaMetadata) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*MediaMetadata) ProtoMessage() {}
|
||||
|
||||
func (x *MediaMetadata) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_store_attachment_proto_msgTypes[1]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use MediaMetadata.ProtoReflect.Descriptor instead.
|
||||
func (*MediaMetadata) Descriptor() ([]byte, []int) {
|
||||
return file_store_attachment_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *MediaMetadata) GetWidth() int32 {
|
||||
if x != nil && x.Width != nil {
|
||||
return *x.Width
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *MediaMetadata) GetHeight() int32 {
|
||||
if x != nil && x.Height != nil {
|
||||
return *x.Height
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *MediaMetadata) GetDetails() isMediaMetadata_Details {
|
||||
if x != nil {
|
||||
return x.Details
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *MediaMetadata) GetPhoto() *PhotoMetadata {
|
||||
if x != nil {
|
||||
if x, ok := x.Details.(*MediaMetadata_Photo); ok {
|
||||
return x.Photo
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *MediaMetadata) GetVideo() *VideoMetadata {
|
||||
if x != nil {
|
||||
if x, ok := x.Details.(*MediaMetadata_Video); ok {
|
||||
return x.Video
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type isMediaMetadata_Details interface {
|
||||
isMediaMetadata_Details()
|
||||
}
|
||||
|
||||
type MediaMetadata_Photo struct {
|
||||
Photo *PhotoMetadata `protobuf:"bytes,3,opt,name=photo,proto3,oneof"`
|
||||
}
|
||||
|
||||
type MediaMetadata_Video struct {
|
||||
Video *VideoMetadata `protobuf:"bytes,4,opt,name=video,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*MediaMetadata_Photo) isMediaMetadata_Details() {}
|
||||
|
||||
func (*MediaMetadata_Video) isMediaMetadata_Details() {}
|
||||
|
||||
type PhotoMetadata struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
CaptureTime *MediaCaptureTime `protobuf:"bytes,1,opt,name=capture_time,json=captureTime,proto3" json:"capture_time,omitempty"`
|
||||
Location *MediaLocation `protobuf:"bytes,2,opt,name=location,proto3" json:"location,omitempty"`
|
||||
SourceExifOrientation *int32 `protobuf:"varint,3,opt,name=source_exif_orientation,json=sourceExifOrientation,proto3,oneof" json:"source_exif_orientation,omitempty"`
|
||||
CameraMake string `protobuf:"bytes,4,opt,name=camera_make,json=cameraMake,proto3" json:"camera_make,omitempty"`
|
||||
CameraModel string `protobuf:"bytes,5,opt,name=camera_model,json=cameraModel,proto3" json:"camera_model,omitempty"`
|
||||
LensModel string `protobuf:"bytes,6,opt,name=lens_model,json=lensModel,proto3" json:"lens_model,omitempty"`
|
||||
FNumber *float64 `protobuf:"fixed64,7,opt,name=f_number,json=fNumber,proto3,oneof" json:"f_number,omitempty"`
|
||||
ExposureTimeSeconds *float64 `protobuf:"fixed64,8,opt,name=exposure_time_seconds,json=exposureTimeSeconds,proto3,oneof" json:"exposure_time_seconds,omitempty"`
|
||||
Iso *int32 `protobuf:"varint,9,opt,name=iso,proto3,oneof" json:"iso,omitempty"`
|
||||
FocalLengthMm *float64 `protobuf:"fixed64,10,opt,name=focal_length_mm,json=focalLengthMm,proto3,oneof" json:"focal_length_mm,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) Reset() {
|
||||
*x = PhotoMetadata{}
|
||||
mi := &file_store_attachment_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*PhotoMetadata) ProtoMessage() {}
|
||||
|
||||
func (x *PhotoMetadata) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_store_attachment_proto_msgTypes[2]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use PhotoMetadata.ProtoReflect.Descriptor instead.
|
||||
func (*PhotoMetadata) Descriptor() ([]byte, []int) {
|
||||
return file_store_attachment_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetCaptureTime() *MediaCaptureTime {
|
||||
if x != nil {
|
||||
return x.CaptureTime
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetLocation() *MediaLocation {
|
||||
if x != nil {
|
||||
return x.Location
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetSourceExifOrientation() int32 {
|
||||
if x != nil && x.SourceExifOrientation != nil {
|
||||
return *x.SourceExifOrientation
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetCameraMake() string {
|
||||
if x != nil {
|
||||
return x.CameraMake
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetCameraModel() string {
|
||||
if x != nil {
|
||||
return x.CameraModel
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetLensModel() string {
|
||||
if x != nil {
|
||||
return x.LensModel
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetFNumber() float64 {
|
||||
if x != nil && x.FNumber != nil {
|
||||
return *x.FNumber
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetExposureTimeSeconds() float64 {
|
||||
if x != nil && x.ExposureTimeSeconds != nil {
|
||||
return *x.ExposureTimeSeconds
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetIso() int32 {
|
||||
if x != nil && x.Iso != nil {
|
||||
return *x.Iso
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *PhotoMetadata) GetFocalLengthMm() float64 {
|
||||
if x != nil && x.FocalLengthMm != nil {
|
||||
return *x.FocalLengthMm
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type MediaCaptureTime struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
LocalDateTime string `protobuf:"bytes,1,opt,name=local_date_time,json=localDateTime,proto3" json:"local_date_time,omitempty"`
|
||||
UtcOffset *string `protobuf:"bytes,2,opt,name=utc_offset,json=utcOffset,proto3,oneof" json:"utc_offset,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *MediaCaptureTime) Reset() {
|
||||
*x = MediaCaptureTime{}
|
||||
mi := &file_store_attachment_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *MediaCaptureTime) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*MediaCaptureTime) ProtoMessage() {}
|
||||
|
||||
func (x *MediaCaptureTime) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_store_attachment_proto_msgTypes[3]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use MediaCaptureTime.ProtoReflect.Descriptor instead.
|
||||
func (*MediaCaptureTime) Descriptor() ([]byte, []int) {
|
||||
return file_store_attachment_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *MediaCaptureTime) GetLocalDateTime() string {
|
||||
if x != nil {
|
||||
return x.LocalDateTime
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MediaCaptureTime) GetUtcOffset() string {
|
||||
if x != nil && x.UtcOffset != nil {
|
||||
return *x.UtcOffset
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type MediaLocation struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Latitude *float64 `protobuf:"fixed64,1,opt,name=latitude,proto3,oneof" json:"latitude,omitempty"`
|
||||
Longitude *float64 `protobuf:"fixed64,2,opt,name=longitude,proto3,oneof" json:"longitude,omitempty"`
|
||||
AltitudeMeters *float64 `protobuf:"fixed64,3,opt,name=altitude_meters,json=altitudeMeters,proto3,oneof" json:"altitude_meters,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *MediaLocation) Reset() {
|
||||
*x = MediaLocation{}
|
||||
mi := &file_store_attachment_proto_msgTypes[4]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *MediaLocation) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*MediaLocation) ProtoMessage() {}
|
||||
|
||||
func (x *MediaLocation) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_store_attachment_proto_msgTypes[4]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use MediaLocation.ProtoReflect.Descriptor instead.
|
||||
func (*MediaLocation) Descriptor() ([]byte, []int) {
|
||||
return file_store_attachment_proto_rawDescGZIP(), []int{4}
|
||||
}
|
||||
|
||||
func (x *MediaLocation) GetLatitude() float64 {
|
||||
if x != nil && x.Latitude != nil {
|
||||
return *x.Latitude
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *MediaLocation) GetLongitude() float64 {
|
||||
if x != nil && x.Longitude != nil {
|
||||
return *x.Longitude
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *MediaLocation) GetAltitudeMeters() float64 {
|
||||
if x != nil && x.AltitudeMeters != nil {
|
||||
return *x.AltitudeMeters
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type VideoMetadata struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
DurationSeconds *float64 `protobuf:"fixed64,1,opt,name=duration_seconds,json=durationSeconds,proto3,oneof" json:"duration_seconds,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *VideoMetadata) Reset() {
|
||||
*x = VideoMetadata{}
|
||||
mi := &file_store_attachment_proto_msgTypes[5]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *VideoMetadata) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*VideoMetadata) ProtoMessage() {}
|
||||
|
||||
func (x *VideoMetadata) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_store_attachment_proto_msgTypes[5]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use VideoMetadata.ProtoReflect.Descriptor instead.
|
||||
func (*VideoMetadata) Descriptor() ([]byte, []int) {
|
||||
return file_store_attachment_proto_rawDescGZIP(), []int{5}
|
||||
}
|
||||
|
||||
func (x *VideoMetadata) GetDurationSeconds() float64 {
|
||||
if x != nil && x.DurationSeconds != nil {
|
||||
return *x.DurationSeconds
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type AttachmentPayload struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Types that are valid to be assigned to Payload:
|
||||
|
|
@ -261,13 +631,14 @@ type AttachmentPayload struct {
|
|||
// *AttachmentPayload_S3Object_
|
||||
Payload isAttachmentPayload_Payload `protobuf_oneof:"payload"`
|
||||
MotionMedia *MotionMedia `protobuf:"bytes,10,opt,name=motion_media,json=motionMedia,proto3" json:"motion_media,omitempty"`
|
||||
MediaMetadata *MediaMetadata `protobuf:"bytes,11,opt,name=media_metadata,json=mediaMetadata,proto3" json:"media_metadata,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *AttachmentPayload) Reset() {
|
||||
*x = AttachmentPayload{}
|
||||
mi := &file_store_attachment_proto_msgTypes[1]
|
||||
mi := &file_store_attachment_proto_msgTypes[6]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -279,7 +650,7 @@ func (x *AttachmentPayload) String() string {
|
|||
func (*AttachmentPayload) ProtoMessage() {}
|
||||
|
||||
func (x *AttachmentPayload) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_store_attachment_proto_msgTypes[1]
|
||||
mi := &file_store_attachment_proto_msgTypes[6]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -292,7 +663,7 @@ func (x *AttachmentPayload) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use AttachmentPayload.ProtoReflect.Descriptor instead.
|
||||
func (*AttachmentPayload) Descriptor() ([]byte, []int) {
|
||||
return file_store_attachment_proto_rawDescGZIP(), []int{1}
|
||||
return file_store_attachment_proto_rawDescGZIP(), []int{6}
|
||||
}
|
||||
|
||||
func (x *AttachmentPayload) GetPayload() isAttachmentPayload_Payload {
|
||||
|
|
@ -318,6 +689,13 @@ func (x *AttachmentPayload) GetMotionMedia() *MotionMedia {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (x *AttachmentPayload) GetMediaMetadata() *MediaMetadata {
|
||||
if x != nil {
|
||||
return x.MediaMetadata
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type isAttachmentPayload_Payload interface {
|
||||
isAttachmentPayload_Payload()
|
||||
}
|
||||
|
|
@ -342,7 +720,7 @@ type AttachmentPayload_S3Object struct {
|
|||
|
||||
func (x *AttachmentPayload_S3Object) Reset() {
|
||||
*x = AttachmentPayload_S3Object{}
|
||||
mi := &file_store_attachment_proto_msgTypes[2]
|
||||
mi := &file_store_attachment_proto_msgTypes[7]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
|
@ -354,7 +732,7 @@ func (x *AttachmentPayload_S3Object) String() string {
|
|||
func (*AttachmentPayload_S3Object) ProtoMessage() {}
|
||||
|
||||
func (x *AttachmentPayload_S3Object) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_store_attachment_proto_msgTypes[2]
|
||||
mi := &file_store_attachment_proto_msgTypes[7]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
|
|
@ -367,7 +745,7 @@ func (x *AttachmentPayload_S3Object) ProtoReflect() protoreflect.Message {
|
|||
|
||||
// Deprecated: Use AttachmentPayload_S3Object.ProtoReflect.Descriptor instead.
|
||||
func (*AttachmentPayload_S3Object) Descriptor() ([]byte, []int) {
|
||||
return file_store_attachment_proto_rawDescGZIP(), []int{1, 0}
|
||||
return file_store_attachment_proto_rawDescGZIP(), []int{6, 0}
|
||||
}
|
||||
|
||||
func (x *AttachmentPayload_S3Object) GetS3Config() *StorageS3Config {
|
||||
|
|
@ -401,11 +779,55 @@ const file_store_attachment_proto_rawDesc = "" +
|
|||
"\x04role\x18\x02 \x01(\x0e2\x1c.memos.store.MotionMediaRoleR\x04role\x12\x19\n" +
|
||||
"\bgroup_id\x18\x03 \x01(\tR\agroupId\x12:\n" +
|
||||
"\x19presentation_timestamp_us\x18\x04 \x01(\x03R\x17presentationTimestampUs\x12,\n" +
|
||||
"\x12has_embedded_video\x18\x05 \x01(\bR\x10hasEmbeddedVideo\"\xc9\x02\n" +
|
||||
"\x12has_embedded_video\x18\x05 \x01(\bR\x10hasEmbeddedVideo\"\xcf\x01\n" +
|
||||
"\rMediaMetadata\x12\x19\n" +
|
||||
"\x05width\x18\x01 \x01(\x05H\x01R\x05width\x88\x01\x01\x12\x1b\n" +
|
||||
"\x06height\x18\x02 \x01(\x05H\x02R\x06height\x88\x01\x01\x122\n" +
|
||||
"\x05photo\x18\x03 \x01(\v2\x1a.memos.store.PhotoMetadataH\x00R\x05photo\x122\n" +
|
||||
"\x05video\x18\x04 \x01(\v2\x1a.memos.store.VideoMetadataH\x00R\x05videoB\t\n" +
|
||||
"\adetailsB\b\n" +
|
||||
"\x06_widthB\t\n" +
|
||||
"\a_height\"\xa5\x04\n" +
|
||||
"\rPhotoMetadata\x12@\n" +
|
||||
"\fcapture_time\x18\x01 \x01(\v2\x1d.memos.store.MediaCaptureTimeR\vcaptureTime\x126\n" +
|
||||
"\blocation\x18\x02 \x01(\v2\x1a.memos.store.MediaLocationR\blocation\x12;\n" +
|
||||
"\x17source_exif_orientation\x18\x03 \x01(\x05H\x00R\x15sourceExifOrientation\x88\x01\x01\x12\x1f\n" +
|
||||
"\vcamera_make\x18\x04 \x01(\tR\n" +
|
||||
"cameraMake\x12!\n" +
|
||||
"\fcamera_model\x18\x05 \x01(\tR\vcameraModel\x12\x1d\n" +
|
||||
"\n" +
|
||||
"lens_model\x18\x06 \x01(\tR\tlensModel\x12\x1e\n" +
|
||||
"\bf_number\x18\a \x01(\x01H\x01R\afNumber\x88\x01\x01\x127\n" +
|
||||
"\x15exposure_time_seconds\x18\b \x01(\x01H\x02R\x13exposureTimeSeconds\x88\x01\x01\x12\x15\n" +
|
||||
"\x03iso\x18\t \x01(\x05H\x03R\x03iso\x88\x01\x01\x12+\n" +
|
||||
"\x0ffocal_length_mm\x18\n" +
|
||||
" \x01(\x01H\x04R\rfocalLengthMm\x88\x01\x01B\x1a\n" +
|
||||
"\x18_source_exif_orientationB\v\n" +
|
||||
"\t_f_numberB\x18\n" +
|
||||
"\x16_exposure_time_secondsB\x06\n" +
|
||||
"\x04_isoB\x12\n" +
|
||||
"\x10_focal_length_mm\"m\n" +
|
||||
"\x10MediaCaptureTime\x12&\n" +
|
||||
"\x0flocal_date_time\x18\x01 \x01(\tR\rlocalDateTime\x12\"\n" +
|
||||
"\n" +
|
||||
"utc_offset\x18\x02 \x01(\tH\x00R\tutcOffset\x88\x01\x01B\r\n" +
|
||||
"\v_utc_offset\"\xb0\x01\n" +
|
||||
"\rMediaLocation\x12\x1f\n" +
|
||||
"\blatitude\x18\x01 \x01(\x01H\x00R\blatitude\x88\x01\x01\x12!\n" +
|
||||
"\tlongitude\x18\x02 \x01(\x01H\x01R\tlongitude\x88\x01\x01\x12,\n" +
|
||||
"\x0faltitude_meters\x18\x03 \x01(\x01H\x02R\x0ealtitudeMeters\x88\x01\x01B\v\n" +
|
||||
"\t_latitudeB\f\n" +
|
||||
"\n" +
|
||||
"_longitudeB\x12\n" +
|
||||
"\x10_altitude_meters\"T\n" +
|
||||
"\rVideoMetadata\x12.\n" +
|
||||
"\x10duration_seconds\x18\x01 \x01(\x01H\x00R\x0fdurationSeconds\x88\x01\x01B\x13\n" +
|
||||
"\x11_duration_seconds\"\x8c\x03\n" +
|
||||
"\x11AttachmentPayload\x12F\n" +
|
||||
"\ts3_object\x18\x01 \x01(\v2'.memos.store.AttachmentPayload.S3ObjectH\x00R\bs3Object\x12;\n" +
|
||||
"\fmotion_media\x18\n" +
|
||||
" \x01(\v2\x18.memos.store.MotionMediaR\vmotionMedia\x1a\xa3\x01\n" +
|
||||
" \x01(\v2\x18.memos.store.MotionMediaR\vmotionMedia\x12A\n" +
|
||||
"\x0emedia_metadata\x18\v \x01(\v2\x1a.memos.store.MediaMetadataR\rmediaMetadata\x1a\xa3\x01\n" +
|
||||
"\bS3Object\x129\n" +
|
||||
"\ts3_config\x18\x01 \x01(\v2\x1c.memos.store.StorageS3ConfigR\bs3Config\x12\x10\n" +
|
||||
"\x03key\x18\x02 \x01(\tR\x03key\x12J\n" +
|
||||
|
|
@ -440,29 +862,39 @@ func file_store_attachment_proto_rawDescGZIP() []byte {
|
|||
}
|
||||
|
||||
var file_store_attachment_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
|
||||
var file_store_attachment_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_store_attachment_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
|
||||
var file_store_attachment_proto_goTypes = []any{
|
||||
(AttachmentStorageType)(0), // 0: memos.store.AttachmentStorageType
|
||||
(MotionMediaFamily)(0), // 1: memos.store.MotionMediaFamily
|
||||
(MotionMediaRole)(0), // 2: memos.store.MotionMediaRole
|
||||
(*MotionMedia)(nil), // 3: memos.store.MotionMedia
|
||||
(*AttachmentPayload)(nil), // 4: memos.store.AttachmentPayload
|
||||
(*AttachmentPayload_S3Object)(nil), // 5: memos.store.AttachmentPayload.S3Object
|
||||
(*StorageS3Config)(nil), // 6: memos.store.StorageS3Config
|
||||
(*timestamppb.Timestamp)(nil), // 7: google.protobuf.Timestamp
|
||||
(*MediaMetadata)(nil), // 4: memos.store.MediaMetadata
|
||||
(*PhotoMetadata)(nil), // 5: memos.store.PhotoMetadata
|
||||
(*MediaCaptureTime)(nil), // 6: memos.store.MediaCaptureTime
|
||||
(*MediaLocation)(nil), // 7: memos.store.MediaLocation
|
||||
(*VideoMetadata)(nil), // 8: memos.store.VideoMetadata
|
||||
(*AttachmentPayload)(nil), // 9: memos.store.AttachmentPayload
|
||||
(*AttachmentPayload_S3Object)(nil), // 10: memos.store.AttachmentPayload.S3Object
|
||||
(*StorageS3Config)(nil), // 11: memos.store.StorageS3Config
|
||||
(*timestamppb.Timestamp)(nil), // 12: google.protobuf.Timestamp
|
||||
}
|
||||
var file_store_attachment_proto_depIdxs = []int32{
|
||||
1, // 0: memos.store.MotionMedia.family:type_name -> memos.store.MotionMediaFamily
|
||||
2, // 1: memos.store.MotionMedia.role:type_name -> memos.store.MotionMediaRole
|
||||
5, // 2: memos.store.AttachmentPayload.s3_object:type_name -> memos.store.AttachmentPayload.S3Object
|
||||
3, // 3: memos.store.AttachmentPayload.motion_media:type_name -> memos.store.MotionMedia
|
||||
6, // 4: memos.store.AttachmentPayload.S3Object.s3_config:type_name -> memos.store.StorageS3Config
|
||||
7, // 5: memos.store.AttachmentPayload.S3Object.last_presigned_time:type_name -> google.protobuf.Timestamp
|
||||
6, // [6:6] is the sub-list for method output_type
|
||||
6, // [6:6] is the sub-list for method input_type
|
||||
6, // [6:6] is the sub-list for extension type_name
|
||||
6, // [6:6] is the sub-list for extension extendee
|
||||
0, // [0:6] is the sub-list for field type_name
|
||||
1, // 0: memos.store.MotionMedia.family:type_name -> memos.store.MotionMediaFamily
|
||||
2, // 1: memos.store.MotionMedia.role:type_name -> memos.store.MotionMediaRole
|
||||
5, // 2: memos.store.MediaMetadata.photo:type_name -> memos.store.PhotoMetadata
|
||||
8, // 3: memos.store.MediaMetadata.video:type_name -> memos.store.VideoMetadata
|
||||
6, // 4: memos.store.PhotoMetadata.capture_time:type_name -> memos.store.MediaCaptureTime
|
||||
7, // 5: memos.store.PhotoMetadata.location:type_name -> memos.store.MediaLocation
|
||||
10, // 6: memos.store.AttachmentPayload.s3_object:type_name -> memos.store.AttachmentPayload.S3Object
|
||||
3, // 7: memos.store.AttachmentPayload.motion_media:type_name -> memos.store.MotionMedia
|
||||
4, // 8: memos.store.AttachmentPayload.media_metadata:type_name -> memos.store.MediaMetadata
|
||||
11, // 9: memos.store.AttachmentPayload.S3Object.s3_config:type_name -> memos.store.StorageS3Config
|
||||
12, // 10: memos.store.AttachmentPayload.S3Object.last_presigned_time:type_name -> google.protobuf.Timestamp
|
||||
11, // [11:11] is the sub-list for method output_type
|
||||
11, // [11:11] is the sub-list for method input_type
|
||||
11, // [11:11] is the sub-list for extension type_name
|
||||
11, // [11:11] is the sub-list for extension extendee
|
||||
0, // [0:11] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_store_attachment_proto_init() }
|
||||
|
|
@ -472,6 +904,14 @@ func file_store_attachment_proto_init() {
|
|||
}
|
||||
file_store_instance_setting_proto_init()
|
||||
file_store_attachment_proto_msgTypes[1].OneofWrappers = []any{
|
||||
(*MediaMetadata_Photo)(nil),
|
||||
(*MediaMetadata_Video)(nil),
|
||||
}
|
||||
file_store_attachment_proto_msgTypes[2].OneofWrappers = []any{}
|
||||
file_store_attachment_proto_msgTypes[3].OneofWrappers = []any{}
|
||||
file_store_attachment_proto_msgTypes[4].OneofWrappers = []any{}
|
||||
file_store_attachment_proto_msgTypes[5].OneofWrappers = []any{}
|
||||
file_store_attachment_proto_msgTypes[6].OneofWrappers = []any{
|
||||
(*AttachmentPayload_S3Object_)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
|
|
@ -480,7 +920,7 @@ func file_store_attachment_proto_init() {
|
|||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_store_attachment_proto_rawDesc), len(file_store_attachment_proto_rawDesc)),
|
||||
NumEnums: 3,
|
||||
NumMessages: 3,
|
||||
NumMessages: 8,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -260,9 +260,11 @@ type GeneralUserSetting struct {
|
|||
MemoVisibility string `protobuf:"bytes,2,opt,name=memo_visibility,json=memoVisibility,proto3" json:"memo_visibility,omitempty"`
|
||||
// The user's theme preference.
|
||||
// This references a CSS file in the web/public/themes/ directory.
|
||||
Theme string `protobuf:"bytes,3,opt,name=theme,proto3" json:"theme,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
Theme string `protobuf:"bytes,3,opt,name=theme,proto3" json:"theme,omitempty"`
|
||||
// Whether the official client should save metadata from future media uploads.
|
||||
SaveMediaMetadata bool `protobuf:"varint,4,opt,name=save_media_metadata,json=saveMediaMetadata,proto3" json:"save_media_metadata,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *GeneralUserSetting) Reset() {
|
||||
|
|
@ -316,6 +318,13 @@ func (x *GeneralUserSetting) GetTheme() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (x *GeneralUserSetting) GetSaveMediaMetadata() bool {
|
||||
if x != nil {
|
||||
return x.SaveMediaMetadata
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type UserTagMetadata struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
// Optional background color for the tag label.
|
||||
|
|
@ -1004,11 +1013,12 @@ const file_store_user_setting_proto_rawDesc = "" +
|
|||
"\x0eREFRESH_TOKENS\x10\x06\x12\x1a\n" +
|
||||
"\x16PERSONAL_ACCESS_TOKENS\x10\a\x12\b\n" +
|
||||
"\x04TAGS\x10\bB\a\n" +
|
||||
"\x05value\"k\n" +
|
||||
"\x05value\"\x9b\x01\n" +
|
||||
"\x12GeneralUserSetting\x12\x16\n" +
|
||||
"\x06locale\x18\x01 \x01(\tR\x06locale\x12'\n" +
|
||||
"\x0fmemo_visibility\x18\x02 \x01(\tR\x0ememoVisibility\x12\x14\n" +
|
||||
"\x05theme\x18\x03 \x01(\tR\x05theme\"s\n" +
|
||||
"\x05theme\x18\x03 \x01(\tR\x05theme\x12.\n" +
|
||||
"\x13save_media_metadata\x18\x04 \x01(\bR\x11saveMediaMetadata\"s\n" +
|
||||
"\x0fUserTagMetadata\x12=\n" +
|
||||
"\x10background_color\x18\x01 \x01(\v2\x12.google.type.ColorR\x0fbackgroundColor\x12!\n" +
|
||||
"\fblur_content\x18\x02 \x01(\bR\vblurContent\"\xa4\x01\n" +
|
||||
|
|
|
|||
|
|
@ -38,12 +38,51 @@ message MotionMedia {
|
|||
bool has_embedded_video = 5;
|
||||
}
|
||||
|
||||
message MediaMetadata {
|
||||
optional int32 width = 1;
|
||||
optional int32 height = 2;
|
||||
|
||||
oneof details {
|
||||
PhotoMetadata photo = 3;
|
||||
VideoMetadata video = 4;
|
||||
}
|
||||
}
|
||||
|
||||
message PhotoMetadata {
|
||||
MediaCaptureTime capture_time = 1;
|
||||
MediaLocation location = 2;
|
||||
optional int32 source_exif_orientation = 3;
|
||||
string camera_make = 4;
|
||||
string camera_model = 5;
|
||||
string lens_model = 6;
|
||||
optional double f_number = 7;
|
||||
optional double exposure_time_seconds = 8;
|
||||
optional int32 iso = 9;
|
||||
optional double focal_length_mm = 10;
|
||||
}
|
||||
|
||||
message MediaCaptureTime {
|
||||
string local_date_time = 1;
|
||||
optional string utc_offset = 2;
|
||||
}
|
||||
|
||||
message MediaLocation {
|
||||
optional double latitude = 1;
|
||||
optional double longitude = 2;
|
||||
optional double altitude_meters = 3;
|
||||
}
|
||||
|
||||
message VideoMetadata {
|
||||
optional double duration_seconds = 1;
|
||||
}
|
||||
|
||||
message AttachmentPayload {
|
||||
oneof payload {
|
||||
S3Object s3_object = 1;
|
||||
}
|
||||
|
||||
MotionMedia motion_media = 10;
|
||||
MediaMetadata media_metadata = 11;
|
||||
|
||||
message S3Object {
|
||||
StorageS3Config s3_config = 1;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@ message GeneralUserSetting {
|
|||
// The user's theme preference.
|
||||
// This references a CSS file in the web/public/themes/ directory.
|
||||
string theme = 3;
|
||||
// Whether the official client should save metadata from future media uploads.
|
||||
bool save_media_metadata = 4;
|
||||
}
|
||||
|
||||
message UserTagMetadata {
|
||||
|
|
|
|||
204
server/router/api/v1/attachment_media_metadata.go
Normal file
204
server/router/api/v1/attachment_media_metadata.go
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"math"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
)
|
||||
|
||||
const maxMediaMetadataStringBytes = 256
|
||||
|
||||
var (
|
||||
mediaLocalDateTimePattern = regexp.MustCompile(`^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?$`)
|
||||
mediaUTCOffsetPattern = regexp.MustCompile(`^[+-](\d{2}):(\d{2})$`)
|
||||
)
|
||||
|
||||
func validateClientMediaMetadata(metadata *v1pb.MediaMetadata, mimeType string) (*storepb.MediaMetadata, error) {
|
||||
if metadata == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
normalizedMIMEType := strings.ToLower(mimeType)
|
||||
isImage := strings.HasPrefix(normalizedMIMEType, "image/")
|
||||
isVideo := strings.HasPrefix(normalizedMIMEType, "video/")
|
||||
if !isImage && !isVideo {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "media_metadata is only supported for image and video attachments")
|
||||
}
|
||||
|
||||
if (metadata.Width == nil) != (metadata.Height == nil) {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "media_metadata width and height must be provided together")
|
||||
}
|
||||
if metadata.Width != nil && (*metadata.Width <= 0 || *metadata.Height <= 0) {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "media_metadata width and height must be positive")
|
||||
}
|
||||
|
||||
switch details := metadata.Details.(type) {
|
||||
case nil:
|
||||
if metadata.Width == nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "media_metadata must contain at least one value")
|
||||
}
|
||||
case *v1pb.MediaMetadata_Photo:
|
||||
if !isImage {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "photo metadata requires an image MIME type")
|
||||
}
|
||||
if proto.Size(details.Photo) == 0 {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "photo metadata must contain at least one value")
|
||||
}
|
||||
if err := validatePhotoMetadata(details.Photo); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case *v1pb.MediaMetadata_Video:
|
||||
if !isVideo {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "video metadata requires a video MIME type")
|
||||
}
|
||||
if details.Video == nil || details.Video.DurationSeconds == nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "video metadata must contain at least one value")
|
||||
}
|
||||
if !isFinite(*details.Video.DurationSeconds) || *details.Video.DurationSeconds < 0 {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "video duration_seconds must be a finite non-negative number")
|
||||
}
|
||||
default:
|
||||
return nil, status.Errorf(codes.InvalidArgument, "unsupported media_metadata details")
|
||||
}
|
||||
|
||||
storeMetadata := &storepb.MediaMetadata{}
|
||||
if err := transcodeProto(metadata, storeMetadata); err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to convert media_metadata: %v", err)
|
||||
}
|
||||
return storeMetadata, nil
|
||||
}
|
||||
|
||||
func validatePhotoMetadata(photo *v1pb.PhotoMetadata) error {
|
||||
if photo.SourceExifOrientation != nil && (*photo.SourceExifOrientation < 1 || *photo.SourceExifOrientation > 8) {
|
||||
return status.Errorf(codes.InvalidArgument, "photo source_exif_orientation must be between 1 and 8")
|
||||
}
|
||||
for _, field := range []struct {
|
||||
name string
|
||||
value string
|
||||
}{
|
||||
{"camera_make", photo.CameraMake},
|
||||
{"camera_model", photo.CameraModel},
|
||||
{"lens_model", photo.LensModel},
|
||||
} {
|
||||
if field.value == "" {
|
||||
continue
|
||||
}
|
||||
if len(field.value) > maxMediaMetadataStringBytes {
|
||||
return status.Errorf(codes.InvalidArgument, "photo %s exceeds %d bytes", field.name, maxMediaMetadataStringBytes)
|
||||
}
|
||||
if strings.TrimSpace(field.value) == "" {
|
||||
return status.Errorf(codes.InvalidArgument, "photo %s must not be blank", field.name)
|
||||
}
|
||||
if strings.ContainsFunc(field.value, unicode.IsControl) {
|
||||
return status.Errorf(codes.InvalidArgument, "photo %s must not contain control characters", field.name)
|
||||
}
|
||||
}
|
||||
for _, field := range []struct {
|
||||
name string
|
||||
value *float64
|
||||
}{
|
||||
{"f_number", photo.FNumber},
|
||||
{"exposure_time_seconds", photo.ExposureTimeSeconds},
|
||||
{"focal_length_mm", photo.FocalLengthMm},
|
||||
} {
|
||||
if field.value != nil && (!isFinite(*field.value) || *field.value <= 0) {
|
||||
return status.Errorf(codes.InvalidArgument, "photo %s must be a finite positive number", field.name)
|
||||
}
|
||||
}
|
||||
if photo.Iso != nil && *photo.Iso <= 0 {
|
||||
return status.Errorf(codes.InvalidArgument, "photo iso must be positive")
|
||||
}
|
||||
if err := validateMediaCaptureTime(photo.CaptureTime); err != nil {
|
||||
return err
|
||||
}
|
||||
return validateMediaLocation(photo.Location)
|
||||
}
|
||||
|
||||
func validateMediaCaptureTime(captureTime *v1pb.MediaCaptureTime) error {
|
||||
if captureTime == nil {
|
||||
return nil
|
||||
}
|
||||
if !mediaLocalDateTimePattern.MatchString(captureTime.LocalDateTime) {
|
||||
return status.Errorf(codes.InvalidArgument, "capture_time local_date_time has an invalid format")
|
||||
}
|
||||
parsed, err := time.Parse("2006-01-02T15:04:05", captureTime.LocalDateTime)
|
||||
if err != nil || parsed.Year() == 0 {
|
||||
return status.Errorf(codes.InvalidArgument, "capture_time local_date_time is invalid")
|
||||
}
|
||||
if captureTime.UtcOffset == nil {
|
||||
return nil
|
||||
}
|
||||
if *captureTime.UtcOffset == "Z" {
|
||||
return nil
|
||||
}
|
||||
match := mediaUTCOffsetPattern.FindStringSubmatch(*captureTime.UtcOffset)
|
||||
if match == nil {
|
||||
return status.Errorf(codes.InvalidArgument, "capture_time utc_offset has an invalid format")
|
||||
}
|
||||
hours, _ := strconv.Atoi(match[1])
|
||||
minutes, _ := strconv.Atoi(match[2])
|
||||
if hours > 14 || minutes > 59 || (hours == 14 && minutes != 0) {
|
||||
return status.Errorf(codes.InvalidArgument, "capture_time utc_offset is outside the supported range")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateMediaLocation(location *v1pb.MediaLocation) error {
|
||||
if location == nil {
|
||||
return nil
|
||||
}
|
||||
if location.Latitude == nil || location.Longitude == nil {
|
||||
return status.Errorf(codes.InvalidArgument, "location latitude and longitude must be provided together")
|
||||
}
|
||||
if !isFinite(*location.Latitude) || *location.Latitude < -90 || *location.Latitude > 90 {
|
||||
return status.Errorf(codes.InvalidArgument, "location latitude must be between -90 and 90")
|
||||
}
|
||||
if !isFinite(*location.Longitude) || *location.Longitude < -180 || *location.Longitude > 180 {
|
||||
return status.Errorf(codes.InvalidArgument, "location longitude must be between -180 and 180")
|
||||
}
|
||||
if location.AltitudeMeters != nil && !isFinite(*location.AltitudeMeters) {
|
||||
return status.Errorf(codes.InvalidArgument, "location altitude_meters must be finite")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func isFinite(value float64) bool {
|
||||
return !math.IsNaN(value) && !math.IsInf(value, 0)
|
||||
}
|
||||
|
||||
// transcodeProto copies src into dst through the wire format. The API and
|
||||
// store MediaMetadata message trees are declared field-for-field identical, so
|
||||
// the round-trip is the entire conversion; unknown fields (e.g. from a newer
|
||||
// client) are dropped rather than stored.
|
||||
func transcodeProto(src, dst proto.Message) error {
|
||||
data, err := proto.Marshal(src)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "failed to marshal source protobuf")
|
||||
}
|
||||
if err := (proto.UnmarshalOptions{DiscardUnknown: true}).Unmarshal(data, dst); err != nil {
|
||||
return errors.Wrap(err, "failed to unmarshal destination protobuf")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convertMediaMetadataFromStore(metadata *storepb.MediaMetadata) *v1pb.MediaMetadata {
|
||||
if metadata == nil {
|
||||
return nil
|
||||
}
|
||||
apiMetadata := &v1pb.MediaMetadata{}
|
||||
if err := transcodeProto(metadata, apiMetadata); err != nil {
|
||||
return nil
|
||||
}
|
||||
return apiMetadata
|
||||
}
|
||||
123
server/router/api/v1/attachment_media_metadata_test.go
Normal file
123
server/router/api/v1/attachment_media_metadata_test.go
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
package v1
|
||||
|
||||
import (
|
||||
"math"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
)
|
||||
|
||||
func TestValidateClientMediaMetadata(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
validPhoto := func() *v1pb.MediaMetadata {
|
||||
return &v1pb.MediaMetadata{
|
||||
Width: proto.Int32(4032),
|
||||
Height: proto.Int32(3024),
|
||||
Details: &v1pb.MediaMetadata_Photo{Photo: &v1pb.PhotoMetadata{
|
||||
CaptureTime: &v1pb.MediaCaptureTime{
|
||||
LocalDateTime: "2026-08-10T14:32:18.123",
|
||||
UtcOffset: proto.String("+08:00"),
|
||||
},
|
||||
Location: &v1pb.MediaLocation{
|
||||
Latitude: proto.Float64(1.3521),
|
||||
Longitude: proto.Float64(103.8198),
|
||||
AltitudeMeters: proto.Float64(18.4),
|
||||
},
|
||||
SourceExifOrientation: proto.Int32(6),
|
||||
CameraMake: "Apple",
|
||||
CameraModel: "iPhone",
|
||||
LensModel: "Main Camera",
|
||||
FNumber: proto.Float64(1.78),
|
||||
ExposureTimeSeconds: proto.Float64(1.0 / 120.0),
|
||||
Iso: proto.Int32(64),
|
||||
FocalLengthMm: proto.Float64(6.86),
|
||||
}},
|
||||
}
|
||||
}
|
||||
|
||||
t.Run("accepts photo metadata", func(t *testing.T) {
|
||||
metadata, err := validateClientMediaMetadata(validPhoto(), "image/jpeg")
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, int32(4032), metadata.GetWidth())
|
||||
require.Equal(t, "Apple", metadata.GetPhoto().GetCameraMake())
|
||||
})
|
||||
|
||||
t.Run("accepts dimensions without details", func(t *testing.T) {
|
||||
metadata, err := validateClientMediaMetadata(&v1pb.MediaMetadata{
|
||||
Width: proto.Int32(1920), Height: proto.Int32(1080),
|
||||
}, "video/mp4")
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, int32(1920), metadata.GetWidth())
|
||||
})
|
||||
|
||||
t.Run("accepts video metadata", func(t *testing.T) {
|
||||
metadata, err := validateClientMediaMetadata(&v1pb.MediaMetadata{
|
||||
Details: &v1pb.MediaMetadata_Video{Video: &v1pb.VideoMetadata{DurationSeconds: proto.Float64(12.5)}},
|
||||
}, "video/mp4")
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 12.5, metadata.GetVideo().GetDurationSeconds())
|
||||
})
|
||||
|
||||
t.Run("accepts uppercase MIME type", func(t *testing.T) {
|
||||
metadata, err := validateClientMediaMetadata(validPhoto(), "IMAGE/JPEG")
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "Apple", metadata.GetPhoto().GetCameraMake())
|
||||
})
|
||||
|
||||
t.Run("accepts Z UTC offset", func(t *testing.T) {
|
||||
metadata, err := validateClientMediaMetadata(photoOnly(&v1pb.PhotoMetadata{
|
||||
CaptureTime: &v1pb.MediaCaptureTime{LocalDateTime: "2026-08-10T14:32:18", UtcOffset: proto.String("Z")},
|
||||
}), "image/jpeg")
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "Z", metadata.GetPhoto().GetCaptureTime().GetUtcOffset())
|
||||
})
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
mimeType string
|
||||
metadata *v1pb.MediaMetadata
|
||||
}{
|
||||
{name: "empty", mimeType: "image/jpeg", metadata: &v1pb.MediaMetadata{}},
|
||||
{name: "non-media MIME", mimeType: "application/pdf", metadata: validPhoto()},
|
||||
{name: "width without height", mimeType: "image/jpeg", metadata: &v1pb.MediaMetadata{Width: proto.Int32(100)}},
|
||||
{name: "non-positive dimension", mimeType: "image/jpeg", metadata: &v1pb.MediaMetadata{Width: proto.Int32(0), Height: proto.Int32(100)}},
|
||||
{name: "photo on video", mimeType: "video/mp4", metadata: validPhoto()},
|
||||
{name: "empty photo", mimeType: "image/jpeg", metadata: &v1pb.MediaMetadata{Details: &v1pb.MediaMetadata_Photo{Photo: &v1pb.PhotoMetadata{}}}},
|
||||
{name: "video on image", mimeType: "image/jpeg", metadata: &v1pb.MediaMetadata{Details: &v1pb.MediaMetadata_Video{Video: &v1pb.VideoMetadata{DurationSeconds: proto.Float64(1)}}}},
|
||||
{name: "empty video", mimeType: "video/mp4", metadata: &v1pb.MediaMetadata{Details: &v1pb.MediaMetadata_Video{Video: &v1pb.VideoMetadata{}}}},
|
||||
{name: "invalid source EXIF orientation", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{SourceExifOrientation: proto.Int32(9)})},
|
||||
{name: "blank camera make", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{CameraMake: " "})},
|
||||
{name: "control character in camera make", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{CameraMake: "Apple\nCo"})},
|
||||
{name: "null byte in lens model", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{LensModel: "Main\x00Camera"})},
|
||||
{name: "long camera model", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{CameraModel: strings.Repeat("x", maxMediaMetadataStringBytes+1)})},
|
||||
{name: "non-finite aperture", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{FNumber: proto.Float64(math.NaN())})},
|
||||
{name: "zero exposure", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{ExposureTimeSeconds: proto.Float64(0)})},
|
||||
{name: "zero ISO", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{Iso: proto.Int32(0)})},
|
||||
{name: "invalid capture format", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{CaptureTime: &v1pb.MediaCaptureTime{LocalDateTime: "2026:08:10 14:32:18"}})},
|
||||
{name: "invalid calendar date", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{CaptureTime: &v1pb.MediaCaptureTime{LocalDateTime: "2026-02-30T14:32:18"}})},
|
||||
{name: "invalid offset", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{CaptureTime: &v1pb.MediaCaptureTime{LocalDateTime: "2026-08-10T14:32:18", UtcOffset: proto.String("+14:30")}})},
|
||||
{name: "missing longitude", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{Location: &v1pb.MediaLocation{Latitude: proto.Float64(1)}})},
|
||||
{name: "latitude out of range", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{Location: &v1pb.MediaLocation{Latitude: proto.Float64(91), Longitude: proto.Float64(1)}})},
|
||||
{name: "non-finite altitude", mimeType: "image/jpeg", metadata: photoOnly(&v1pb.PhotoMetadata{Location: &v1pb.MediaLocation{Latitude: proto.Float64(1), Longitude: proto.Float64(1), AltitudeMeters: proto.Float64(math.Inf(1))}})},
|
||||
{name: "negative duration", mimeType: "video/mp4", metadata: &v1pb.MediaMetadata{Details: &v1pb.MediaMetadata_Video{Video: &v1pb.VideoMetadata{DurationSeconds: proto.Float64(-1)}}}},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
_, err := validateClientMediaMetadata(test.metadata, test.mimeType)
|
||||
require.Error(t, err)
|
||||
require.Equal(t, codes.InvalidArgument, status.Code(err))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func photoOnly(photo *v1pb.PhotoMetadata) *v1pb.MediaMetadata {
|
||||
return &v1pb.MediaMetadata{Details: &v1pb.MediaMetadata_Photo{Photo: photo}}
|
||||
}
|
||||
|
|
@ -111,6 +111,14 @@ func (s *APIV1Service) CreateAttachment(ctx context.Context, request *v1pb.Creat
|
|||
create.Payload = ensureAttachmentPayload(create.Payload)
|
||||
create.Payload.MotionMedia = inputMotionMedia
|
||||
}
|
||||
inputMediaMetadata, err := validateClientMediaMetadata(request.Attachment.MediaMetadata, request.Attachment.Type)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if inputMediaMetadata != nil {
|
||||
create.Payload = ensureAttachmentPayload(create.Payload)
|
||||
create.Payload.MediaMetadata = inputMediaMetadata
|
||||
}
|
||||
|
||||
instanceStorageSetting, err := s.Store.GetInstanceStorageSetting(ctx)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -25,12 +25,13 @@ import (
|
|||
|
||||
func convertAttachmentFromStore(attachment *store.Attachment) *v1pb.Attachment {
|
||||
attachmentMessage := &v1pb.Attachment{
|
||||
Name: fmt.Sprintf("%s%s", AttachmentNamePrefix, attachment.UID),
|
||||
CreateTime: timestamppb.New(time.Unix(attachment.CreatedTs, 0)),
|
||||
Filename: attachment.Filename,
|
||||
Type: attachment.Type,
|
||||
Size: attachment.Size,
|
||||
MotionMedia: convertMotionMediaFromStore(getAttachmentMotionMedia(attachment)),
|
||||
Name: fmt.Sprintf("%s%s", AttachmentNamePrefix, attachment.UID),
|
||||
CreateTime: timestamppb.New(time.Unix(attachment.CreatedTs, 0)),
|
||||
Filename: attachment.Filename,
|
||||
Type: attachment.Type,
|
||||
Size: attachment.Size,
|
||||
MotionMedia: convertMotionMediaFromStore(getAttachmentMotionMedia(attachment)),
|
||||
MediaMetadata: convertMediaMetadataFromStore(attachment.Payload.GetMediaMetadata()),
|
||||
}
|
||||
if attachment.MemoUID != nil && *attachment.MemoUID != "" {
|
||||
memoName := fmt.Sprintf("%s%s", MemoNamePrefix, *attachment.MemoUID)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
|
|
@ -28,6 +29,7 @@ func TestGatewayMarshalerOmitsUnsetMessageFields(t *testing.T) {
|
|||
payload := marshalThroughGateway(t, attachment)
|
||||
|
||||
require.NotContains(t, payload, "motionMedia", "an unset message field must be omitted, not emitted as null")
|
||||
require.NotContains(t, payload, "mediaMetadata", "an unset message field must be omitted, not emitted as null")
|
||||
// Scalar defaults stay in the payload: the schema lists filename and type as
|
||||
// required, so dropping unpopulated scalars would break validation instead.
|
||||
require.Equal(t, "", payload["externalLink"])
|
||||
|
|
@ -36,6 +38,52 @@ func TestGatewayMarshalerOmitsUnsetMessageFields(t *testing.T) {
|
|||
require.Equal(t, "0", payload["size"])
|
||||
}
|
||||
|
||||
func TestGatewayMarshalerKeepsMediaMetadataFieldNames(t *testing.T) {
|
||||
attachment := &v1pb.Attachment{
|
||||
Name: "attachments/video1",
|
||||
Filename: "clip.mp4",
|
||||
Type: "video/mp4",
|
||||
MediaMetadata: &v1pb.MediaMetadata{
|
||||
Width: proto.Int32(1920),
|
||||
Height: proto.Int32(1080),
|
||||
Details: &v1pb.MediaMetadata_Video{Video: &v1pb.VideoMetadata{
|
||||
DurationSeconds: proto.Float64(12.5),
|
||||
}},
|
||||
},
|
||||
}
|
||||
|
||||
payload := marshalThroughGateway(t, attachment)
|
||||
|
||||
metadata, ok := payload["mediaMetadata"].(map[string]any)
|
||||
require.True(t, ok)
|
||||
require.Equal(t, float64(1920), metadata["width"])
|
||||
video, ok := metadata["video"].(map[string]any)
|
||||
require.True(t, ok)
|
||||
require.Equal(t, 12.5, video["durationSeconds"])
|
||||
}
|
||||
|
||||
func TestGatewayMarshalerNamesSourceExifOrientationExplicitly(t *testing.T) {
|
||||
attachment := &v1pb.Attachment{
|
||||
Name: "attachments/photo1",
|
||||
Filename: "photo.jpg",
|
||||
Type: "image/jpeg",
|
||||
MediaMetadata: &v1pb.MediaMetadata{
|
||||
Details: &v1pb.MediaMetadata_Photo{Photo: &v1pb.PhotoMetadata{
|
||||
SourceExifOrientation: proto.Int32(6),
|
||||
}},
|
||||
},
|
||||
}
|
||||
|
||||
payload := marshalThroughGateway(t, attachment)
|
||||
|
||||
metadata, ok := payload["mediaMetadata"].(map[string]any)
|
||||
require.True(t, ok)
|
||||
photo, ok := metadata["photo"].(map[string]any)
|
||||
require.True(t, ok)
|
||||
require.Equal(t, float64(6), photo["sourceExifOrientation"])
|
||||
require.NotContains(t, photo, "orientation")
|
||||
}
|
||||
|
||||
func TestGatewayMarshalerKeepsPopulatedMessageFields(t *testing.T) {
|
||||
attachment := &v1pb.Attachment{
|
||||
Name: "attachments/livephoto1",
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/usememos/memos/internal/testutil"
|
||||
v1pb "github.com/usememos/memos/proto/gen/api/v1"
|
||||
|
|
@ -342,6 +343,112 @@ func TestCreateAttachmentMotionMedia(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestCreateAttachmentMediaMetadata(t *testing.T) {
|
||||
ts := NewTestService(t)
|
||||
defer ts.Cleanup()
|
||||
ctx := context.Background()
|
||||
|
||||
user, err := ts.CreateRegularUser(ctx, "media_metadata_user")
|
||||
require.NoError(t, err)
|
||||
userCtx := ts.CreateUserContext(ctx, user.ID)
|
||||
|
||||
photoMetadata := &v1pb.MediaMetadata{
|
||||
Width: proto.Int32(20),
|
||||
Height: proto.Int32(10),
|
||||
Details: &v1pb.MediaMetadata_Photo{Photo: &v1pb.PhotoMetadata{
|
||||
CaptureTime: &v1pb.MediaCaptureTime{
|
||||
LocalDateTime: "2026-08-10T14:32:18.123",
|
||||
UtcOffset: proto.String("+08:00"),
|
||||
},
|
||||
Location: &v1pb.MediaLocation{
|
||||
Latitude: proto.Float64(1.3521),
|
||||
Longitude: proto.Float64(103.8198),
|
||||
AltitudeMeters: proto.Float64(18.4),
|
||||
},
|
||||
SourceExifOrientation: proto.Int32(6),
|
||||
CameraMake: "Apple",
|
||||
CameraModel: "iPhone",
|
||||
LensModel: "Main Camera",
|
||||
FNumber: proto.Float64(1.78),
|
||||
ExposureTimeSeconds: proto.Float64(1.0 / 120.0),
|
||||
Iso: proto.Int32(64),
|
||||
FocalLengthMm: proto.Float64(6.86),
|
||||
}},
|
||||
}
|
||||
|
||||
photo, err := ts.Service.CreateAttachment(userCtx, &v1pb.CreateAttachmentRequest{
|
||||
Attachment: &v1pb.Attachment{
|
||||
Filename: "photo.jpg",
|
||||
Type: "image/jpeg",
|
||||
Content: testutil.BuildJPEG(20, 10),
|
||||
MediaMetadata: photoMetadata,
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.True(t, proto.Equal(photoMetadata, photo.MediaMetadata))
|
||||
|
||||
photoUID, err := apiv1.ExtractAttachmentUIDFromName(photo.Name)
|
||||
require.NoError(t, err)
|
||||
storedPhoto, err := ts.Store.GetAttachment(ctx, &store.FindAttachment{UID: &photoUID})
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, storedPhoto.Payload.GetMediaMetadata())
|
||||
require.Equal(t, "Apple", storedPhoto.Payload.GetMediaMetadata().GetPhoto().GetCameraMake())
|
||||
require.Equal(t, int32(6), storedPhoto.Payload.GetMediaMetadata().GetPhoto().GetSourceExifOrientation())
|
||||
|
||||
gotPhoto, err := ts.Service.GetAttachment(userCtx, &v1pb.GetAttachmentRequest{Name: photo.Name})
|
||||
require.NoError(t, err)
|
||||
require.True(t, proto.Equal(photoMetadata, gotPhoto.MediaMetadata))
|
||||
|
||||
listed, err := ts.Service.ListAttachments(userCtx, &v1pb.ListAttachmentsRequest{PageSize: 100})
|
||||
require.NoError(t, err)
|
||||
var listedPhoto *v1pb.Attachment
|
||||
for _, attachment := range listed.Attachments {
|
||||
if attachment.Name == photo.Name {
|
||||
listedPhoto = attachment
|
||||
break
|
||||
}
|
||||
}
|
||||
require.NotNil(t, listedPhoto)
|
||||
require.True(t, proto.Equal(photoMetadata, listedPhoto.MediaMetadata))
|
||||
|
||||
memo, err := ts.Service.CreateMemo(userCtx, &v1pb.CreateMemoRequest{Memo: &v1pb.Memo{
|
||||
Content: "memo with metadata",
|
||||
Visibility: v1pb.Visibility_PRIVATE,
|
||||
Attachments: []*v1pb.Attachment{{Name: photo.Name}},
|
||||
}})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, memo.Attachments, 1)
|
||||
require.True(t, proto.Equal(photoMetadata, memo.Attachments[0].MediaMetadata))
|
||||
|
||||
video, err := ts.Service.CreateAttachment(userCtx, &v1pb.CreateAttachmentRequest{
|
||||
Attachment: &v1pb.Attachment{
|
||||
Filename: "clip.mp4",
|
||||
Type: "video/mp4",
|
||||
Content: []byte("fake-video"),
|
||||
MediaMetadata: &v1pb.MediaMetadata{
|
||||
Width: proto.Int32(1920),
|
||||
Height: proto.Int32(1080),
|
||||
Details: &v1pb.MediaMetadata_Video{Video: &v1pb.VideoMetadata{
|
||||
DurationSeconds: proto.Float64(12.5),
|
||||
}},
|
||||
},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 12.5, video.MediaMetadata.GetVideo().GetDurationSeconds())
|
||||
|
||||
withoutMetadata, err := ts.Service.CreateAttachment(userCtx, &v1pb.CreateAttachmentRequest{
|
||||
Attachment: &v1pb.Attachment{Filename: "plain.png", Type: "image/png", Content: []byte("fake-png")},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Nil(t, withoutMetadata.MediaMetadata)
|
||||
plainUID, err := apiv1.ExtractAttachmentUIDFromName(withoutMetadata.Name)
|
||||
require.NoError(t, err)
|
||||
storedPlain, err := ts.Store.GetAttachment(ctx, &store.FindAttachment{UID: &plainUID})
|
||||
require.NoError(t, err)
|
||||
require.Nil(t, storedPlain.Payload.GetMediaMetadata())
|
||||
}
|
||||
|
||||
func TestBatchDeleteAttachments(t *testing.T) {
|
||||
ts := NewTestService(t)
|
||||
defer ts.Cleanup()
|
||||
|
|
|
|||
|
|
@ -59,6 +59,60 @@ func TestListUserSettingsOmitsInternalStoreSettings(t *testing.T) {
|
|||
require.Equal(t, "ja", resp.Settings[0].GetGeneralSetting().Locale)
|
||||
}
|
||||
|
||||
func TestGeneralUserSettingSaveMediaMetadata(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ts := NewTestService(t)
|
||||
defer ts.Cleanup()
|
||||
|
||||
user, err := ts.CreateRegularUser(ctx, "media-setting-user")
|
||||
require.NoError(t, err)
|
||||
userCtx := ts.CreateUserContext(ctx, user.ID)
|
||||
settingName := "users/media-setting-user/settings/GENERAL"
|
||||
|
||||
defaultSetting, err := ts.Service.GetUserSetting(userCtx, &apiv1.GetUserSettingRequest{Name: settingName})
|
||||
require.NoError(t, err)
|
||||
require.False(t, defaultSetting.GetGeneralSetting().GetSaveMediaMetadata())
|
||||
|
||||
updated, err := ts.Service.UpdateUserSetting(userCtx, &apiv1.UpdateUserSettingRequest{
|
||||
Setting: &apiv1.UserSetting{
|
||||
Name: settingName,
|
||||
Value: &apiv1.UserSetting_GeneralSetting_{
|
||||
GeneralSetting: &apiv1.UserSetting_GeneralSetting{SaveMediaMetadata: true},
|
||||
},
|
||||
},
|
||||
UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"save_media_metadata"}},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.True(t, updated.GetGeneralSetting().GetSaveMediaMetadata())
|
||||
require.Equal(t, "en", updated.GetGeneralSetting().GetLocale())
|
||||
require.Equal(t, "PRIVATE", updated.GetGeneralSetting().GetMemoVisibility())
|
||||
|
||||
updated, err = ts.Service.UpdateUserSetting(userCtx, &apiv1.UpdateUserSettingRequest{
|
||||
Setting: &apiv1.UserSetting{
|
||||
Name: settingName,
|
||||
Value: &apiv1.UserSetting_GeneralSetting_{
|
||||
GeneralSetting: &apiv1.UserSetting_GeneralSetting{Locale: "ja"},
|
||||
},
|
||||
},
|
||||
UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"locale"}},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "ja", updated.GetGeneralSetting().GetLocale())
|
||||
require.True(t, updated.GetGeneralSetting().GetSaveMediaMetadata())
|
||||
|
||||
updated, err = ts.Service.UpdateUserSetting(userCtx, &apiv1.UpdateUserSettingRequest{
|
||||
Setting: &apiv1.UserSetting{
|
||||
Name: settingName,
|
||||
Value: &apiv1.UserSetting_GeneralSetting_{
|
||||
GeneralSetting: &apiv1.UserSetting_GeneralSetting{SaveMediaMetadata: false},
|
||||
},
|
||||
},
|
||||
UpdateMask: &fieldmaskpb.FieldMask{Paths: []string{"save_media_metadata"}},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.False(t, updated.GetGeneralSetting().GetSaveMediaMetadata())
|
||||
}
|
||||
|
||||
func TestUserTagSettings(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ts := NewTestService(t)
|
||||
|
|
|
|||
|
|
@ -187,9 +187,10 @@ func convertUserSettingFromStore(storeSetting *storepb.UserSetting, user *store.
|
|||
if general := storeSetting.GetGeneral(); general != nil {
|
||||
setting.Value = &v1pb.UserSetting_GeneralSetting_{
|
||||
GeneralSetting: &v1pb.UserSetting_GeneralSetting{
|
||||
Locale: general.Locale,
|
||||
MemoVisibility: general.MemoVisibility,
|
||||
Theme: general.Theme,
|
||||
Locale: general.Locale,
|
||||
MemoVisibility: general.MemoVisibility,
|
||||
Theme: general.Theme,
|
||||
SaveMediaMetadata: general.SaveMediaMetadata,
|
||||
},
|
||||
}
|
||||
} else {
|
||||
|
|
@ -240,9 +241,10 @@ func convertUserSettingToStore(apiSetting *v1pb.UserSetting, userID int32, key s
|
|||
if general := apiSetting.GetGeneralSetting(); general != nil {
|
||||
storeSetting.Value = &storepb.UserSetting_General{
|
||||
General: &storepb.GeneralUserSetting{
|
||||
Locale: general.Locale,
|
||||
MemoVisibility: general.MemoVisibility,
|
||||
Theme: general.Theme,
|
||||
Locale: general.Locale,
|
||||
MemoVisibility: general.MemoVisibility,
|
||||
Theme: general.Theme,
|
||||
SaveMediaMetadata: general.SaveMediaMetadata,
|
||||
},
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -84,22 +84,17 @@ func (s *APIV1Service) UpdateUserSetting(ctx context.Context, request *v1pb.Upda
|
|||
var updatedSetting *v1pb.UserSetting
|
||||
switch storeKey {
|
||||
case storepb.UserSetting_GENERAL:
|
||||
existingUserSetting, _ := s.Store.GetUserSetting(ctx, &store.FindUserSetting{
|
||||
existingUserSetting, err := s.Store.GetUserSetting(ctx, &store.FindUserSetting{
|
||||
UserID: &userID,
|
||||
Key: storeKey,
|
||||
})
|
||||
|
||||
generalSetting := &storepb.GeneralUserSetting{}
|
||||
if existingUserSetting != nil {
|
||||
// Start with existing general setting values.
|
||||
generalSetting = existingUserSetting.GetGeneral()
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.Internal, "failed to get existing general setting: %v", err)
|
||||
}
|
||||
|
||||
updatedGeneral := &v1pb.UserSetting_GeneralSetting{
|
||||
MemoVisibility: generalSetting.GetMemoVisibility(),
|
||||
Locale: generalSetting.GetLocale(),
|
||||
Theme: generalSetting.GetTheme(),
|
||||
}
|
||||
// Seed the merge from the shared store→API converter, which already falls
|
||||
// back to defaults when the setting (or its general value) is missing.
|
||||
updatedGeneral := convertUserSettingFromStore(existingUserSetting, user, storeKey).GetGeneralSetting()
|
||||
|
||||
incomingGeneral := request.Setting.GetGeneralSetting()
|
||||
if incomingGeneral == nil {
|
||||
|
|
@ -113,6 +108,8 @@ func (s *APIV1Service) UpdateUserSetting(ctx context.Context, request *v1pb.Upda
|
|||
updatedGeneral.Theme = incomingGeneral.Theme
|
||||
case "locale":
|
||||
updatedGeneral.Locale = incomingGeneral.Locale
|
||||
case "save_media_metadata":
|
||||
updatedGeneral.SaveMediaMetadata = incomingGeneral.SaveMediaMetadata
|
||||
default:
|
||||
// Ignore unsupported fields.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
|
||||
"github.com/lithammer/shortuuid/v4"
|
||||
"github.com/stretchr/testify/require"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/store"
|
||||
|
|
@ -81,6 +82,24 @@ func TestAttachmentStore(t *testing.T) {
|
|||
Blob: []byte("test"),
|
||||
Type: "application/epub+zip",
|
||||
Size: 637607,
|
||||
Payload: &storepb.AttachmentPayload{
|
||||
Payload: &storepb.AttachmentPayload_S3Object_{
|
||||
S3Object: &storepb.AttachmentPayload_S3Object{Key: "attachments/test.jpg"},
|
||||
},
|
||||
MotionMedia: &storepb.MotionMedia{
|
||||
Family: storepb.MotionMediaFamily_APPLE_LIVE_PHOTO,
|
||||
Role: storepb.MotionMediaRole_STILL,
|
||||
GroupId: "live-photo-pair",
|
||||
},
|
||||
MediaMetadata: &storepb.MediaMetadata{
|
||||
Width: proto.Int32(1200),
|
||||
Height: proto.Int32(800),
|
||||
Details: &storepb.MediaMetadata_Photo{Photo: &storepb.PhotoMetadata{
|
||||
CameraMake: "Test Camera",
|
||||
SourceExifOrientation: proto.Int32(6),
|
||||
}},
|
||||
},
|
||||
},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
|
|
@ -92,6 +111,11 @@ func TestAttachmentStore(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
require.Equal(t, correctFilename, attachment.Filename)
|
||||
require.Equal(t, int32(1), attachment.ID)
|
||||
require.Equal(t, int32(1200), attachment.Payload.GetMediaMetadata().GetWidth())
|
||||
require.Equal(t, "Test Camera", attachment.Payload.GetMediaMetadata().GetPhoto().GetCameraMake())
|
||||
require.Equal(t, int32(6), attachment.Payload.GetMediaMetadata().GetPhoto().GetSourceExifOrientation())
|
||||
require.Equal(t, "attachments/test.jpg", attachment.Payload.GetS3Object().GetKey())
|
||||
require.Equal(t, "live-photo-pair", attachment.Payload.GetMotionMedia().GetGroupId())
|
||||
|
||||
notFoundAttachment, err := ts.GetAttachment(ctx, &store.FindAttachment{
|
||||
Filename: &incorrectFilename,
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
"clsx": "^2.1.1",
|
||||
"copy-to-clipboard": "^4.0.2",
|
||||
"dayjs": "^1.11.20",
|
||||
"exifr": "^7.1.3",
|
||||
"highlight.js": "^11.11.1",
|
||||
"html-to-image": "^1.11.13",
|
||||
"i18next": "^26.3.6",
|
||||
|
|
|
|||
|
|
@ -68,6 +68,9 @@ importers:
|
|||
dayjs:
|
||||
specifier: ^1.11.20
|
||||
version: 1.11.20
|
||||
exifr:
|
||||
specifier: ^7.1.3
|
||||
version: 7.1.3
|
||||
highlight.js:
|
||||
specifier: ^11.11.1
|
||||
version: 11.11.1
|
||||
|
|
@ -1572,6 +1575,9 @@ packages:
|
|||
estree-walker@3.0.3:
|
||||
resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==}
|
||||
|
||||
exifr@7.1.3:
|
||||
resolution: {integrity: sha512-g/aje2noHivrRSLbAUtBPWFbxKdKhgj/xr1vATDdUXPOFYJlQ62Ft0oy+72V6XLIpDJfHs6gXLbBLAolqOXYRw==}
|
||||
|
||||
expect-type@1.3.0:
|
||||
resolution: {integrity: sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
|
@ -3817,6 +3823,8 @@ snapshots:
|
|||
dependencies:
|
||||
'@types/estree': 1.0.8
|
||||
|
||||
exifr@7.1.3: {}
|
||||
|
||||
expect-type@1.3.0: {}
|
||||
|
||||
extend@3.0.2: {}
|
||||
|
|
|
|||
|
|
@ -24,9 +24,8 @@ interface Props {
|
|||
|
||||
const AttachmentIcon = (props: Props) => {
|
||||
const { attachment } = props;
|
||||
const [previewImage, setPreviewImage] = useState<{ open: boolean; urls: string[]; index: number }>({
|
||||
const [previewImage, setPreviewImage] = useState<{ open: boolean; index: number }>({
|
||||
open: false,
|
||||
urls: [],
|
||||
index: 0,
|
||||
});
|
||||
const resourceType = getAttachmentType(attachment);
|
||||
|
|
@ -39,7 +38,7 @@ const AttachmentIcon = (props: Props) => {
|
|||
};
|
||||
|
||||
const handleImageClick = () => {
|
||||
setPreviewImage({ open: true, urls: [attachmentUrl], index: 0 });
|
||||
setPreviewImage({ open: true, index: 0 });
|
||||
};
|
||||
|
||||
if (resourceType === "image/*") {
|
||||
|
|
@ -66,7 +65,16 @@ const AttachmentIcon = (props: Props) => {
|
|||
<PreviewImageDialog
|
||||
open={previewImage.open}
|
||||
onOpenChange={(open) => setPreviewImage((prev) => ({ ...prev, open }))}
|
||||
imgUrls={previewImage.urls}
|
||||
items={[
|
||||
{
|
||||
id: attachment.name,
|
||||
kind: "image",
|
||||
sourceUrl: attachmentUrl,
|
||||
posterUrl: getAttachmentThumbnailUrl(attachment),
|
||||
filename: attachment.filename,
|
||||
attachments: [attachment],
|
||||
},
|
||||
]}
|
||||
initialIndex={previewImage.index}
|
||||
/>
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,9 @@ import MotionPhotoPreview from "@/components/MotionPhotoPreview";
|
|||
import { Badge } from "@/components/ui/badge";
|
||||
import VideoPoster from "@/components/VideoPoster";
|
||||
import type { AttachmentLibraryMediaItem, AttachmentLibraryMonthGroup } from "@/hooks/useAttachmentLibrary";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
import { formatMediaDuration } from "@/utils/media-metadata";
|
||||
import { AttachmentMetadataLine, AttachmentOpenButton, AttachmentSourceChip } from "./AttachmentLibraryPrimitives";
|
||||
|
||||
interface AttachmentMediaGridProps {
|
||||
|
|
@ -13,6 +15,8 @@ interface AttachmentMediaGridProps {
|
|||
|
||||
const AttachmentMediaCard = ({ item, onPreview }: { item: AttachmentLibraryMediaItem; onPreview: () => void }) => {
|
||||
const t = useTranslate();
|
||||
const videoDuration = item.attachments.map((attachment) => attachment.mediaMetadata?.details).find((details) => details?.case === "video")
|
||||
?.value.durationSeconds;
|
||||
|
||||
return (
|
||||
<article className="overflow-hidden rounded-[20px] border border-border/60 bg-background/90 shadow-sm shadow-black/[0.03]">
|
||||
|
|
@ -27,8 +31,14 @@ const AttachmentMediaCard = ({ item, onPreview }: { item: AttachmentLibraryMedia
|
|||
className="h-full w-full object-cover"
|
||||
/>
|
||||
<div className="absolute inset-0 bg-linear-to-t from-black/35 via-black/5 to-transparent" />
|
||||
<span className="absolute bottom-2.5 right-2.5 inline-flex h-8 w-8 items-center justify-center rounded-full bg-background/85 text-foreground shadow-sm backdrop-blur-sm">
|
||||
<span
|
||||
className={cn(
|
||||
"absolute bottom-2.5 right-2.5 inline-flex h-8 items-center justify-center rounded-full bg-background/85 text-foreground shadow-sm backdrop-blur-sm",
|
||||
videoDuration === undefined ? "w-8" : "gap-1.5 px-2.5 text-[11px] font-medium tabular-nums",
|
||||
)}
|
||||
>
|
||||
<PlayIcon className="h-3.5 w-3.5 fill-current" />
|
||||
{videoDuration !== undefined && <span>{formatMediaDuration(videoDuration)}</span>}
|
||||
</span>
|
||||
</>
|
||||
) : item.kind === "motion" ? (
|
||||
|
|
|
|||
246
web/src/components/MediaMetadataDetails.tsx
Normal file
246
web/src/components/MediaMetadataDetails.tsx
Normal file
|
|
@ -0,0 +1,246 @@
|
|||
import {
|
||||
ApertureIcon,
|
||||
CalendarArrowUpIcon,
|
||||
CalendarClockIcon,
|
||||
CameraIcon,
|
||||
CheckIcon,
|
||||
CopyIcon,
|
||||
FileType2Icon,
|
||||
FocusIcon,
|
||||
type LucideIcon,
|
||||
MapIcon,
|
||||
MapPinIcon,
|
||||
RotateCwIcon,
|
||||
ScanIcon,
|
||||
TimerIcon,
|
||||
XIcon,
|
||||
} from "lucide-react";
|
||||
import { type ReactNode, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { LazyLocationPicker } from "@/components/map/LazyLocationPicker";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import i18n from "@/i18n";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
import type { PreviewMediaItem } from "@/utils/media-item";
|
||||
import { buildMediaMetadataDisplay } from "@/utils/media-metadata";
|
||||
|
||||
interface DetailRowProps {
|
||||
icon: LucideIcon;
|
||||
label: string;
|
||||
value: string;
|
||||
secondary?: string;
|
||||
action?: ReactNode;
|
||||
}
|
||||
|
||||
interface MediaMetadataDetailsProps {
|
||||
id: string;
|
||||
item: PreviewMediaItem;
|
||||
onClose: () => void;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const DetailRow = ({ icon: Icon, label, value, secondary, action }: DetailRowProps) => (
|
||||
<div className="grid grid-cols-[1rem_minmax(0,1fr)_auto] gap-x-2.5 py-2.5">
|
||||
<Icon className="mt-0.5 size-3.5 text-white/38" strokeWidth={1.75} aria-hidden="true" />
|
||||
<div className="min-w-0">
|
||||
<div className="text-[11px] font-medium leading-4 text-white/45">{label}</div>
|
||||
<div className="mt-0.5 break-words text-[13px] leading-5 text-white/88 tabular-nums">{value}</div>
|
||||
{secondary && <div className="mt-0.5 text-[11px] leading-4 text-white/48">{secondary}</div>}
|
||||
</div>
|
||||
{action && <div className="self-center">{action}</div>}
|
||||
</div>
|
||||
);
|
||||
|
||||
const DetailSection = ({ title, children }: { title: string; children: ReactNode }) => (
|
||||
<section>
|
||||
<h3 className="mb-0.5 text-[10px] font-semibold uppercase tracking-[0.16em] text-white/32">{title}</h3>
|
||||
<div className="divide-y divide-white/[0.07]">{children}</div>
|
||||
</section>
|
||||
);
|
||||
|
||||
const IconAction = ({ label, onClick, children }: { label: string; onClick: () => void; children: ReactNode }) => (
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
title={label}
|
||||
aria-label={label}
|
||||
onClick={onClick}
|
||||
className="inline-flex size-7 items-center justify-center rounded-full text-white/48 transition-colors hover:bg-white/[0.08] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/45"
|
||||
>
|
||||
{children}
|
||||
</Button>
|
||||
);
|
||||
|
||||
const MediaMetadataDetails = ({ id, item, onClose, className }: MediaMetadataDetailsProps) => {
|
||||
const t = useTranslate();
|
||||
const [showMap, setShowMap] = useState(false);
|
||||
const [coordinatesCopied, setCoordinatesCopied] = useState(false);
|
||||
const copyResetTimer = useRef<number | undefined>(undefined);
|
||||
const locale = i18n.language;
|
||||
const details = useMemo(() => buildMediaMetadataDisplay(item.attachments, locale), [item.attachments, locale]);
|
||||
|
||||
useEffect(() => {
|
||||
setShowMap(false);
|
||||
setCoordinatesCopied(false);
|
||||
}, [item.id]);
|
||||
|
||||
useEffect(
|
||||
() => () => {
|
||||
if (copyResetTimer.current !== undefined) {
|
||||
window.clearTimeout(copyResetTimer.current);
|
||||
}
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const copyCoordinates = async () => {
|
||||
if (!details.location || !navigator.clipboard) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await navigator.clipboard.writeText(`${details.location.latitude}, ${details.location.longitude}`);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
setCoordinatesCopied(true);
|
||||
if (copyResetTimer.current !== undefined) {
|
||||
window.clearTimeout(copyResetTimer.current);
|
||||
}
|
||||
copyResetTimer.current = window.setTimeout(() => setCoordinatesCopied(false), 1600);
|
||||
};
|
||||
|
||||
const hasFileDetails = Boolean(details.file || details.dimensions || details.duration || details.uploaded);
|
||||
const hasCaptureDetails = Boolean(details.captured);
|
||||
const hasCameraDetails = Boolean(details.camera || details.lens || details.exposure);
|
||||
|
||||
return (
|
||||
<aside
|
||||
id={id}
|
||||
aria-label={t("attachment-details.title")}
|
||||
className={cn(
|
||||
"absolute inset-x-0 bottom-0 z-40 flex max-h-[72vh] flex-col overflow-hidden rounded-t-2xl border-t border-white/10 bg-neutral-950/96 text-white shadow-2xl backdrop-blur-xl lg:inset-y-0 lg:left-auto lg:w-[22rem] lg:max-h-none lg:rounded-none lg:border-l lg:border-t-0 lg:bg-black/82",
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<div className="mx-auto mt-2 h-1 w-8 rounded-full bg-white/18 lg:hidden" aria-hidden="true" />
|
||||
<header className="flex shrink-0 items-center justify-between gap-3 border-b border-white/[0.08] px-4 pb-3 pt-3 lg:pt-20">
|
||||
<div>
|
||||
<h2 className="text-sm font-medium text-white/92">{t("attachment-details.title")}</h2>
|
||||
<p className="mt-0.5 max-w-[16rem] truncate text-xs text-white/42">{item.filename}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="inline-flex size-8 items-center justify-center rounded-full text-white/55 hover:bg-white/[0.08] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/45 lg:hidden"
|
||||
aria-label={t("attachment-details.actions.hide")}
|
||||
>
|
||||
<XIcon className="size-4" aria-hidden="true" />
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div className="overflow-y-auto px-4 pb-[max(1rem,env(safe-area-inset-bottom))] pt-4">
|
||||
<div className="space-y-5">
|
||||
{hasFileDetails && (
|
||||
<DetailSection title={t("attachment-details.sections.file")}>
|
||||
{details.file && <DetailRow icon={FileType2Icon} label={t("attachment-details.fields.file")} value={details.file} />}
|
||||
{details.dimensions && (
|
||||
<DetailRow icon={ScanIcon} label={t("attachment-details.fields.dimensions")} value={details.dimensions} />
|
||||
)}
|
||||
{details.duration && <DetailRow icon={TimerIcon} label={t("attachment-details.fields.duration")} value={details.duration} />}
|
||||
{details.uploaded && (
|
||||
<DetailRow icon={CalendarArrowUpIcon} label={t("attachment-details.fields.uploaded")} value={details.uploaded} />
|
||||
)}
|
||||
</DetailSection>
|
||||
)}
|
||||
|
||||
{hasCaptureDetails && (
|
||||
<DetailSection title={t("attachment-details.sections.capture")}>
|
||||
<DetailRow
|
||||
icon={CalendarClockIcon}
|
||||
label={t("attachment-details.fields.captured")}
|
||||
value={details.captured!}
|
||||
secondary={
|
||||
details.utcOffset
|
||||
? details.utcOffset === "Z"
|
||||
? "UTC"
|
||||
: `UTC${details.utcOffset}`
|
||||
: t("attachment-details.timezone-unknown")
|
||||
}
|
||||
/>
|
||||
</DetailSection>
|
||||
)}
|
||||
|
||||
{hasCameraDetails && (
|
||||
<DetailSection title={t("attachment-details.sections.camera")}>
|
||||
{details.camera && <DetailRow icon={CameraIcon} label={t("attachment-details.fields.camera")} value={details.camera} />}
|
||||
{details.lens && <DetailRow icon={FocusIcon} label={t("attachment-details.fields.lens")} value={details.lens} />}
|
||||
{details.exposure && (
|
||||
<DetailRow icon={ApertureIcon} label={t("attachment-details.fields.exposure")} value={details.exposure} />
|
||||
)}
|
||||
</DetailSection>
|
||||
)}
|
||||
|
||||
{details.location && (
|
||||
<DetailSection title={t("attachment-details.sections.location")}>
|
||||
<DetailRow
|
||||
icon={MapPinIcon}
|
||||
label={t("attachment-details.fields.location")}
|
||||
value={details.location.coordinates}
|
||||
secondary={
|
||||
details.location.altitude ? `${t("attachment-details.fields.altitude")} · ${details.location.altitude}` : undefined
|
||||
}
|
||||
action={
|
||||
<IconAction
|
||||
label={coordinatesCopied ? t("attachment-details.actions.copied") : t("attachment-details.actions.copy-coordinates")}
|
||||
onClick={() => void copyCoordinates()}
|
||||
>
|
||||
{coordinatesCopied ? <CheckIcon className="size-3.5" /> : <CopyIcon className="size-3.5" />}
|
||||
</IconAction>
|
||||
}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setShowMap((visible) => !visible)}
|
||||
className="mt-2 inline-flex h-8 items-center gap-1.5 rounded-full border border-white/10 px-3 text-xs text-white/62 transition-colors hover:border-white/18 hover:bg-white/[0.06] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/45"
|
||||
>
|
||||
<MapIcon className="size-3.5" strokeWidth={1.75} aria-hidden="true" />
|
||||
{showMap ? t("attachment-details.actions.hide-map") : t("attachment-details.actions.show-map")}
|
||||
</button>
|
||||
{showMap && (
|
||||
<LazyLocationPicker
|
||||
className="mt-3 h-44 rounded-xl border-white/10"
|
||||
latlng={{ lat: details.location.latitude, lng: details.location.longitude }}
|
||||
readonly
|
||||
/>
|
||||
)}
|
||||
</DetailSection>
|
||||
)}
|
||||
|
||||
{!details.hasSavedMetadata && (
|
||||
<p className="rounded-xl border border-white/[0.07] px-3 py-2.5 text-xs leading-5 text-white/42">
|
||||
{t("attachment-details.empty")}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{details.sourceExifOrientation !== undefined && (
|
||||
<details className="group border-t border-white/[0.08] pt-3">
|
||||
<summary className="cursor-pointer select-none text-[11px] font-medium text-white/42 hover:text-white/65">
|
||||
{t("attachment-details.sections.technical")}
|
||||
</summary>
|
||||
<div className="mt-2">
|
||||
<DetailRow
|
||||
icon={RotateCwIcon}
|
||||
label={t("attachment-details.fields.source-orientation")}
|
||||
value={String(details.sourceExifOrientation)}
|
||||
/>
|
||||
</div>
|
||||
</details>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
};
|
||||
|
||||
export default MediaMetadataDetails;
|
||||
|
|
@ -6,7 +6,7 @@ export { useAutoSave } from "./useAutoSave";
|
|||
export { useBlobUrls } from "./useBlobUrls";
|
||||
export { useEditorActiveState } from "./useEditorActiveState";
|
||||
export { COMPACT_TOOLBAR_WIDTH, isCompactWidth, useElementWidth } from "./useElementWidth";
|
||||
export { pairAppleLivePhotoFiles, useFileUpload } from "./useFileUpload";
|
||||
export { pairAppleLivePhotoFiles, toLocalFiles, useFileUpload } from "./useFileUpload";
|
||||
export { useFocusMode } from "./useFocusMode";
|
||||
export { splitInlineLocalFiles, useInlineImageUpload } from "./useInlineImageUpload";
|
||||
export { useLinkMemo } from "./useLinkMemo";
|
||||
|
|
|
|||
|
|
@ -1,15 +1,34 @@
|
|||
import { create } from "@bufbuild/protobuf";
|
||||
import { useRef } from "react";
|
||||
import { useAuth } from "@/contexts/AuthContext";
|
||||
import { type MotionMedia, MotionMediaFamily, MotionMediaRole, MotionMediaSchema } from "@/types/proto/api/v1/attachment_service_pb";
|
||||
import { mediaMetadataService } from "../services/mediaMetadataService";
|
||||
import type { LocalFile } from "../types/attachment";
|
||||
import { useBlobUrls } from "./useBlobUrls";
|
||||
|
||||
/**
|
||||
* Single ingest point turning picked/pasted/dropped Files into LocalFiles.
|
||||
* Media metadata extraction starts here (not at upload time) so every upload
|
||||
* path inherits the preference from the LocalFile instead of threading it.
|
||||
*/
|
||||
export const toLocalFiles = (files: File[], options: { createBlobUrl: (file: File) => string; saveMediaMetadata: boolean }): LocalFile[] =>
|
||||
pairAppleLivePhotoFiles(
|
||||
files.map((file) => ({
|
||||
file,
|
||||
previewUrl: options.createBlobUrl(file),
|
||||
origin: "upload",
|
||||
mediaMetadata: options.saveMediaMetadata ? mediaMetadataService.extract(file) : undefined,
|
||||
})),
|
||||
);
|
||||
|
||||
export const useFileUpload = (onFilesSelected: (localFiles: LocalFile[]) => void) => {
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const selectingFlagRef = useRef(false);
|
||||
// Track preview blob URLs so they're revoked on unmount instead of leaking
|
||||
// (matches the paste/drop/audio paths, which all go through useBlobUrls).
|
||||
const { createBlobUrl } = useBlobUrls();
|
||||
const { userGeneralSetting } = useAuth();
|
||||
const saveMediaMetadata = userGeneralSetting?.saveMediaMetadata ?? false;
|
||||
|
||||
const handleFileInputChange = (event?: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const files = Array.from(fileInputRef.current?.files || event?.target.files || []);
|
||||
|
|
@ -17,13 +36,7 @@ export const useFileUpload = (onFilesSelected: (localFiles: LocalFile[]) => void
|
|||
return;
|
||||
}
|
||||
selectingFlagRef.current = true;
|
||||
const localFiles: LocalFile[] = pairAppleLivePhotoFiles(
|
||||
files.map((file) => ({
|
||||
file,
|
||||
previewUrl: createBlobUrl(file),
|
||||
origin: "upload",
|
||||
})),
|
||||
);
|
||||
const localFiles = toLocalFiles(files, { createBlobUrl, saveMediaMetadata });
|
||||
onFilesSelected(localFiles);
|
||||
selectingFlagRef.current = false;
|
||||
// Optionally clear input value to allow re-selecting the same file
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ import { convertVisibilityFromString } from "@/utils/memo";
|
|||
import { AudioRecorderPanel, EditorContent, EditorMetadata, FocusModeOverlay, TimestampPopover } from "./components";
|
||||
import { FOCUS_MODE_STYLES, FORMATTING_TOOLBAR_STORAGE_KEY } from "./constants";
|
||||
import {
|
||||
pairAppleLivePhotoFiles,
|
||||
splitInlineLocalFiles,
|
||||
toLocalFiles,
|
||||
useAudioRecorder,
|
||||
useAutoSave,
|
||||
useBlobUrls,
|
||||
|
|
@ -60,6 +60,7 @@ const MemoEditorImpl: React.FC<MemoEditorProps> = ({
|
|||
const [isAudioRecorderOpen, setIsAudioRecorderOpen] = useState(false);
|
||||
const [isTranscribingAudio, setIsTranscribingAudio] = useState(false);
|
||||
const { createBlobUrl } = useBlobUrls();
|
||||
const saveMediaMetadata = userGeneralSetting?.saveMediaMetadata ?? false;
|
||||
const inlineImageUpload = useInlineImageUpload(editorRef);
|
||||
// Persisted preference: also show the formatting toolbar in normal mode. Focus
|
||||
// mode always shows it regardless; this only governs the non-focus layout.
|
||||
|
|
@ -232,27 +233,15 @@ const MemoEditorImpl: React.FC<MemoEditorProps> = ({
|
|||
void handleStartAudioRecording();
|
||||
};
|
||||
|
||||
const toLocalFiles = useCallback(
|
||||
(files: File[]): LocalFile[] =>
|
||||
pairAppleLivePhotoFiles(
|
||||
files.map((file) => ({
|
||||
file,
|
||||
previewUrl: createBlobUrl(file),
|
||||
origin: "upload",
|
||||
})),
|
||||
),
|
||||
[createBlobUrl],
|
||||
);
|
||||
|
||||
/** Shared by the + menu (no position) and by editor paste/drop (drop position). */
|
||||
const handleInsertImages = useCallback(
|
||||
(files: File[], position?: number) => {
|
||||
if (getState().ui.isLoading.saving) return;
|
||||
const { inline, attachments } = splitInlineLocalFiles(toLocalFiles(files));
|
||||
const { inline, attachments } = splitInlineLocalFiles(toLocalFiles(files, { createBlobUrl, saveMediaMetadata }));
|
||||
attachments.forEach((file) => dispatch(actions.addLocalFile(file)));
|
||||
inlineImageUpload.insertLocalImages(inline, position);
|
||||
},
|
||||
[actions, dispatch, getState, inlineImageUpload.insertLocalImages, toLocalFiles],
|
||||
[actions, createBlobUrl, dispatch, getState, inlineImageUpload.insertLocalImages, saveMediaMetadata],
|
||||
);
|
||||
|
||||
const handleCancelAudioRecording = () => {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { AttachmentSchema } from "@/types/proto/api/v1/attachment_service_pb";
|
|||
|
||||
export const CACHE_DEBOUNCE_DELAY = 500;
|
||||
|
||||
const pendingSaves = new Map<string, ReturnType<typeof window.setTimeout>>();
|
||||
const pendingSaves = new Map<string, number>();
|
||||
const cursors = new Map<string, number>();
|
||||
const STRUCTURED_CACHE_ENTRY_KIND = "memos.editor-cache";
|
||||
const STRUCTURED_CACHE_ENTRY_VERSION = 2;
|
||||
|
|
|
|||
352
web/src/components/MemoEditor/services/mediaMetadataService.ts
Normal file
352
web/src/components/MemoEditor/services/mediaMetadataService.ts
Normal file
|
|
@ -0,0 +1,352 @@
|
|||
import { create } from "@bufbuild/protobuf";
|
||||
import {
|
||||
MediaCaptureTimeSchema,
|
||||
MediaLocationSchema,
|
||||
type MediaMetadata,
|
||||
MediaMetadataSchema,
|
||||
PhotoMetadataSchema,
|
||||
VideoMetadataSchema,
|
||||
} from "@/types/proto/api/v1/attachment_service_pb";
|
||||
import { isImage } from "@/utils/attachment";
|
||||
|
||||
const EXTRACTION_TIMEOUT_MS = 5_000;
|
||||
const MAX_METADATA_STRING_BYTES = 256;
|
||||
const EXIF_TAGS = [
|
||||
"Make",
|
||||
"Model",
|
||||
"Orientation",
|
||||
"ImageWidth",
|
||||
"ImageHeight",
|
||||
"ExifImageWidth",
|
||||
"ExifImageHeight",
|
||||
"DateTimeOriginal",
|
||||
"CreateDate",
|
||||
"SubSecTimeOriginal",
|
||||
"SubSecTimeDigitized",
|
||||
"OffsetTimeOriginal",
|
||||
"OffsetTimeDigitized",
|
||||
"GPSLatitudeRef",
|
||||
"GPSLatitude",
|
||||
"GPSLongitudeRef",
|
||||
"GPSLongitude",
|
||||
"GPSAltitudeRef",
|
||||
"GPSAltitude",
|
||||
"LensModel",
|
||||
"FNumber",
|
||||
"ExposureTime",
|
||||
"ISO",
|
||||
"FocalLength",
|
||||
];
|
||||
const EXIF_PARSE_OPTIONS = {
|
||||
pick: EXIF_TAGS,
|
||||
translateValues: false,
|
||||
reviveValues: false,
|
||||
makerNote: false,
|
||||
userComment: false,
|
||||
xmp: false,
|
||||
icc: false,
|
||||
iptc: false,
|
||||
jfif: false,
|
||||
ihdr: false,
|
||||
ifd1: false,
|
||||
};
|
||||
|
||||
const textEncoder = new TextEncoder();
|
||||
|
||||
type ExifTags = Record<string, unknown>;
|
||||
type Dimensions = { width: number; height: number };
|
||||
|
||||
export const mediaMetadataService = {
|
||||
async extract(file: File): Promise<MediaMetadata | undefined> {
|
||||
try {
|
||||
if (isImage(file.type)) {
|
||||
return await extractImageMetadata(file);
|
||||
}
|
||||
if (file.type.startsWith("video/")) {
|
||||
return await extractVideoMetadata(file);
|
||||
}
|
||||
} catch {
|
||||
warnExtractionFailure();
|
||||
}
|
||||
return undefined;
|
||||
},
|
||||
};
|
||||
|
||||
async function extractImageMetadata(file: File): Promise<MediaMetadata | undefined> {
|
||||
let tags: ExifTags = {};
|
||||
try {
|
||||
tags = await readExifTags(file);
|
||||
} catch {
|
||||
warnExtractionFailure();
|
||||
}
|
||||
|
||||
const sourceExifOrientation = normalizeInteger(tags.Orientation, 1, 8);
|
||||
// EXIF dimensions come from a cheap header read; decode the image only when they are absent.
|
||||
const dimensions = readExifDimensions(tags, sourceExifOrientation) ?? (await readImageDimensions(file));
|
||||
|
||||
const photoFields = {
|
||||
captureTime: readCaptureTime(tags),
|
||||
location: readLocation(tags),
|
||||
sourceExifOrientation,
|
||||
cameraMake: normalizeMetadataString(tags.Make),
|
||||
cameraModel: normalizeMetadataString(tags.Model),
|
||||
lensModel: normalizeMetadataString(tags.LensModel),
|
||||
fNumber: normalizePositiveNumber(tags.FNumber),
|
||||
exposureTimeSeconds: normalizePositiveNumber(tags.ExposureTime),
|
||||
iso: normalizeInteger(tags.ISO, 1),
|
||||
focalLengthMm: normalizePositiveNumber(tags.FocalLength),
|
||||
};
|
||||
const hasPhotoDetails = Object.values(photoFields).some((value) => value !== undefined);
|
||||
|
||||
if (!dimensions && !hasPhotoDetails) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return create(MediaMetadataSchema, {
|
||||
width: dimensions?.width,
|
||||
height: dimensions?.height,
|
||||
details: hasPhotoDetails ? { case: "photo", value: create(PhotoMetadataSchema, photoFields) } : { case: undefined },
|
||||
});
|
||||
}
|
||||
|
||||
async function readExifTags(file: File): Promise<ExifTags> {
|
||||
const exifr = await import("exifr");
|
||||
const parsed = await withTimeout(exifr.parse(file, EXIF_PARSE_OPTIONS), EXTRACTION_TIMEOUT_MS);
|
||||
return parsed && typeof parsed === "object" ? (parsed as ExifTags) : {};
|
||||
}
|
||||
|
||||
function readExifDimensions(tags: ExifTags, orientation: number | undefined): Dimensions | undefined {
|
||||
const width = normalizeInteger(tags.ExifImageWidth ?? tags.ImageWidth, 1);
|
||||
const height = normalizeInteger(tags.ExifImageHeight ?? tags.ImageHeight, 1);
|
||||
if (width === undefined || height === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (orientation !== undefined && orientation >= 5) {
|
||||
return { width: height, height: width };
|
||||
}
|
||||
return { width, height };
|
||||
}
|
||||
|
||||
async function readImageDimensions(file: File): Promise<Dimensions | undefined> {
|
||||
if (typeof createImageBitmap !== "function") {
|
||||
return undefined;
|
||||
}
|
||||
const bitmapPromise = createImageBitmap(file);
|
||||
try {
|
||||
const bitmap = await withTimeout(bitmapPromise, EXTRACTION_TIMEOUT_MS);
|
||||
const dimensions = normalizeDimensions(bitmap.width, bitmap.height);
|
||||
bitmap.close();
|
||||
return dimensions;
|
||||
} catch {
|
||||
void bitmapPromise.then((bitmap) => bitmap.close()).catch(() => undefined);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
async function extractVideoMetadata(file: File): Promise<MediaMetadata | undefined> {
|
||||
const { dimensions, durationSeconds } = await readVideoMetadata(file);
|
||||
if (!dimensions && durationSeconds === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return create(MediaMetadataSchema, {
|
||||
width: dimensions?.width,
|
||||
height: dimensions?.height,
|
||||
details:
|
||||
durationSeconds === undefined ? { case: undefined } : { case: "video", value: create(VideoMetadataSchema, { durationSeconds }) },
|
||||
});
|
||||
}
|
||||
|
||||
async function readVideoMetadata(file: File): Promise<{ dimensions?: Dimensions; durationSeconds?: number }> {
|
||||
return await new Promise((resolve, reject) => {
|
||||
const url = URL.createObjectURL(file);
|
||||
const video = document.createElement("video");
|
||||
video.preload = "metadata";
|
||||
|
||||
const cleanup = () => {
|
||||
window.clearTimeout(timeout);
|
||||
video.removeEventListener("loadedmetadata", handleLoadedMetadata);
|
||||
video.removeEventListener("error", fail);
|
||||
video.removeAttribute("src");
|
||||
video.load();
|
||||
URL.revokeObjectURL(url);
|
||||
};
|
||||
const fail = () => {
|
||||
cleanup();
|
||||
reject(new Error("video metadata extraction failed"));
|
||||
};
|
||||
const handleLoadedMetadata = () => {
|
||||
const dimensions = normalizeDimensions(video.videoWidth, video.videoHeight);
|
||||
const durationSeconds = Number.isFinite(video.duration) && video.duration >= 0 ? video.duration : undefined;
|
||||
cleanup();
|
||||
resolve({ dimensions, durationSeconds });
|
||||
};
|
||||
const timeout = window.setTimeout(fail, EXTRACTION_TIMEOUT_MS);
|
||||
|
||||
video.addEventListener("loadedmetadata", handleLoadedMetadata);
|
||||
video.addEventListener("error", fail);
|
||||
video.src = url;
|
||||
video.load();
|
||||
});
|
||||
}
|
||||
|
||||
function readCaptureTime(tags: ExifTags) {
|
||||
return (
|
||||
normalizeCaptureTime(tags.DateTimeOriginal, tags.SubSecTimeOriginal, tags.OffsetTimeOriginal) ??
|
||||
normalizeCaptureTime(tags.CreateDate, tags.SubSecTimeDigitized, tags.OffsetTimeDigitized)
|
||||
);
|
||||
}
|
||||
|
||||
function normalizeCaptureTime(dateValue: unknown, subsecondValue: unknown, offsetValue: unknown) {
|
||||
if (typeof dateValue !== "string") {
|
||||
return undefined;
|
||||
}
|
||||
const match = cleanExifString(dateValue).match(/^(\d{4}):(\d{2}):(\d{2})[ T](\d{2}):(\d{2}):(\d{2})$/);
|
||||
if (!match) {
|
||||
return undefined;
|
||||
}
|
||||
const [, yearText, monthText, dayText, hourText, minuteText, secondText] = match;
|
||||
if (!Number(yearText)) {
|
||||
return undefined;
|
||||
}
|
||||
const base = `${yearText}-${monthText}-${dayText}T${hourText}:${minuteText}:${secondText}`;
|
||||
// Round-trip through Date to reject impossible calendar dates: an invalid
|
||||
// component either yields NaN or rolls over so the ISO form no longer matches.
|
||||
const parsed = new Date(`${base}Z`);
|
||||
if (Number.isNaN(parsed.getTime()) || !parsed.toISOString().startsWith(base)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const cleanedSubseconds = typeof subsecondValue === "string" ? cleanExifString(subsecondValue) : "";
|
||||
const subseconds = /^\d{1,9}$/.test(cleanedSubseconds) ? cleanedSubseconds : undefined;
|
||||
const localDateTime = subseconds ? `${base}.${subseconds}` : base;
|
||||
const utcOffset = normalizeUTCOffset(offsetValue);
|
||||
return create(MediaCaptureTimeSchema, { localDateTime, utcOffset });
|
||||
}
|
||||
|
||||
function normalizeUTCOffset(value: unknown): string | undefined {
|
||||
if (typeof value !== "string") {
|
||||
return undefined;
|
||||
}
|
||||
const offset = cleanExifString(value);
|
||||
if (offset === "Z") {
|
||||
return offset;
|
||||
}
|
||||
const match = offset.match(/^[+-](\d{2}):(\d{2})$/);
|
||||
if (!match) {
|
||||
return undefined;
|
||||
}
|
||||
const hours = Number(match[1]);
|
||||
const minutes = Number(match[2]);
|
||||
return hours <= 14 && minutes <= 59 && (hours !== 14 || minutes === 0) ? offset : undefined;
|
||||
}
|
||||
|
||||
function readLocation(tags: ExifTags) {
|
||||
const latitude = normalizeCoordinate(tags.latitude, tags.GPSLatitude, tags.GPSLatitudeRef, 90, "N", "S");
|
||||
const longitude = normalizeCoordinate(tags.longitude, tags.GPSLongitude, tags.GPSLongitudeRef, 180, "E", "W");
|
||||
if (latitude === undefined || longitude === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
const rawAltitude = normalizeFiniteNumber(tags.GPSAltitude);
|
||||
const altitudeRef = normalizeFiniteNumber(tags.GPSAltitudeRef);
|
||||
const altitudeMeters = rawAltitude === undefined ? undefined : altitudeRef === 1 ? -rawAltitude : rawAltitude;
|
||||
return create(MediaLocationSchema, { latitude, longitude, altitudeMeters });
|
||||
}
|
||||
|
||||
function normalizeCoordinate(
|
||||
computed: unknown,
|
||||
dms: unknown,
|
||||
ref: unknown,
|
||||
maximum: number,
|
||||
positiveRef: string,
|
||||
negativeRef: string,
|
||||
): number | undefined {
|
||||
const computedNumber = normalizeFiniteNumber(computed);
|
||||
if (computedNumber !== undefined && computedNumber >= -maximum && computedNumber <= maximum) {
|
||||
return computedNumber;
|
||||
}
|
||||
const direction = typeof ref === "string" ? cleanExifString(ref).toUpperCase() : "";
|
||||
if (!Array.isArray(dms) || dms.length < 3 || (direction !== positiveRef && direction !== negativeRef)) {
|
||||
return undefined;
|
||||
}
|
||||
const degrees = normalizeFiniteNumber(dms[0]);
|
||||
const minutes = normalizeFiniteNumber(dms[1]);
|
||||
const seconds = normalizeFiniteNumber(dms[2]);
|
||||
if (
|
||||
degrees === undefined ||
|
||||
minutes === undefined ||
|
||||
seconds === undefined ||
|
||||
degrees < 0 ||
|
||||
minutes < 0 ||
|
||||
minutes >= 60 ||
|
||||
seconds < 0 ||
|
||||
seconds >= 60
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
const sign = direction === negativeRef ? -1 : 1;
|
||||
const result = sign * (degrees + minutes / 60 + seconds / 3600);
|
||||
return result >= -maximum && result <= maximum ? result : undefined;
|
||||
}
|
||||
|
||||
function normalizeMetadataString(value: unknown): string | undefined {
|
||||
if (typeof value !== "string") {
|
||||
return undefined;
|
||||
}
|
||||
// Strip Unicode Cc control characters to match server-side validation.
|
||||
const normalized = value.replace(/\p{Cc}/gu, "").trim();
|
||||
if (!normalized || normalized.length > MAX_METADATA_STRING_BYTES) {
|
||||
return undefined;
|
||||
}
|
||||
return textEncoder.encode(normalized).byteLength > MAX_METADATA_STRING_BYTES ? undefined : normalized;
|
||||
}
|
||||
|
||||
function cleanExifString(value: string): string {
|
||||
return value.replace(/[\0\s]+$/g, "").trimStart();
|
||||
}
|
||||
|
||||
function normalizeFiniteNumber(value: unknown): number | undefined {
|
||||
if (typeof value === "number") {
|
||||
return Number.isFinite(value) ? value : undefined;
|
||||
}
|
||||
if (Array.isArray(value) || value instanceof Uint8Array) {
|
||||
return normalizeFiniteNumber(value[0]);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function normalizePositiveNumber(value: unknown): number | undefined {
|
||||
const number = normalizeFiniteNumber(value);
|
||||
return number !== undefined && number > 0 ? number : undefined;
|
||||
}
|
||||
|
||||
function normalizeInteger(value: unknown, minimum: number, maximum = Number.MAX_SAFE_INTEGER): number | undefined {
|
||||
const number = normalizeFiniteNumber(value);
|
||||
return number !== undefined && Number.isInteger(number) && number >= minimum && number <= maximum ? number : undefined;
|
||||
}
|
||||
|
||||
function normalizeDimensions(width: number, height: number): Dimensions | undefined {
|
||||
return Number.isInteger(width) && width > 0 && Number.isInteger(height) && height > 0 ? { width, height } : undefined;
|
||||
}
|
||||
|
||||
async function withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T> {
|
||||
let timeout: number | undefined;
|
||||
try {
|
||||
return await Promise.race([
|
||||
promise,
|
||||
new Promise<T>((_, reject) => {
|
||||
timeout = window.setTimeout(() => reject(new Error("media metadata extraction timed out")), timeoutMs);
|
||||
}),
|
||||
]);
|
||||
} finally {
|
||||
if (timeout !== undefined) {
|
||||
window.clearTimeout(timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function warnExtractionFailure() {
|
||||
if (import.meta.env.DEV) {
|
||||
console.warn("Media metadata extraction failed; continuing without metadata.");
|
||||
}
|
||||
}
|
||||
|
|
@ -7,7 +7,8 @@ import type { LocalFile } from "../types/attachment";
|
|||
export const uploadService = {
|
||||
async uploadFile(localFile: LocalFile): Promise<Attachment> {
|
||||
const { file, motionMedia } = localFile;
|
||||
const buffer = new Uint8Array(await file.arrayBuffer());
|
||||
const [mediaMetadata, arrayBuffer] = await Promise.all([localFile.mediaMetadata, file.arrayBuffer()]);
|
||||
const buffer = new Uint8Array(arrayBuffer);
|
||||
return attachmentServiceClient.createAttachment({
|
||||
attachment: create(AttachmentSchema, {
|
||||
filename: file.name,
|
||||
|
|
@ -15,6 +16,7 @@ export const uploadService = {
|
|||
type: file.type,
|
||||
content: buffer,
|
||||
motionMedia: motionMedia ? create(MotionMediaSchema, motionMedia) : undefined,
|
||||
mediaMetadata,
|
||||
}),
|
||||
});
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import type { Attachment, MotionMedia } from "@/types/proto/api/v1/attachment_service_pb";
|
||||
import type { Attachment, MediaMetadata, MotionMedia } from "@/types/proto/api/v1/attachment_service_pb";
|
||||
import { MotionMediaFamily, MotionMediaRole } from "@/types/proto/api/v1/attachment_service_pb";
|
||||
import { getAttachmentThumbnailUrl, getAttachmentType, getAttachmentUrl } from "@/utils/attachment";
|
||||
import { buildAttachmentVisualItems } from "@/utils/media-item";
|
||||
|
|
@ -27,6 +27,12 @@ export interface LocalFile {
|
|||
readonly durationSeconds: number;
|
||||
};
|
||||
readonly motionMedia?: MotionMedia;
|
||||
/**
|
||||
* Extraction started at file ingest when the user's save-media-metadata
|
||||
* preference was on; absent means the preference was off (or the file came
|
||||
* from a source with nothing to extract). The promise never rejects.
|
||||
*/
|
||||
readonly mediaMetadata?: Promise<MediaMetadata | undefined>;
|
||||
}
|
||||
|
||||
const AUDIO_RECORDING_FILENAME_RE = /^(?:voice-(?:recording|note)|audio-recording)-(\d{8})-(\d{4,6})/i;
|
||||
|
|
|
|||
|
|
@ -282,24 +282,46 @@ const AttachmentListEditor: FC<AttachmentListEditorProps> = ({
|
|||
const previewItems = useMemo<PreviewMediaItem[]>(
|
||||
() =>
|
||||
items.reduce<PreviewMediaItem[]>((acc, item) => {
|
||||
const itemAttachments = item.isLocal ? undefined : collectMembers(attachmentsByName, item.memberIds);
|
||||
if (item.category === "image") {
|
||||
acc.push({ id: item.id, kind: "image", sourceUrl: item.sourceUrl, posterUrl: item.thumbnailUrl, filename: item.filename });
|
||||
acc.push({
|
||||
id: item.id,
|
||||
kind: "image",
|
||||
sourceUrl: item.sourceUrl,
|
||||
posterUrl: item.thumbnailUrl,
|
||||
filename: item.filename,
|
||||
attachments: itemAttachments,
|
||||
});
|
||||
return acc;
|
||||
}
|
||||
|
||||
if (item.category === "video") {
|
||||
acc.push({ id: item.id, kind: "video", sourceUrl: item.sourceUrl, posterUrl: item.thumbnailUrl, filename: item.filename });
|
||||
acc.push({
|
||||
id: item.id,
|
||||
kind: "video",
|
||||
sourceUrl: item.sourceUrl,
|
||||
posterUrl: item.thumbnailUrl,
|
||||
filename: item.filename,
|
||||
attachments: itemAttachments,
|
||||
});
|
||||
return acc;
|
||||
}
|
||||
|
||||
if (item.category === "motion") {
|
||||
acc.push({ id: item.id, kind: "motion", motionUrl: item.sourceUrl, posterUrl: item.thumbnailUrl, filename: item.filename });
|
||||
acc.push({
|
||||
id: item.id,
|
||||
kind: "motion",
|
||||
motionUrl: item.sourceUrl,
|
||||
posterUrl: item.thumbnailUrl,
|
||||
filename: item.filename,
|
||||
attachments: itemAttachments,
|
||||
});
|
||||
return acc;
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []),
|
||||
[items],
|
||||
[attachmentsByName, items],
|
||||
);
|
||||
|
||||
// Items address their members by id, so index once instead of re-scanning both
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
import { ChevronLeft, ChevronRight, RotateCcw, X, ZoomIn, ZoomOut } from "lucide-react";
|
||||
import { ChevronLeft, ChevronRight, InfoIcon, RotateCcw, X, ZoomIn, ZoomOut } from "lucide-react";
|
||||
import React, { useEffect, useMemo, useState } from "react";
|
||||
import MediaMetadataDetails from "@/components/MediaMetadataDetails";
|
||||
import MotionPhotoPreview from "@/components/MotionPhotoPreview";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Dialog, DialogContent, DialogDescription, DialogTitle } from "@/components/ui/dialog";
|
||||
import { VisuallyHidden } from "@/components/ui/visually-hidden";
|
||||
import useMediaQuery from "@/hooks/useMediaQuery";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useTranslate } from "@/utils/i18n";
|
||||
import type { PreviewMediaItem } from "@/utils/media-item";
|
||||
|
||||
interface Props {
|
||||
|
|
@ -24,9 +26,11 @@ const DOUBLE_TAP_ZOOM = 2;
|
|||
const clampZoom = (scale: number) => Math.min(MAX_ZOOM, Math.max(MIN_ZOOM, scale));
|
||||
|
||||
function PreviewImageDialog({ open, onOpenChange, imgUrls = [], items, initialIndex = 0 }: Props) {
|
||||
const t = useTranslate();
|
||||
const sm = useMediaQuery("sm");
|
||||
const [currentIndex, setCurrentIndex] = useState(initialIndex);
|
||||
const [zoomScale, setZoomScale] = useState(MIN_ZOOM);
|
||||
const [showDetails, setShowDetails] = useState(false);
|
||||
const previewItems = useMemo(
|
||||
() => items ?? imgUrls.map((url) => ({ id: url, kind: "image" as const, sourceUrl: url, posterUrl: url, filename: "Image" })),
|
||||
[imgUrls, items],
|
||||
|
|
@ -35,6 +39,7 @@ function PreviewImageDialog({ open, onOpenChange, imgUrls = [], items, initialIn
|
|||
useEffect(() => {
|
||||
if (open) {
|
||||
setCurrentIndex(initialIndex);
|
||||
setShowDetails(false);
|
||||
}
|
||||
}, [initialIndex, open]);
|
||||
|
||||
|
|
@ -54,11 +59,6 @@ function PreviewImageDialog({ open, onOpenChange, imgUrls = [], items, initialIn
|
|||
return;
|
||||
}
|
||||
|
||||
if (event.key === "Escape") {
|
||||
onOpenChange(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.key === "ArrowLeft") {
|
||||
setCurrentIndex((prev) => Math.max(prev - 1, 0));
|
||||
return;
|
||||
|
|
@ -71,7 +71,7 @@ function PreviewImageDialog({ open, onOpenChange, imgUrls = [], items, initialIn
|
|||
|
||||
document.addEventListener("keydown", handleKeyDown);
|
||||
return () => document.removeEventListener("keydown", handleKeyDown);
|
||||
}, [itemCount, onOpenChange, open]);
|
||||
}, [itemCount, open]);
|
||||
|
||||
useEffect(() => {
|
||||
setZoomScale(MIN_ZOOM);
|
||||
|
|
@ -104,7 +104,17 @@ function PreviewImageDialog({ open, onOpenChange, imgUrls = [], items, initialIn
|
|||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<Dialog
|
||||
open={open}
|
||||
onOpenChange={(nextOpen, eventDetails) => {
|
||||
if (!nextOpen && showDetails && eventDetails.reason === "escape-key") {
|
||||
eventDetails.cancel();
|
||||
setShowDetails(false);
|
||||
return;
|
||||
}
|
||||
onOpenChange(nextOpen);
|
||||
}}
|
||||
>
|
||||
<DialogContent
|
||||
showCloseButton={false}
|
||||
className="!h-[100vh] !w-[100vw] !max-h-[100vh] !max-w-[100vw] overflow-hidden border-0 bg-black/92 p-0 shadow-none"
|
||||
|
|
@ -117,7 +127,12 @@ function PreviewImageDialog({ open, onOpenChange, imgUrls = [], items, initialIn
|
|||
</DialogDescription>
|
||||
</VisuallyHidden>
|
||||
|
||||
<div className="absolute inset-x-0 top-0 z-20 bg-linear-to-b from-black/70 via-black/35 to-transparent px-3 pb-6 pt-3 sm:px-5 sm:pt-4">
|
||||
<div
|
||||
className={cn(
|
||||
"absolute inset-x-0 top-0 z-50 bg-linear-to-b from-black/70 via-black/35 to-transparent px-3 pb-6 pt-3 sm:px-5 sm:pt-4",
|
||||
showDetails && "lg:pr-[23rem]",
|
||||
)}
|
||||
>
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="min-w-0 text-white">
|
||||
<div className="truncate text-sm font-medium">{currentItem.filename || "Attachment"}</div>
|
||||
|
|
@ -128,16 +143,30 @@ function PreviewImageDialog({ open, onOpenChange, imgUrls = [], items, initialIn
|
|||
)}
|
||||
</div>
|
||||
|
||||
<Button
|
||||
type="button"
|
||||
onClick={handleClose}
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="shrink-0 rounded-full bg-white/10 text-white hover:bg-white/16 hover:text-white"
|
||||
aria-label="Close preview"
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</Button>
|
||||
<div className="flex shrink-0 items-center gap-1.5">
|
||||
<Button
|
||||
type="button"
|
||||
onClick={() => setShowDetails((visible) => !visible)}
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className={cn("rounded-full text-white hover:bg-white/16 hover:text-white", showDetails ? "bg-white/18" : "bg-white/10")}
|
||||
aria-label={showDetails ? t("attachment-details.actions.hide") : t("attachment-details.actions.show")}
|
||||
aria-expanded={showDetails}
|
||||
aria-controls="attachment-media-details"
|
||||
>
|
||||
<InfoIcon className="h-4 w-4" />
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
onClick={handleClose}
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="rounded-full bg-white/10 text-white hover:bg-white/16 hover:text-white"
|
||||
aria-label="Close preview"
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -146,11 +175,16 @@ function PreviewImageDialog({ open, onOpenChange, imgUrls = [], items, initialIn
|
|||
className={cn(
|
||||
"flex h-full w-full items-center justify-center px-3 pb-20 pt-16 sm:px-16 sm:pb-8 sm:pt-20",
|
||||
isImagePreview && "cursor-zoom-in",
|
||||
showDetails && "lg:pr-[26rem]",
|
||||
)}
|
||||
onWheel={handleWheel}
|
||||
onClick={(event) => {
|
||||
if (event.target === event.currentTarget && !isZoomed) {
|
||||
handleClose();
|
||||
if (showDetails) {
|
||||
setShowDetails(false);
|
||||
} else {
|
||||
handleClose();
|
||||
}
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
|
@ -160,7 +194,10 @@ function PreviewImageDialog({ open, onOpenChange, imgUrls = [], items, initialIn
|
|||
key={currentItem.id}
|
||||
src={currentItem.sourceUrl}
|
||||
poster={currentItem.posterUrl}
|
||||
className="max-h-[calc(100vh-8rem)] max-w-[calc(100vw-1.5rem)] rounded-md object-contain sm:max-h-[calc(100vh-7rem)] sm:max-w-[calc(100vw-8rem)]"
|
||||
className={cn(
|
||||
"max-h-[calc(100vh-8rem)] max-w-[calc(100vw-1.5rem)] rounded-md object-contain sm:max-h-[calc(100vh-7rem)] sm:max-w-[calc(100vw-8rem)]",
|
||||
showDetails && "lg:max-w-[calc(100vw-30rem)]",
|
||||
)}
|
||||
controls
|
||||
autoPlay
|
||||
playsInline
|
||||
|
|
@ -173,13 +210,19 @@ function PreviewImageDialog({ open, onOpenChange, imgUrls = [], items, initialIn
|
|||
alt={`Preview live photo ${safeIndex + 1} of ${itemCount}`}
|
||||
presentationTimestampUs={currentItem.presentationTimestampUs}
|
||||
badgeClassName="left-3 top-3 sm:left-4 sm:top-4"
|
||||
mediaClassName="max-h-[calc(100vh-8rem)] max-w-[calc(100vw-1.5rem)] rounded-md object-contain sm:max-h-[calc(100vh-7rem)] sm:max-w-[calc(100vw-8rem)]"
|
||||
mediaClassName={cn(
|
||||
"max-h-[calc(100vh-8rem)] max-w-[calc(100vw-1.5rem)] rounded-md object-contain sm:max-h-[calc(100vh-7rem)] sm:max-w-[calc(100vw-8rem)]",
|
||||
showDetails && "lg:max-w-[calc(100vw-30rem)]",
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<img
|
||||
src={currentItem.sourceUrl}
|
||||
alt={`Preview image ${safeIndex + 1} of ${itemCount}`}
|
||||
className="max-h-[calc(100vh-8rem)] max-w-[calc(100vw-1.5rem)] rounded-md object-contain select-none sm:max-h-[calc(100vh-7rem)] sm:max-w-[calc(100vw-8rem)]"
|
||||
className={cn(
|
||||
"max-h-[calc(100vh-8rem)] max-w-[calc(100vw-1.5rem)] rounded-md object-contain select-none sm:max-h-[calc(100vh-7rem)] sm:max-w-[calc(100vw-8rem)]",
|
||||
showDetails && "lg:max-w-[calc(100vw-30rem)]",
|
||||
)}
|
||||
style={{
|
||||
transform: `translate3d(0px, 0px, 0) scale(${zoomScale})`,
|
||||
transition: "transform 120ms ease-out",
|
||||
|
|
@ -195,7 +238,7 @@ function PreviewImageDialog({ open, onOpenChange, imgUrls = [], items, initialIn
|
|||
</div>
|
||||
|
||||
{isImagePreview && (
|
||||
<div className="absolute inset-x-0 bottom-0 z-30 px-3 pb-3 pt-6">
|
||||
<div className={cn("absolute inset-x-0 bottom-0 z-30 px-3 pb-3 pt-6", showDetails && "hidden lg:block lg:pr-[22rem]")}>
|
||||
<div className="mx-auto flex w-fit items-center gap-1 rounded-full bg-black/60 px-2 py-2 text-white shadow-lg backdrop-blur-sm">
|
||||
{hasMultiple && !sm && (
|
||||
<>
|
||||
|
|
@ -241,11 +284,12 @@ function PreviewImageDialog({ open, onOpenChange, imgUrls = [], items, initialIn
|
|||
label="Next item"
|
||||
onClick={handleNext}
|
||||
icon={<ChevronRight className="h-5 w-5" />}
|
||||
detailsOpen={showDetails}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
|
||||
{hasMultiple && !sm && !isImagePreview && (
|
||||
{hasMultiple && !sm && !isImagePreview && !showDetails && (
|
||||
<div className="absolute inset-x-0 bottom-0 z-20 px-3 pb-3 pt-6">
|
||||
<div className="mx-auto flex max-w-xs items-center justify-between rounded-full bg-black/55 px-2 py-2 backdrop-blur-sm">
|
||||
<Button
|
||||
|
|
@ -274,6 +318,8 @@ function PreviewImageDialog({ open, onOpenChange, imgUrls = [], items, initialIn
|
|||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{showDetails && <MediaMetadataDetails id="attachment-media-details" item={currentItem} onClose={() => setShowDetails(false)} />}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
|
|
@ -285,9 +331,10 @@ interface NavButtonProps {
|
|||
label: string;
|
||||
onClick: () => void;
|
||||
icon: React.ReactNode;
|
||||
detailsOpen?: boolean;
|
||||
}
|
||||
|
||||
const NavButton = ({ side, disabled, label, onClick, icon }: NavButtonProps) => (
|
||||
const NavButton = ({ side, disabled, label, onClick, icon, detailsOpen = false }: NavButtonProps) => (
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
|
|
@ -297,7 +344,7 @@ const NavButton = ({ side, disabled, label, onClick, icon }: NavButtonProps) =>
|
|||
aria-label={label}
|
||||
className={cn(
|
||||
"absolute top-1/2 z-20 hidden h-11 w-11 -translate-y-1/2 rounded-full bg-white/10 text-white backdrop-blur-sm hover:bg-white/16 hover:text-white disabled:opacity-25 sm:flex",
|
||||
side === "left" ? "left-4" : "right-4",
|
||||
side === "left" ? "left-4" : detailsOpen ? "right-4 lg:right-[23rem]" : "right-4",
|
||||
)}
|
||||
>
|
||||
{icon}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { create } from "@bufbuild/protobuf";
|
||||
import { useMemo } from "react";
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import { useAuth } from "@/contexts/AuthContext";
|
||||
import { useUpdateUserGeneralSetting } from "@/hooks/useUserQueries";
|
||||
import { Visibility } from "@/types/proto/api/v1/memo_service_pb";
|
||||
|
|
@ -18,7 +19,7 @@ import SettingSection from "./SettingSection";
|
|||
const PreferencesSection = () => {
|
||||
const t = useTranslate();
|
||||
const { currentUser, userGeneralSetting: generalSetting, refetchSettings } = useAuth();
|
||||
const { mutate: updateUserGeneralSetting } = useUpdateUserGeneralSetting(currentUser?.name);
|
||||
const { mutate: updateUserGeneralSetting, isPending: isUpdatingGeneralSetting } = useUpdateUserGeneralSetting(currentUser?.name);
|
||||
|
||||
const handleLocaleSelectChange = (locale: Locale) => {
|
||||
// Apply locale immediately for instant UI feedback and persist to localStorage
|
||||
|
|
@ -68,6 +69,17 @@ const PreferencesSection = () => {
|
|||
);
|
||||
};
|
||||
|
||||
const handleSaveMediaMetadataChange = (saveMediaMetadata: boolean) => {
|
||||
updateUserGeneralSetting(
|
||||
{ generalSetting: { saveMediaMetadata }, updateMask: ["save_media_metadata"] },
|
||||
{
|
||||
onSuccess: async () => {
|
||||
await refetchSettings();
|
||||
},
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
// Provide default values if setting is not loaded yet
|
||||
const setting: UserSetting_GeneralSetting =
|
||||
generalSetting ||
|
||||
|
|
@ -75,6 +87,7 @@ const PreferencesSection = () => {
|
|||
locale: "en",
|
||||
memoVisibility: "PRIVATE",
|
||||
theme: "system",
|
||||
saveMediaMetadata: false,
|
||||
});
|
||||
|
||||
return (
|
||||
|
|
@ -123,6 +136,26 @@ const PreferencesSection = () => {
|
|||
</SettingListItem>
|
||||
</SettingList>
|
||||
</SettingGroup>
|
||||
|
||||
<SettingGroup
|
||||
title={t("setting.preference.uploads-privacy-title")}
|
||||
description={t("setting.preference.uploads-privacy-description")}
|
||||
showSeparator
|
||||
>
|
||||
<SettingList>
|
||||
<SettingListItem
|
||||
label={t("setting.preference.save-media-metadata")}
|
||||
description={t("setting.preference.save-media-metadata-description")}
|
||||
>
|
||||
<Switch
|
||||
aria-label={t("setting.preference.save-media-metadata")}
|
||||
checked={setting.saveMediaMetadata}
|
||||
disabled={isUpdatingGeneralSetting}
|
||||
onCheckedChange={handleSaveMediaMetadataChange}
|
||||
/>
|
||||
</SettingListItem>
|
||||
</SettingList>
|
||||
</SettingGroup>
|
||||
</SettingSection>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -53,6 +53,39 @@
|
|||
"banner-title": "Memos demo",
|
||||
"deploy-link": "Deploy your own Memos"
|
||||
},
|
||||
"attachment-details": {
|
||||
"actions": {
|
||||
"copied": "Coordinates copied",
|
||||
"copy-coordinates": "Copy coordinates",
|
||||
"hide": "Hide attachment details",
|
||||
"hide-map": "Hide map",
|
||||
"show": "Show attachment details",
|
||||
"show-map": "Show map"
|
||||
},
|
||||
"empty": "No saved capture metadata.",
|
||||
"fields": {
|
||||
"altitude": "Altitude",
|
||||
"camera": "Camera",
|
||||
"captured": "Captured",
|
||||
"dimensions": "Dimensions",
|
||||
"duration": "Duration",
|
||||
"exposure": "Exposure",
|
||||
"file": "File",
|
||||
"lens": "Lens",
|
||||
"location": "Coordinates",
|
||||
"source-orientation": "Source EXIF orientation",
|
||||
"uploaded": "Uploaded"
|
||||
},
|
||||
"sections": {
|
||||
"camera": "Camera",
|
||||
"capture": "Capture",
|
||||
"file": "File",
|
||||
"location": "Location",
|
||||
"technical": "Technical details"
|
||||
},
|
||||
"timezone-unknown": "Time zone unknown",
|
||||
"title": "Details"
|
||||
},
|
||||
"attachment-library": {
|
||||
"actions": {
|
||||
"open": "Open",
|
||||
|
|
@ -674,8 +707,12 @@
|
|||
"language-description": "Updates the interface language immediately and saves it to your account.",
|
||||
"memo-defaults-description": "Set the defaults used when composing new memos.",
|
||||
"memo-defaults-title": "Memo defaults",
|
||||
"save-media-metadata": "Save media metadata",
|
||||
"save-media-metadata-description": "For future uploads, save available camera, capture time, location, image dimensions, and basic video details. Anyone who can view the attachment can receive this metadata. Existing attachments are unchanged.",
|
||||
"theme-description": "Applies the selected theme immediately on this device.",
|
||||
"theme": "Theme"
|
||||
"theme": "Theme",
|
||||
"uploads-privacy-description": "Control privacy-sensitive information submitted with uploaded media.",
|
||||
"uploads-privacy-title": "Uploads & privacy"
|
||||
},
|
||||
"memo-view": {
|
||||
"delete-confirm": "Are you sure you want to delete view `{{title}}`?",
|
||||
|
|
|
|||
|
|
@ -508,9 +508,13 @@
|
|||
"language-description": "立即更新界面语言,并保存到当前账号。",
|
||||
"memo-defaults-description": "设置创建新备忘录时使用的默认值。",
|
||||
"memo-defaults-title": "备忘录默认值",
|
||||
"save-media-metadata": "保存媒体元数据",
|
||||
"save-media-metadata-description": "为之后上传的文件保存可用的相机型号、拍摄时间、位置、图片尺寸和基础视频信息。任何能查看附件的人都可能获取这些元数据。已有附件不受影响。",
|
||||
"theme-description": "立即在当前设备上应用所选主题。",
|
||||
"theme": "主题",
|
||||
"label": "偏好设置"
|
||||
"label": "偏好设置",
|
||||
"uploads-privacy-description": "控制上传媒体时提交的隐私敏感信息。",
|
||||
"uploads-privacy-title": "上传与隐私"
|
||||
},
|
||||
"memo-view": {
|
||||
"delete-confirm": "您确定要删除视图 `{{title}}` 吗?",
|
||||
|
|
@ -883,6 +887,39 @@
|
|||
"connecting": "正在连接",
|
||||
"disconnected": "已断开"
|
||||
},
|
||||
"attachment-details": {
|
||||
"actions": {
|
||||
"copied": "已复制坐标",
|
||||
"copy-coordinates": "复制坐标",
|
||||
"hide": "隐藏附件详情",
|
||||
"hide-map": "隐藏地图",
|
||||
"show": "显示附件详情",
|
||||
"show-map": "显示地图"
|
||||
},
|
||||
"empty": "没有保存的拍摄信息。",
|
||||
"fields": {
|
||||
"altitude": "海拔",
|
||||
"camera": "相机",
|
||||
"captured": "拍摄时间",
|
||||
"dimensions": "尺寸",
|
||||
"duration": "时长",
|
||||
"exposure": "曝光",
|
||||
"file": "文件",
|
||||
"lens": "镜头",
|
||||
"location": "坐标",
|
||||
"source-orientation": "源 EXIF 方向",
|
||||
"uploaded": "上传时间"
|
||||
},
|
||||
"sections": {
|
||||
"camera": "相机",
|
||||
"capture": "拍摄",
|
||||
"file": "文件",
|
||||
"location": "位置",
|
||||
"technical": "技术信息"
|
||||
},
|
||||
"timezone-unknown": "未知时区",
|
||||
"title": "详情"
|
||||
},
|
||||
"attachment-library": {
|
||||
"actions": {
|
||||
"open": "打开",
|
||||
|
|
|
|||
|
|
@ -54,6 +54,39 @@
|
|||
"banner-title": "Memos demo",
|
||||
"deploy-link": "部署您的 Memos"
|
||||
},
|
||||
"attachment-details": {
|
||||
"actions": {
|
||||
"copied": "已複製座標",
|
||||
"copy-coordinates": "複製座標",
|
||||
"hide": "隱藏附件詳細資訊",
|
||||
"hide-map": "隱藏地圖",
|
||||
"show": "顯示附件詳細資訊",
|
||||
"show-map": "顯示地圖"
|
||||
},
|
||||
"empty": "沒有儲存的拍攝資訊。",
|
||||
"fields": {
|
||||
"altitude": "海拔",
|
||||
"camera": "相機",
|
||||
"captured": "拍攝時間",
|
||||
"dimensions": "尺寸",
|
||||
"duration": "時長",
|
||||
"exposure": "曝光",
|
||||
"file": "檔案",
|
||||
"lens": "鏡頭",
|
||||
"location": "座標",
|
||||
"source-orientation": "來源 EXIF 方向",
|
||||
"uploaded": "上傳時間"
|
||||
},
|
||||
"sections": {
|
||||
"camera": "相機",
|
||||
"capture": "拍攝",
|
||||
"file": "檔案",
|
||||
"location": "位置",
|
||||
"technical": "技術資訊"
|
||||
},
|
||||
"timezone-unknown": "未知時區",
|
||||
"title": "詳細資訊"
|
||||
},
|
||||
"attachment-library": {
|
||||
"actions": {
|
||||
"open": "開啟",
|
||||
|
|
@ -679,8 +712,12 @@
|
|||
"language-description": "立即更新介面語言並儲存至您的帳號。",
|
||||
"memo-defaults-description": "設定撰寫新備忘錄時使用的預設值。",
|
||||
"memo-defaults-title": "備忘錄預設值",
|
||||
"save-media-metadata": "儲存媒體中繼資料",
|
||||
"save-media-metadata-description": "為之後上傳的檔案儲存可用的相機型號、拍攝時間、位置、圖片尺寸和基本影片資訊。任何能檢視附件的人都可能取得這些中繼資料。現有附件不受影響。",
|
||||
"theme-description": "立即在此裝置上套入選定的主題。",
|
||||
"theme": "主題"
|
||||
"theme": "主題",
|
||||
"uploads-privacy-description": "控制上傳媒體時提交的隱私敏感資訊。",
|
||||
"uploads-privacy-title": "上傳與隱私"
|
||||
},
|
||||
"memo-view": {
|
||||
"delete-confirm": "您確定要刪除檢視 `{{title}}` 嗎?",
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import type { Message } from "@bufbuild/protobuf";
|
|||
* Describes the file api/v1/attachment_service.proto.
|
||||
*/
|
||||
export const file_api_v1_attachment_service: GenFile = /*@__PURE__*/
|
||||
fileDesc("Ch9hcGkvdjEvYXR0YWNobWVudF9zZXJ2aWNlLnByb3RvEgxtZW1vcy5hcGkudjEivAEKC01vdGlvbk1lZGlhEi8KBmZhbWlseRgBIAEoDjIfLm1lbW9zLmFwaS52MS5Nb3Rpb25NZWRpYUZhbWlseRIrCgRyb2xlGAIgASgOMh0ubWVtb3MuYXBpLnYxLk1vdGlvbk1lZGlhUm9sZRIQCghncm91cF9pZBgDIAEoCRIhChlwcmVzZW50YXRpb25fdGltZXN0YW1wX3VzGAQgASgDEhoKEmhhc19lbWJlZGRlZF92aWRlbxgFIAEoCCLsAgoKQXR0YWNobWVudBIRCgRuYW1lGAEgASgJQgPgQQgSNAoLY3JlYXRlX3RpbWUYAiABKAsyGi5nb29nbGUucHJvdG9idWYuVGltZXN0YW1wQgPgQQMSFQoIZmlsZW5hbWUYAyABKAlCA+BBAhIUCgdjb250ZW50GAQgASgMQgPgQQQSGgoNZXh0ZXJuYWxfbGluaxgFIAEoCUID4EEBEhEKBHR5cGUYBiABKAlCA+BBAhIRCgRzaXplGAcgASgDQgPgQQMSFgoEbWVtbxgIIAEoCUID4EEBSACIAQESNAoMbW90aW9uX21lZGlhGAkgASgLMhkubWVtb3MuYXBpLnYxLk1vdGlvbk1lZGlhQgPgQQE6T+pBTAoXbWVtb3MuYXBpLnYxL0F0dGFjaG1lbnQSGGF0dGFjaG1lbnRzL3thdHRhY2htZW50fSoLYXR0YWNobWVudHMyCmF0dGFjaG1lbnRCBwoFX21lbW8iaAoXQ3JlYXRlQXR0YWNobWVudFJlcXVlc3QSMQoKYXR0YWNobWVudBgBIAEoCzIYLm1lbW9zLmFwaS52MS5BdHRhY2htZW50QgPgQQISGgoNYXR0YWNobWVudF9pZBgCIAEoCUID4EEBInUKFkxpc3RBdHRhY2htZW50c1JlcXVlc3QSFgoJcGFnZV9zaXplGAEgASgFQgPgQQESFwoKcGFnZV90b2tlbhgCIAEoCUID4EEBEhMKBmZpbHRlchgDIAEoCUID4EEBEhUKCG9yZGVyX2J5GAQgASgJQgPgQQEiYQoXTGlzdEF0dGFjaG1lbnRzUmVzcG9uc2USLQoLYXR0YWNobWVudHMYASADKAsyGC5tZW1vcy5hcGkudjEuQXR0YWNobWVudBIXCg9uZXh0X3BhZ2VfdG9rZW4YAiABKAkiRQoUR2V0QXR0YWNobWVudFJlcXVlc3QSLQoEbmFtZRgBIAEoCUIf4EEC+kEZChdtZW1vcy5hcGkudjEvQXR0YWNobWVudCKCAQoXVXBkYXRlQXR0YWNobWVudFJlcXVlc3QSMQoKYXR0YWNobWVudBgBIAEoCzIYLm1lbW9zLmFwaS52MS5BdHRhY2htZW50QgPgQQISNAoLdXBkYXRlX21hc2sYAiABKAsyGi5nb29nbGUucHJvdG9idWYuRmllbGRNYXNrQgPgQQIiSAoXRGVsZXRlQXR0YWNobWVudFJlcXVlc3QSLQoEbmFtZRgBIAEoCUIf4EEC+kEZChdtZW1vcy5hcGkudjEvQXR0YWNobWVudCIzCh1CYXRjaERlbGV0ZUF0dGFjaG1lbnRzUmVxdWVzdBISCgVuYW1lcxgBIAMoCUID4EECKmgKEU1vdGlvbk1lZGlhRmFtaWx5EiMKH01PVElPTl9NRURJQV9GQU1JTFlfVU5TUEVDSUZJRUQQABIUChBBUFBMRV9MSVZFX1BIT1RPEAESGAoUQU5EUk9JRF9NT1RJT05fUEhPVE8QAipZCg9Nb3Rpb25NZWRpYVJvbGUSIQodTU9USU9OX01FRElBX1JPTEVfVU5TUEVDSUZJRUQQABIJCgVTVElMTBABEgkKBVZJREVPEAISDQoJQ09OVEFJTkVSEAMy0AYKEUF0dGFjaG1lbnRTZXJ2aWNlEokBChBDcmVhdGVBdHRhY2htZW50EiUubWVtb3MuYXBpLnYxLkNyZWF0ZUF0dGFjaG1lbnRSZXF1ZXN0GhgubWVtb3MuYXBpLnYxLkF0dGFjaG1lbnQiNNpBCmF0dGFjaG1lbnSC0+STAiE6CmF0dGFjaG1lbnQiEy9hcGkvdjEvYXR0YWNobWVudHMSewoPTGlzdEF0dGFjaG1lbnRzEiQubWVtb3MuYXBpLnYxLkxpc3RBdHRhY2htZW50c1JlcXVlc3QaJS5tZW1vcy5hcGkudjEuTGlzdEF0dGFjaG1lbnRzUmVzcG9uc2UiG4LT5JMCFRITL2FwaS92MS9hdHRhY2htZW50cxJ6Cg1HZXRBdHRhY2htZW50EiIubWVtb3MuYXBpLnYxLkdldEF0dGFjaG1lbnRSZXF1ZXN0GhgubWVtb3MuYXBpLnYxLkF0dGFjaG1lbnQiK9pBBG5hbWWC0+STAh4SHC9hcGkvdjEve25hbWU9YXR0YWNobWVudHMvKn0SqQEKEFVwZGF0ZUF0dGFjaG1lbnQSJS5tZW1vcy5hcGkudjEuVXBkYXRlQXR0YWNobWVudFJlcXVlc3QaGC5tZW1vcy5hcGkudjEuQXR0YWNobWVudCJU2kEWYXR0YWNobWVudCx1cGRhdGVfbWFza4LT5JMCNToKYXR0YWNobWVudDInL2FwaS92MS97YXR0YWNobWVudC5uYW1lPWF0dGFjaG1lbnRzLyp9En4KEERlbGV0ZUF0dGFjaG1lbnQSJS5tZW1vcy5hcGkudjEuRGVsZXRlQXR0YWNobWVudFJlcXVlc3QaFi5nb29nbGUucHJvdG9idWYuRW1wdHkiK9pBBG5hbWWC0+STAh4qHC9hcGkvdjEve25hbWU9YXR0YWNobWVudHMvKn0SiQEKFkJhdGNoRGVsZXRlQXR0YWNobWVudHMSKy5tZW1vcy5hcGkudjEuQmF0Y2hEZWxldGVBdHRhY2htZW50c1JlcXVlc3QaFi5nb29nbGUucHJvdG9idWYuRW1wdHkiKoLT5JMCJDoBKiIfL2FwaS92MS9hdHRhY2htZW50czpiYXRjaERlbGV0ZUKuAQoQY29tLm1lbW9zLmFwaS52MUIWQXR0YWNobWVudFNlcnZpY2VQcm90b1ABWjBnaXRodWIuY29tL3VzZW1lbW9zL21lbW9zL3Byb3RvL2dlbi9hcGkvdjE7YXBpdjGiAgNNQViqAgxNZW1vcy5BcGkuVjHKAgxNZW1vc1xBcGlcVjHiAhhNZW1vc1xBcGlcVjFcR1BCTWV0YWRhdGHqAg5NZW1vczo6QXBpOjpWMWIGcHJvdG8z", [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("Ch9hcGkvdjEvYXR0YWNobWVudF9zZXJ2aWNlLnByb3RvEgxtZW1vcy5hcGkudjEivAEKC01vdGlvbk1lZGlhEi8KBmZhbWlseRgBIAEoDjIfLm1lbW9zLmFwaS52MS5Nb3Rpb25NZWRpYUZhbWlseRIrCgRyb2xlGAIgASgOMh0ubWVtb3MuYXBpLnYxLk1vdGlvbk1lZGlhUm9sZRIQCghncm91cF9pZBgDIAEoCRIhChlwcmVzZW50YXRpb25fdGltZXN0YW1wX3VzGAQgASgDEhoKEmhhc19lbWJlZGRlZF92aWRlbxgFIAEoCCK0AQoNTWVkaWFNZXRhZGF0YRISCgV3aWR0aBgBIAEoBUgBiAEBEhMKBmhlaWdodBgCIAEoBUgCiAEBEiwKBXBob3RvGAMgASgLMhsubWVtb3MuYXBpLnYxLlBob3RvTWV0YWRhdGFIABIsCgV2aWRlbxgEIAEoCzIbLm1lbW9zLmFwaS52MS5WaWRlb01ldGFkYXRhSABCCQoHZGV0YWlsc0IICgZfd2lkdGhCCQoHX2hlaWdodCKjAwoNUGhvdG9NZXRhZGF0YRI0CgxjYXB0dXJlX3RpbWUYASABKAsyHi5tZW1vcy5hcGkudjEuTWVkaWFDYXB0dXJlVGltZRItCghsb2NhdGlvbhgCIAEoCzIbLm1lbW9zLmFwaS52MS5NZWRpYUxvY2F0aW9uEiQKF3NvdXJjZV9leGlmX29yaWVudGF0aW9uGAMgASgFSACIAQESEwoLY2FtZXJhX21ha2UYBCABKAkSFAoMY2FtZXJhX21vZGVsGAUgASgJEhIKCmxlbnNfbW9kZWwYBiABKAkSFQoIZl9udW1iZXIYByABKAFIAYgBARIiChVleHBvc3VyZV90aW1lX3NlY29uZHMYCCABKAFIAogBARIQCgNpc28YCSABKAVIA4gBARIcCg9mb2NhbF9sZW5ndGhfbW0YCiABKAFIBIgBAUIaChhfc291cmNlX2V4aWZfb3JpZW50YXRpb25CCwoJX2ZfbnVtYmVyQhgKFl9leHBvc3VyZV90aW1lX3NlY29uZHNCBgoEX2lzb0ISChBfZm9jYWxfbGVuZ3RoX21tIlMKEE1lZGlhQ2FwdHVyZVRpbWUSFwoPbG9jYWxfZGF0ZV90aW1lGAEgASgJEhcKCnV0Y19vZmZzZXQYAiABKAlIAIgBAUINCgtfdXRjX29mZnNldCKLAQoNTWVkaWFMb2NhdGlvbhIVCghsYXRpdHVkZRgBIAEoAUgAiAEBEhYKCWxvbmdpdHVkZRgCIAEoAUgBiAEBEhwKD2FsdGl0dWRlX21ldGVycxgDIAEoAUgCiAEBQgsKCV9sYXRpdHVkZUIMCgpfbG9uZ2l0dWRlQhIKEF9hbHRpdHVkZV9tZXRlcnMiQwoNVmlkZW9NZXRhZGF0YRIdChBkdXJhdGlvbl9zZWNvbmRzGAEgASgBSACIAQFCEwoRX2R1cmF0aW9uX3NlY29uZHMiqQMKCkF0dGFjaG1lbnQSEQoEbmFtZRgBIAEoCUID4EEIEjQKC2NyZWF0ZV90aW1lGAIgASgLMhouZ29vZ2xlLnByb3RvYnVmLlRpbWVzdGFtcEID4EEDEhUKCGZpbGVuYW1lGAMgASgJQgPgQQISFAoHY29udGVudBgEIAEoDEID4EEEEhoKDWV4dGVybmFsX2xpbmsYBSABKAlCA+BBARIRCgR0eXBlGAYgASgJQgPgQQISEQoEc2l6ZRgHIAEoA0ID4EEDEhYKBG1lbW8YCCABKAlCA+BBAUgAiAEBEjQKDG1vdGlvbl9tZWRpYRgJIAEoCzIZLm1lbW9zLmFwaS52MS5Nb3Rpb25NZWRpYUID4EEBEjsKDm1lZGlhX21ldGFkYXRhGAogASgLMhsubWVtb3MuYXBpLnYxLk1lZGlhTWV0YWRhdGFCBuBBAeBBBTpP6kFMChdtZW1vcy5hcGkudjEvQXR0YWNobWVudBIYYXR0YWNobWVudHMve2F0dGFjaG1lbnR9KgthdHRhY2htZW50czIKYXR0YWNobWVudEIHCgVfbWVtbyJoChdDcmVhdGVBdHRhY2htZW50UmVxdWVzdBIxCgphdHRhY2htZW50GAEgASgLMhgubWVtb3MuYXBpLnYxLkF0dGFjaG1lbnRCA+BBAhIaCg1hdHRhY2htZW50X2lkGAIgASgJQgPgQQEidQoWTGlzdEF0dGFjaG1lbnRzUmVxdWVzdBIWCglwYWdlX3NpemUYASABKAVCA+BBARIXCgpwYWdlX3Rva2VuGAIgASgJQgPgQQESEwoGZmlsdGVyGAMgASgJQgPgQQESFQoIb3JkZXJfYnkYBCABKAlCA+BBASJhChdMaXN0QXR0YWNobWVudHNSZXNwb25zZRItCgthdHRhY2htZW50cxgBIAMoCzIYLm1lbW9zLmFwaS52MS5BdHRhY2htZW50EhcKD25leHRfcGFnZV90b2tlbhgCIAEoCSJFChRHZXRBdHRhY2htZW50UmVxdWVzdBItCgRuYW1lGAEgASgJQh/gQQL6QRkKF21lbW9zLmFwaS52MS9BdHRhY2htZW50IoIBChdVcGRhdGVBdHRhY2htZW50UmVxdWVzdBIxCgphdHRhY2htZW50GAEgASgLMhgubWVtb3MuYXBpLnYxLkF0dGFjaG1lbnRCA+BBAhI0Cgt1cGRhdGVfbWFzaxgCIAEoCzIaLmdvb2dsZS5wcm90b2J1Zi5GaWVsZE1hc2tCA+BBAiJIChdEZWxldGVBdHRhY2htZW50UmVxdWVzdBItCgRuYW1lGAEgASgJQh/gQQL6QRkKF21lbW9zLmFwaS52MS9BdHRhY2htZW50IjMKHUJhdGNoRGVsZXRlQXR0YWNobWVudHNSZXF1ZXN0EhIKBW5hbWVzGAEgAygJQgPgQQIqaAoRTW90aW9uTWVkaWFGYW1pbHkSIwofTU9USU9OX01FRElBX0ZBTUlMWV9VTlNQRUNJRklFRBAAEhQKEEFQUExFX0xJVkVfUEhPVE8QARIYChRBTkRST0lEX01PVElPTl9QSE9UTxACKlkKD01vdGlvbk1lZGlhUm9sZRIhCh1NT1RJT05fTUVESUFfUk9MRV9VTlNQRUNJRklFRBAAEgkKBVNUSUxMEAESCQoFVklERU8QAhINCglDT05UQUlORVIQAzLQBgoRQXR0YWNobWVudFNlcnZpY2USiQEKEENyZWF0ZUF0dGFjaG1lbnQSJS5tZW1vcy5hcGkudjEuQ3JlYXRlQXR0YWNobWVudFJlcXVlc3QaGC5tZW1vcy5hcGkudjEuQXR0YWNobWVudCI02kEKYXR0YWNobWVudILT5JMCIToKYXR0YWNobWVudCITL2FwaS92MS9hdHRhY2htZW50cxJ7Cg9MaXN0QXR0YWNobWVudHMSJC5tZW1vcy5hcGkudjEuTGlzdEF0dGFjaG1lbnRzUmVxdWVzdBolLm1lbW9zLmFwaS52MS5MaXN0QXR0YWNobWVudHNSZXNwb25zZSIbgtPkkwIVEhMvYXBpL3YxL2F0dGFjaG1lbnRzEnoKDUdldEF0dGFjaG1lbnQSIi5tZW1vcy5hcGkudjEuR2V0QXR0YWNobWVudFJlcXVlc3QaGC5tZW1vcy5hcGkudjEuQXR0YWNobWVudCIr2kEEbmFtZYLT5JMCHhIcL2FwaS92MS97bmFtZT1hdHRhY2htZW50cy8qfRKpAQoQVXBkYXRlQXR0YWNobWVudBIlLm1lbW9zLmFwaS52MS5VcGRhdGVBdHRhY2htZW50UmVxdWVzdBoYLm1lbW9zLmFwaS52MS5BdHRhY2htZW50IlTaQRZhdHRhY2htZW50LHVwZGF0ZV9tYXNrgtPkkwI1OgphdHRhY2htZW50MicvYXBpL3YxL3thdHRhY2htZW50Lm5hbWU9YXR0YWNobWVudHMvKn0SfgoQRGVsZXRlQXR0YWNobWVudBIlLm1lbW9zLmFwaS52MS5EZWxldGVBdHRhY2htZW50UmVxdWVzdBoWLmdvb2dsZS5wcm90b2J1Zi5FbXB0eSIr2kEEbmFtZYLT5JMCHiocL2FwaS92MS97bmFtZT1hdHRhY2htZW50cy8qfRKJAQoWQmF0Y2hEZWxldGVBdHRhY2htZW50cxIrLm1lbW9zLmFwaS52MS5CYXRjaERlbGV0ZUF0dGFjaG1lbnRzUmVxdWVzdBoWLmdvb2dsZS5wcm90b2J1Zi5FbXB0eSIqgtPkkwIkOgEqIh8vYXBpL3YxL2F0dGFjaG1lbnRzOmJhdGNoRGVsZXRlQq4BChBjb20ubWVtb3MuYXBpLnYxQhZBdHRhY2htZW50U2VydmljZVByb3RvUAFaMGdpdGh1Yi5jb20vdXNlbWVtb3MvbWVtb3MvcHJvdG8vZ2VuL2FwaS92MTthcGl2MaICA01BWKoCDE1lbW9zLkFwaS5WMcoCDE1lbW9zXEFwaVxWMeICGE1lbW9zXEFwaVxWMVxHUEJNZXRhZGF0YeoCDk1lbW9zOjpBcGk6OlYxYgZwcm90bzM", [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]);
|
||||
|
||||
/**
|
||||
* @generated from message memos.api.v1.MotionMedia
|
||||
|
|
@ -55,6 +55,198 @@ export type MotionMedia = Message<"memos.api.v1.MotionMedia"> & {
|
|||
export const MotionMediaSchema: GenMessage<MotionMedia> = /*@__PURE__*/
|
||||
messageDesc(file_api_v1_attachment_service, 0);
|
||||
|
||||
/**
|
||||
* MediaMetadata contains normalized metadata explicitly supplied by a client.
|
||||
* The server validates and stores this data but does not extract it from the media file.
|
||||
*
|
||||
* @generated from message memos.api.v1.MediaMetadata
|
||||
*/
|
||||
export type MediaMetadata = Message<"memos.api.v1.MediaMetadata"> & {
|
||||
/**
|
||||
* Optional. Display-oriented width in pixels.
|
||||
*
|
||||
* @generated from field: optional int32 width = 1;
|
||||
*/
|
||||
width?: number | undefined;
|
||||
|
||||
/**
|
||||
* Optional. Display-oriented height in pixels.
|
||||
*
|
||||
* @generated from field: optional int32 height = 2;
|
||||
*/
|
||||
height?: number | undefined;
|
||||
|
||||
/**
|
||||
* @generated from oneof memos.api.v1.MediaMetadata.details
|
||||
*/
|
||||
details: {
|
||||
/**
|
||||
* @generated from field: memos.api.v1.PhotoMetadata photo = 3;
|
||||
*/
|
||||
value: PhotoMetadata;
|
||||
case: "photo";
|
||||
} | {
|
||||
/**
|
||||
* @generated from field: memos.api.v1.VideoMetadata video = 4;
|
||||
*/
|
||||
value: VideoMetadata;
|
||||
case: "video";
|
||||
} | { case: undefined; value?: undefined };
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message memos.api.v1.MediaMetadata.
|
||||
* Use `create(MediaMetadataSchema)` to create a new message.
|
||||
*/
|
||||
export const MediaMetadataSchema: GenMessage<MediaMetadata> = /*@__PURE__*/
|
||||
messageDesc(file_api_v1_attachment_service, 1);
|
||||
|
||||
/**
|
||||
* @generated from message memos.api.v1.PhotoMetadata
|
||||
*/
|
||||
export type PhotoMetadata = Message<"memos.api.v1.PhotoMetadata"> & {
|
||||
/**
|
||||
* Optional. Capture time as recorded by the source media.
|
||||
*
|
||||
* @generated from field: memos.api.v1.MediaCaptureTime capture_time = 1;
|
||||
*/
|
||||
captureTime?: MediaCaptureTime | undefined;
|
||||
|
||||
/**
|
||||
* Optional. Geographic location recorded by the source media.
|
||||
*
|
||||
* @generated from field: memos.api.v1.MediaLocation location = 2;
|
||||
*/
|
||||
location?: MediaLocation | undefined;
|
||||
|
||||
/**
|
||||
* Optional. EXIF orientation value from 1 through 8 as recorded by the source file.
|
||||
* This value is informational and must not be reapplied to the stored attachment;
|
||||
* width and height already describe its display-oriented dimensions.
|
||||
*
|
||||
* @generated from field: optional int32 source_exif_orientation = 3;
|
||||
*/
|
||||
sourceExifOrientation?: number | undefined;
|
||||
|
||||
/**
|
||||
* @generated from field: string camera_make = 4;
|
||||
*/
|
||||
cameraMake: string;
|
||||
|
||||
/**
|
||||
* @generated from field: string camera_model = 5;
|
||||
*/
|
||||
cameraModel: string;
|
||||
|
||||
/**
|
||||
* @generated from field: string lens_model = 6;
|
||||
*/
|
||||
lensModel: string;
|
||||
|
||||
/**
|
||||
* @generated from field: optional double f_number = 7;
|
||||
*/
|
||||
fNumber?: number | undefined;
|
||||
|
||||
/**
|
||||
* @generated from field: optional double exposure_time_seconds = 8;
|
||||
*/
|
||||
exposureTimeSeconds?: number | undefined;
|
||||
|
||||
/**
|
||||
* @generated from field: optional int32 iso = 9;
|
||||
*/
|
||||
iso?: number | undefined;
|
||||
|
||||
/**
|
||||
* @generated from field: optional double focal_length_mm = 10;
|
||||
*/
|
||||
focalLengthMm?: number | undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message memos.api.v1.PhotoMetadata.
|
||||
* Use `create(PhotoMetadataSchema)` to create a new message.
|
||||
*/
|
||||
export const PhotoMetadataSchema: GenMessage<PhotoMetadata> = /*@__PURE__*/
|
||||
messageDesc(file_api_v1_attachment_service, 2);
|
||||
|
||||
/**
|
||||
* @generated from message memos.api.v1.MediaCaptureTime
|
||||
*/
|
||||
export type MediaCaptureTime = Message<"memos.api.v1.MediaCaptureTime"> & {
|
||||
/**
|
||||
* Local date and time without a time zone, formatted as YYYY-MM-DDTHH:mm:ss[.fraction].
|
||||
*
|
||||
* @generated from field: string local_date_time = 1;
|
||||
*/
|
||||
localDateTime: string;
|
||||
|
||||
/**
|
||||
* Optional. UTC offset formatted as Z or +/-HH:MM.
|
||||
*
|
||||
* @generated from field: optional string utc_offset = 2;
|
||||
*/
|
||||
utcOffset?: string | undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message memos.api.v1.MediaCaptureTime.
|
||||
* Use `create(MediaCaptureTimeSchema)` to create a new message.
|
||||
*/
|
||||
export const MediaCaptureTimeSchema: GenMessage<MediaCaptureTime> = /*@__PURE__*/
|
||||
messageDesc(file_api_v1_attachment_service, 3);
|
||||
|
||||
/**
|
||||
* @generated from message memos.api.v1.MediaLocation
|
||||
*/
|
||||
export type MediaLocation = Message<"memos.api.v1.MediaLocation"> & {
|
||||
/**
|
||||
* Optional. WGS84 latitude in decimal degrees. Must be provided with longitude.
|
||||
*
|
||||
* @generated from field: optional double latitude = 1;
|
||||
*/
|
||||
latitude?: number | undefined;
|
||||
|
||||
/**
|
||||
* Optional. WGS84 longitude in decimal degrees. Must be provided with latitude.
|
||||
*
|
||||
* @generated from field: optional double longitude = 2;
|
||||
*/
|
||||
longitude?: number | undefined;
|
||||
|
||||
/**
|
||||
* Optional. Signed altitude in meters relative to sea level.
|
||||
*
|
||||
* @generated from field: optional double altitude_meters = 3;
|
||||
*/
|
||||
altitudeMeters?: number | undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message memos.api.v1.MediaLocation.
|
||||
* Use `create(MediaLocationSchema)` to create a new message.
|
||||
*/
|
||||
export const MediaLocationSchema: GenMessage<MediaLocation> = /*@__PURE__*/
|
||||
messageDesc(file_api_v1_attachment_service, 4);
|
||||
|
||||
/**
|
||||
* @generated from message memos.api.v1.VideoMetadata
|
||||
*/
|
||||
export type VideoMetadata = Message<"memos.api.v1.VideoMetadata"> & {
|
||||
/**
|
||||
* @generated from field: optional double duration_seconds = 1;
|
||||
*/
|
||||
durationSeconds?: number | undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes the message memos.api.v1.VideoMetadata.
|
||||
* Use `create(VideoMetadataSchema)` to create a new message.
|
||||
*/
|
||||
export const VideoMetadataSchema: GenMessage<VideoMetadata> = /*@__PURE__*/
|
||||
messageDesc(file_api_v1_attachment_service, 5);
|
||||
|
||||
/**
|
||||
* @generated from message memos.api.v1.Attachment
|
||||
*/
|
||||
|
|
@ -123,6 +315,13 @@ export type Attachment = Message<"memos.api.v1.Attachment"> & {
|
|||
* @generated from field: memos.api.v1.MotionMedia motion_media = 9;
|
||||
*/
|
||||
motionMedia?: MotionMedia | undefined;
|
||||
|
||||
/**
|
||||
* Optional. Immutable normalized media metadata explicitly supplied by the client at creation time.
|
||||
*
|
||||
* @generated from field: memos.api.v1.MediaMetadata media_metadata = 10;
|
||||
*/
|
||||
mediaMetadata?: MediaMetadata | undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -130,7 +329,7 @@ export type Attachment = Message<"memos.api.v1.Attachment"> & {
|
|||
* Use `create(AttachmentSchema)` to create a new message.
|
||||
*/
|
||||
export const AttachmentSchema: GenMessage<Attachment> = /*@__PURE__*/
|
||||
messageDesc(file_api_v1_attachment_service, 1);
|
||||
messageDesc(file_api_v1_attachment_service, 6);
|
||||
|
||||
/**
|
||||
* @generated from message memos.api.v1.CreateAttachmentRequest
|
||||
|
|
@ -158,7 +357,7 @@ export type CreateAttachmentRequest = Message<"memos.api.v1.CreateAttachmentRequ
|
|||
* Use `create(CreateAttachmentRequestSchema)` to create a new message.
|
||||
*/
|
||||
export const CreateAttachmentRequestSchema: GenMessage<CreateAttachmentRequest> = /*@__PURE__*/
|
||||
messageDesc(file_api_v1_attachment_service, 2);
|
||||
messageDesc(file_api_v1_attachment_service, 7);
|
||||
|
||||
/**
|
||||
* @generated from message memos.api.v1.ListAttachmentsRequest
|
||||
|
|
@ -206,7 +405,7 @@ export type ListAttachmentsRequest = Message<"memos.api.v1.ListAttachmentsReques
|
|||
* Use `create(ListAttachmentsRequestSchema)` to create a new message.
|
||||
*/
|
||||
export const ListAttachmentsRequestSchema: GenMessage<ListAttachmentsRequest> = /*@__PURE__*/
|
||||
messageDesc(file_api_v1_attachment_service, 3);
|
||||
messageDesc(file_api_v1_attachment_service, 8);
|
||||
|
||||
/**
|
||||
* @generated from message memos.api.v1.ListAttachmentsResponse
|
||||
|
|
@ -233,7 +432,7 @@ export type ListAttachmentsResponse = Message<"memos.api.v1.ListAttachmentsRespo
|
|||
* Use `create(ListAttachmentsResponseSchema)` to create a new message.
|
||||
*/
|
||||
export const ListAttachmentsResponseSchema: GenMessage<ListAttachmentsResponse> = /*@__PURE__*/
|
||||
messageDesc(file_api_v1_attachment_service, 4);
|
||||
messageDesc(file_api_v1_attachment_service, 9);
|
||||
|
||||
/**
|
||||
* @generated from message memos.api.v1.GetAttachmentRequest
|
||||
|
|
@ -253,7 +452,7 @@ export type GetAttachmentRequest = Message<"memos.api.v1.GetAttachmentRequest">
|
|||
* Use `create(GetAttachmentRequestSchema)` to create a new message.
|
||||
*/
|
||||
export const GetAttachmentRequestSchema: GenMessage<GetAttachmentRequest> = /*@__PURE__*/
|
||||
messageDesc(file_api_v1_attachment_service, 5);
|
||||
messageDesc(file_api_v1_attachment_service, 10);
|
||||
|
||||
/**
|
||||
* @generated from message memos.api.v1.UpdateAttachmentRequest
|
||||
|
|
@ -279,7 +478,7 @@ export type UpdateAttachmentRequest = Message<"memos.api.v1.UpdateAttachmentRequ
|
|||
* Use `create(UpdateAttachmentRequestSchema)` to create a new message.
|
||||
*/
|
||||
export const UpdateAttachmentRequestSchema: GenMessage<UpdateAttachmentRequest> = /*@__PURE__*/
|
||||
messageDesc(file_api_v1_attachment_service, 6);
|
||||
messageDesc(file_api_v1_attachment_service, 11);
|
||||
|
||||
/**
|
||||
* @generated from message memos.api.v1.DeleteAttachmentRequest
|
||||
|
|
@ -299,7 +498,7 @@ export type DeleteAttachmentRequest = Message<"memos.api.v1.DeleteAttachmentRequ
|
|||
* Use `create(DeleteAttachmentRequestSchema)` to create a new message.
|
||||
*/
|
||||
export const DeleteAttachmentRequestSchema: GenMessage<DeleteAttachmentRequest> = /*@__PURE__*/
|
||||
messageDesc(file_api_v1_attachment_service, 7);
|
||||
messageDesc(file_api_v1_attachment_service, 12);
|
||||
|
||||
/**
|
||||
* @generated from message memos.api.v1.BatchDeleteAttachmentsRequest
|
||||
|
|
@ -316,7 +515,7 @@ export type BatchDeleteAttachmentsRequest = Message<"memos.api.v1.BatchDeleteAtt
|
|||
* Use `create(BatchDeleteAttachmentsRequestSchema)` to create a new message.
|
||||
*/
|
||||
export const BatchDeleteAttachmentsRequestSchema: GenMessage<BatchDeleteAttachmentsRequest> = /*@__PURE__*/
|
||||
messageDesc(file_api_v1_attachment_service, 8);
|
||||
messageDesc(file_api_v1_attachment_service, 13);
|
||||
|
||||
/**
|
||||
* @generated from enum memos.api.v1.MotionMediaFamily
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -14,6 +14,7 @@ import {
|
|||
interface PreviewMediaItemBase {
|
||||
id: string;
|
||||
filename: string;
|
||||
attachments?: Attachment[];
|
||||
}
|
||||
|
||||
export interface ImagePreviewMediaItem extends PreviewMediaItemBase {
|
||||
|
|
@ -131,6 +132,7 @@ function buildSingleAttachmentItem(attachment: Attachment): AttachmentVisualItem
|
|||
sourceUrl,
|
||||
posterUrl,
|
||||
filename: attachment.filename,
|
||||
attachments: [attachment],
|
||||
},
|
||||
mimeType: attachment.type,
|
||||
};
|
||||
|
|
@ -154,6 +156,7 @@ function buildAppleMotionItem(still: Attachment, video: Attachment): AttachmentV
|
|||
posterUrl,
|
||||
motionUrl: sourceUrl,
|
||||
filename: still.filename,
|
||||
attachments: [still, video],
|
||||
},
|
||||
mimeType: still.type,
|
||||
};
|
||||
|
|
@ -175,6 +178,7 @@ function buildAndroidMotionItem(attachment: Attachment): AttachmentVisualItem {
|
|||
posterUrl: getAttachmentThumbnailUrl(attachment),
|
||||
filename: attachment.filename,
|
||||
presentationTimestampUs: attachment.motionMedia?.presentationTimestampUs,
|
||||
attachments: [attachment],
|
||||
},
|
||||
mimeType: attachment.type,
|
||||
};
|
||||
|
|
|
|||
130
web/src/utils/media-metadata.ts
Normal file
130
web/src/utils/media-metadata.ts
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
import { timestampDate } from "@bufbuild/protobuf/wkt";
|
||||
import type { Attachment } from "@/types/proto/api/v1/attachment_service_pb";
|
||||
import { formatFileSize, getFileTypeLabel } from "./format";
|
||||
|
||||
export interface MediaLocationDisplay {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
coordinates: string;
|
||||
altitude?: string;
|
||||
}
|
||||
|
||||
export interface MediaMetadataDisplay {
|
||||
file?: string;
|
||||
dimensions?: string;
|
||||
uploaded?: string;
|
||||
duration?: string;
|
||||
captured?: string;
|
||||
utcOffset?: string;
|
||||
camera?: string;
|
||||
lens?: string;
|
||||
exposure?: string;
|
||||
location?: MediaLocationDisplay;
|
||||
sourceExifOrientation?: number;
|
||||
hasSavedMetadata: boolean;
|
||||
}
|
||||
|
||||
const formatNumber = (value: number, locale: string, maximumFractionDigits = 2) =>
|
||||
new Intl.NumberFormat(locale, { maximumFractionDigits }).format(value);
|
||||
|
||||
const formatCivilDateTime = (value: string, locale: string): string | undefined => {
|
||||
const match = value.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})/);
|
||||
if (!match) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const [, year, month, day, hour, minute, second] = match;
|
||||
const date = new Date(Date.UTC(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute), Number(second)));
|
||||
return new Intl.DateTimeFormat(locale, {
|
||||
year: "numeric",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
timeZone: "UTC",
|
||||
}).format(date);
|
||||
};
|
||||
|
||||
export const formatMediaDuration = (seconds: number): string => {
|
||||
const roundedSeconds = Math.max(0, Math.round(seconds));
|
||||
const hours = Math.floor(roundedSeconds / 3600);
|
||||
const minutes = Math.floor((roundedSeconds % 3600) / 60);
|
||||
const remainingSeconds = roundedSeconds % 60;
|
||||
|
||||
if (hours > 0) {
|
||||
return `${hours}:${String(minutes).padStart(2, "0")}:${String(remainingSeconds).padStart(2, "0")}`;
|
||||
}
|
||||
return `${minutes}:${String(remainingSeconds).padStart(2, "0")}`;
|
||||
};
|
||||
|
||||
export const formatExposureTime = (seconds: number, locale: string): string => {
|
||||
if (seconds > 0 && seconds < 1) {
|
||||
const reciprocal = 1 / seconds;
|
||||
const roundedReciprocal = Math.round(reciprocal);
|
||||
if (roundedReciprocal > 0 && Math.abs(reciprocal - roundedReciprocal) / roundedReciprocal < 0.01) {
|
||||
return `1/${roundedReciprocal} s`;
|
||||
}
|
||||
}
|
||||
return `${formatNumber(seconds, locale, 4)} s`;
|
||||
};
|
||||
|
||||
export const buildMediaMetadataDisplay = (attachments: Attachment[] | undefined, locale: string): MediaMetadataDisplay => {
|
||||
if (!attachments || attachments.length === 0) {
|
||||
return { hasSavedMetadata: false };
|
||||
}
|
||||
|
||||
const photoAttachment = attachments.find((attachment) => attachment.mediaMetadata?.details.case === "photo");
|
||||
const videoAttachment = attachments.find((attachment) => attachment.mediaMetadata?.details.case === "video");
|
||||
const primaryAttachment = photoAttachment ?? videoAttachment ?? attachments[0];
|
||||
const photoMetadata = photoAttachment?.mediaMetadata?.details;
|
||||
const photo = photoMetadata?.case === "photo" ? photoMetadata.value : undefined;
|
||||
const videoMetadata = videoAttachment?.mediaMetadata?.details;
|
||||
const video = videoMetadata?.case === "video" ? videoMetadata.value : undefined;
|
||||
const dimensionsMetadata = attachments.find(
|
||||
(attachment) => attachment.mediaMetadata?.width !== undefined && attachment.mediaMetadata.height !== undefined,
|
||||
)?.mediaMetadata;
|
||||
const totalSize = attachments.reduce((total, attachment) => total + attachment.size, 0n);
|
||||
const fileParts = [getFileTypeLabel(primaryAttachment.type), totalSize > 0n ? formatFileSize(Number(totalSize)) : undefined].filter(
|
||||
Boolean,
|
||||
);
|
||||
const camera = [photo?.cameraMake, photo?.cameraModel].filter(Boolean).join(" ") || undefined;
|
||||
const exposure = [
|
||||
photo?.fNumber !== undefined ? `ƒ/${formatNumber(photo.fNumber, locale)}` : undefined,
|
||||
photo?.exposureTimeSeconds !== undefined ? formatExposureTime(photo.exposureTimeSeconds, locale) : undefined,
|
||||
photo?.iso !== undefined ? `ISO ${photo.iso}` : undefined,
|
||||
photo?.focalLengthMm !== undefined ? `${formatNumber(photo.focalLengthMm, locale)} mm` : undefined,
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" · ");
|
||||
|
||||
const location =
|
||||
photo?.location?.latitude !== undefined && photo.location.longitude !== undefined
|
||||
? {
|
||||
latitude: photo.location.latitude,
|
||||
longitude: photo.location.longitude,
|
||||
coordinates: `${photo.location.latitude.toFixed(5)}°, ${photo.location.longitude.toFixed(5)}°`,
|
||||
altitude: photo.location.altitudeMeters !== undefined ? `${formatNumber(photo.location.altitudeMeters, locale, 1)} m` : undefined,
|
||||
}
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
file: fileParts.join(" · ") || undefined,
|
||||
dimensions:
|
||||
dimensionsMetadata?.width !== undefined && dimensionsMetadata.height !== undefined
|
||||
? `${dimensionsMetadata.width} × ${dimensionsMetadata.height} px`
|
||||
: undefined,
|
||||
uploaded: primaryAttachment.createTime
|
||||
? new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeStyle: "short" }).format(timestampDate(primaryAttachment.createTime))
|
||||
: undefined,
|
||||
duration: video?.durationSeconds !== undefined ? formatMediaDuration(video.durationSeconds) : undefined,
|
||||
captured: photo?.captureTime?.localDateTime ? formatCivilDateTime(photo.captureTime.localDateTime, locale) : undefined,
|
||||
utcOffset: photo?.captureTime?.utcOffset,
|
||||
camera,
|
||||
lens: photo?.lensModel || undefined,
|
||||
exposure: exposure || undefined,
|
||||
location,
|
||||
sourceExifOrientation: photo?.sourceExifOrientation,
|
||||
hasSavedMetadata: attachments.some((attachment) => attachment.mediaMetadata !== undefined),
|
||||
};
|
||||
};
|
||||
|
|
@ -4,7 +4,7 @@ import { MemoryRouter } from "react-router-dom";
|
|||
import { describe, expect, it, vi } from "vitest";
|
||||
import AttachmentMediaGrid from "@/components/AttachmentLibrary/AttachmentMediaGrid";
|
||||
import type { AttachmentLibraryMonthGroup } from "@/hooks/useAttachmentLibrary";
|
||||
import { AttachmentSchema } from "@/types/proto/api/v1/attachment_service_pb";
|
||||
import { AttachmentSchema, MediaMetadataSchema, VideoMetadataSchema } from "@/types/proto/api/v1/attachment_service_pb";
|
||||
|
||||
vi.mock("@/utils/i18n", () => ({ useTranslate: () => (key: string) => key }));
|
||||
|
||||
|
|
@ -62,4 +62,56 @@ describe("<AttachmentMediaGrid>", () => {
|
|||
fireEvent.click(memoLink);
|
||||
expect(onPreview).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps video duration inside the existing play badge", () => {
|
||||
const attachment = create(AttachmentSchema, {
|
||||
name: "attachments/video",
|
||||
filename: "clip.mp4",
|
||||
type: "video/mp4",
|
||||
memo: "memos/source-memo",
|
||||
mediaMetadata: create(MediaMetadataSchema, {
|
||||
details: {
|
||||
case: "video",
|
||||
value: create(VideoMetadataSchema, { durationSeconds: 12.5 }),
|
||||
},
|
||||
}),
|
||||
});
|
||||
const groups: AttachmentLibraryMonthGroup[] = [
|
||||
{
|
||||
key: "2026-07",
|
||||
label: "Jul 2026",
|
||||
items: [
|
||||
{
|
||||
id: attachment.name,
|
||||
kind: "video",
|
||||
filename: attachment.filename,
|
||||
posterUrl: "/poster.jpg",
|
||||
sourceUrl: "/clip.mp4",
|
||||
attachmentNames: [attachment.name],
|
||||
attachments: [attachment],
|
||||
previewItem: {
|
||||
id: attachment.name,
|
||||
kind: "video",
|
||||
filename: attachment.filename,
|
||||
sourceUrl: "/clip.mp4",
|
||||
attachments: [attachment],
|
||||
},
|
||||
mimeType: attachment.type,
|
||||
primaryAttachment: attachment,
|
||||
createdLabel: "Jul 29, 2026",
|
||||
fileTypeLabel: "MP4",
|
||||
memoName: attachment.memo,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<AttachmentMediaGrid groups={groups} onPreview={vi.fn()} />
|
||||
</MemoryRouter>,
|
||||
);
|
||||
|
||||
expect(screen.getByText("0:13")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ vi.mock("@/utils/i18n", async (importOriginal) => ({
|
|||
useTranslate: () => (key: string) => key,
|
||||
}));
|
||||
vi.mock("@/hooks/useCurrentUser", () => ({ default: () => undefined }));
|
||||
vi.mock("@/contexts/AuthContext", () => ({ useAuth: () => ({ userGeneralSetting: undefined }) }));
|
||||
vi.mock("@/components/map/useReverseGeocoding", () => ({ useReverseGeocoding: () => ({ data: undefined }) }));
|
||||
|
||||
beforeAll(() => {
|
||||
|
|
|
|||
19
web/tests/media-item-preview-metadata.test.ts
Normal file
19
web/tests/media-item-preview-metadata.test.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { create } from "@bufbuild/protobuf";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { AttachmentSchema, MediaMetadataSchema } from "@/types/proto/api/v1/attachment_service_pb";
|
||||
import { buildAttachmentVisualItems } from "@/utils/media-item";
|
||||
|
||||
describe("media preview metadata plumbing", () => {
|
||||
it("keeps the source attachment on preview items", () => {
|
||||
const attachment = create(AttachmentSchema, {
|
||||
name: "attachments/photo",
|
||||
filename: "photo.jpg",
|
||||
type: "image/jpeg",
|
||||
mediaMetadata: create(MediaMetadataSchema, { width: 1200, height: 800 }),
|
||||
});
|
||||
|
||||
const [item] = buildAttachmentVisualItems([attachment]);
|
||||
|
||||
expect(item.previewItem.attachments).toEqual([attachment]);
|
||||
});
|
||||
});
|
||||
35
web/tests/media-metadata-display.test.ts
Normal file
35
web/tests/media-metadata-display.test.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { create } from "@bufbuild/protobuf";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { AttachmentSchema, MediaMetadataSchema, VideoMetadataSchema } from "@/types/proto/api/v1/attachment_service_pb";
|
||||
import { buildMediaMetadataDisplay, formatExposureTime, formatMediaDuration } from "@/utils/media-metadata";
|
||||
|
||||
describe("media metadata display formatting", () => {
|
||||
it("uses conventional media duration and shutter-speed notation", () => {
|
||||
expect(formatMediaDuration(65.4)).toBe("1:05");
|
||||
expect(formatMediaDuration(3661)).toBe("1:01:01");
|
||||
expect(formatExposureTime(1 / 120, "en")).toBe("1/120 s");
|
||||
});
|
||||
|
||||
it("formats video metadata without requiring photo details", () => {
|
||||
const attachment = create(AttachmentSchema, {
|
||||
filename: "clip.mp4",
|
||||
type: "video/mp4",
|
||||
size: 1_048_576n,
|
||||
mediaMetadata: create(MediaMetadataSchema, {
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
details: {
|
||||
case: "video",
|
||||
value: create(VideoMetadataSchema, { durationSeconds: 12.5 }),
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
expect(buildMediaMetadataDisplay([attachment], "en")).toMatchObject({
|
||||
file: "MP4 · 1.0 MB",
|
||||
dimensions: "1920 × 1080 px",
|
||||
duration: "0:13",
|
||||
hasSavedMetadata: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
141
web/tests/media-metadata-exif-fixture.test.ts
Normal file
141
web/tests/media-metadata-exif-fixture.test.ts
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { mediaMetadataService } from "@/components/MemoEditor/services/mediaMetadataService";
|
||||
|
||||
describe("mediaMetadataService EXIF fixture", () => {
|
||||
beforeEach(() => {
|
||||
vi.stubGlobal(
|
||||
"createImageBitmap",
|
||||
vi.fn(async () => ({ width: 2, height: 1, close: vi.fn() })),
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it("maps selected fields from a real JPEG EXIF payload", async () => {
|
||||
const metadata = await mediaMetadataService.extract(buildExifJpegFixture());
|
||||
|
||||
expect(metadata?.width).toBe(3000);
|
||||
expect(metadata?.height).toBe(4000);
|
||||
expect(metadata?.details.case).toBe("photo");
|
||||
if (metadata?.details.case !== "photo") throw new Error("expected photo metadata");
|
||||
|
||||
expect(metadata.details.value.captureTime).toMatchObject({
|
||||
localDateTime: "2026-08-10T14:32:18.123",
|
||||
utcOffset: "+08:00",
|
||||
});
|
||||
expect(metadata.details.value.location).toMatchObject({
|
||||
latitude: 1.3521,
|
||||
longitude: 103.8198,
|
||||
altitudeMeters: 18.4,
|
||||
});
|
||||
expect(metadata.details.value).toMatchObject({
|
||||
sourceExifOrientation: 6,
|
||||
cameraMake: "Apple",
|
||||
cameraModel: "iPhone",
|
||||
lensModel: "Main Camera",
|
||||
fNumber: 1.78,
|
||||
exposureTimeSeconds: 1 / 120,
|
||||
iso: 64,
|
||||
focalLengthMm: 6.86,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// A minimal JPEG containing a little-endian TIFF EXIF segment with known values.
|
||||
function buildExifJpegFixture(): File {
|
||||
const tiff = new Uint8Array(424);
|
||||
const view = new DataView(tiff.buffer);
|
||||
const littleEndian = true;
|
||||
|
||||
tiff.set([0x49, 0x49], 0);
|
||||
view.setUint16(2, 42, littleEndian);
|
||||
view.setUint32(4, 8, littleEndian);
|
||||
|
||||
const writeEntry = (position: number, tag: number, type: number, count: number, value: number) => {
|
||||
view.setUint16(position, tag, littleEndian);
|
||||
view.setUint16(position + 2, type, littleEndian);
|
||||
view.setUint32(position + 4, count, littleEndian);
|
||||
view.setUint32(position + 8, value, littleEndian);
|
||||
};
|
||||
const writeShortEntry = (position: number, tag: number, value: number) => {
|
||||
writeEntry(position, tag, 3, 1, 0);
|
||||
view.setUint16(position + 8, value, littleEndian);
|
||||
};
|
||||
const writeByteEntry = (position: number, tag: number, value: number) => {
|
||||
writeEntry(position, tag, 1, 1, 0);
|
||||
view.setUint8(position + 8, value);
|
||||
};
|
||||
const writeInlineASCIIEntry = (position: number, tag: number, value: string) => {
|
||||
const bytes = new TextEncoder().encode(`${value}\0`);
|
||||
writeEntry(position, tag, 2, bytes.length, 0);
|
||||
tiff.set(bytes, position + 8);
|
||||
};
|
||||
const writeASCII = (offset: number, value: string) => {
|
||||
tiff.set(new TextEncoder().encode(`${value}\0`), offset);
|
||||
};
|
||||
const writeRational = (offset: number, numerator: number, denominator: number) => {
|
||||
view.setUint32(offset, numerator, littleEndian);
|
||||
view.setUint32(offset + 4, denominator, littleEndian);
|
||||
};
|
||||
|
||||
// IFD0: camera identity, orientation, and pointers to the EXIF/GPS IFDs.
|
||||
view.setUint16(8, 5, littleEndian);
|
||||
writeEntry(10, 0x010f, 2, 6, 74);
|
||||
writeEntry(22, 0x0110, 2, 7, 80);
|
||||
writeShortEntry(34, 0x0112, 6);
|
||||
writeEntry(46, 0x8769, 4, 1, 88);
|
||||
writeEntry(58, 0x8825, 4, 1, 278);
|
||||
view.setUint32(70, 0, littleEndian);
|
||||
writeASCII(74, "Apple");
|
||||
writeASCII(80, "iPhone");
|
||||
|
||||
// EXIF IFD: dimensions, capture time, and exposure details.
|
||||
view.setUint16(88, 10, littleEndian);
|
||||
writeEntry(90, 0x829a, 5, 1, 250);
|
||||
writeEntry(102, 0x829d, 5, 1, 242);
|
||||
writeShortEntry(114, 0x8827, 64);
|
||||
writeEntry(126, 0x9003, 2, 20, 214);
|
||||
writeEntry(138, 0x9011, 2, 7, 234);
|
||||
writeEntry(150, 0x920a, 5, 1, 258);
|
||||
writeInlineASCIIEntry(162, 0x9291, "123");
|
||||
writeEntry(174, 0xa002, 4, 1, 4000);
|
||||
writeEntry(186, 0xa003, 4, 1, 3000);
|
||||
writeEntry(198, 0xa434, 2, 12, 266);
|
||||
view.setUint32(210, 0, littleEndian);
|
||||
writeASCII(214, "2026:08:10 14:32:18");
|
||||
writeASCII(234, "+08:00");
|
||||
writeRational(242, 178, 100);
|
||||
writeRational(250, 1, 120);
|
||||
writeRational(258, 686, 100);
|
||||
writeASCII(266, "Main Camera");
|
||||
|
||||
// GPS IFD: Singapore coordinates and altitude.
|
||||
view.setUint16(278, 7, littleEndian);
|
||||
writeEntry(280, 0x0000, 1, 4, 0x00000302);
|
||||
writeInlineASCIIEntry(292, 0x0001, "N");
|
||||
writeEntry(304, 0x0002, 5, 3, 368);
|
||||
writeInlineASCIIEntry(316, 0x0003, "E");
|
||||
writeEntry(328, 0x0004, 5, 3, 392);
|
||||
writeByteEntry(340, 0x0005, 0);
|
||||
writeEntry(352, 0x0006, 5, 1, 416);
|
||||
view.setUint32(364, 0, littleEndian);
|
||||
writeRational(368, 1, 1);
|
||||
writeRational(376, 21, 1);
|
||||
writeRational(384, 756, 100);
|
||||
writeRational(392, 103, 1);
|
||||
writeRational(400, 49, 1);
|
||||
writeRational(408, 1128, 100);
|
||||
writeRational(416, 184, 10);
|
||||
|
||||
const exifPayload = new Uint8Array(6 + tiff.length);
|
||||
exifPayload.set(new TextEncoder().encode("Exif\0\0"));
|
||||
exifPayload.set(tiff, 6);
|
||||
const jpeg = new Uint8Array(2 + 2 + 2 + exifPayload.length + 2);
|
||||
jpeg.set([0xff, 0xd8, 0xff, 0xe1], 0);
|
||||
new DataView(jpeg.buffer).setUint16(4, exifPayload.length + 2);
|
||||
jpeg.set(exifPayload, 6);
|
||||
jpeg.set([0xff, 0xd9], jpeg.length - 2);
|
||||
return new File([jpeg], "known-exif.jpg", { type: "image/jpeg" });
|
||||
}
|
||||
162
web/tests/media-metadata-service.test.ts
Normal file
162
web/tests/media-metadata-service.test.ts
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
parseExif: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("exifr", () => ({
|
||||
parse: mocks.parseExif,
|
||||
}));
|
||||
|
||||
import { mediaMetadataService } from "@/components/MemoEditor/services/mediaMetadataService";
|
||||
|
||||
describe("mediaMetadataService", () => {
|
||||
beforeEach(() => {
|
||||
Object.defineProperty(URL, "createObjectURL", {
|
||||
configurable: true,
|
||||
value: vi.fn(() => "blob:test-media"),
|
||||
});
|
||||
Object.defineProperty(URL, "revokeObjectURL", {
|
||||
configurable: true,
|
||||
value: vi.fn(),
|
||||
});
|
||||
vi.stubGlobal(
|
||||
"createImageBitmap",
|
||||
vi.fn(async () => ({ width: 640, height: 480, close: vi.fn() })),
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it("normalizes selected EXIF fields without inventing a timezone", async () => {
|
||||
mocks.parseExif.mockResolvedValue({
|
||||
Make: " Apple\0 ",
|
||||
Model: "iPhone",
|
||||
LensModel: "Main Camera",
|
||||
Orientation: 6,
|
||||
ExifImageWidth: 4000,
|
||||
ExifImageHeight: 3000,
|
||||
DateTimeOriginal: "2026:08:10 14:32:18",
|
||||
SubSecTimeOriginal: "123",
|
||||
latitude: 1.3521,
|
||||
longitude: 103.8198,
|
||||
GPSAltitude: 18.4,
|
||||
GPSAltitudeRef: 0,
|
||||
FNumber: 1.78,
|
||||
ExposureTime: 1 / 120,
|
||||
ISO: 64,
|
||||
FocalLength: 6.86,
|
||||
});
|
||||
|
||||
const metadata = await mediaMetadataService.extract(new File([new Uint8Array([1, 2, 3])], "photo.jpg", { type: "image/jpeg" }));
|
||||
|
||||
expect(metadata?.width).toBe(3000);
|
||||
expect(metadata?.height).toBe(4000);
|
||||
expect(metadata?.details.case).toBe("photo");
|
||||
if (metadata?.details.case !== "photo") throw new Error("expected photo metadata");
|
||||
expect(metadata.details.value.captureTime?.localDateTime).toBe("2026-08-10T14:32:18.123");
|
||||
expect(metadata.details.value.captureTime?.utcOffset).toBeUndefined();
|
||||
expect(metadata.details.value.location).toMatchObject({ latitude: 1.3521, longitude: 103.8198, altitudeMeters: 18.4 });
|
||||
expect(metadata.details.value).toMatchObject({
|
||||
sourceExifOrientation: 6,
|
||||
cameraMake: "Apple",
|
||||
cameraModel: "iPhone",
|
||||
lensModel: "Main Camera",
|
||||
fNumber: 1.78,
|
||||
exposureTimeSeconds: 1 / 120,
|
||||
iso: 64,
|
||||
focalLengthMm: 6.86,
|
||||
});
|
||||
});
|
||||
|
||||
it("preserves a valid EXIF UTC offset", async () => {
|
||||
mocks.parseExif.mockResolvedValue({
|
||||
DateTimeOriginal: "2026:08:10 14:32:18\0 ",
|
||||
OffsetTimeOriginal: "+08:00\0",
|
||||
});
|
||||
|
||||
const metadata = await mediaMetadataService.extract(new File([new Uint8Array([1])], "photo.jpg", { type: "image/jpeg" }));
|
||||
|
||||
expect(metadata?.details.case).toBe("photo");
|
||||
if (metadata?.details.case !== "photo") throw new Error("expected photo metadata");
|
||||
expect(metadata.details.value.captureTime?.utcOffset).toBe("+08:00");
|
||||
});
|
||||
|
||||
it("drops incomplete raw GPS coordinates instead of guessing their direction", async () => {
|
||||
mocks.parseExif.mockResolvedValue({
|
||||
GPSLatitude: [1, 21, 7.56],
|
||||
GPSLongitude: [103, 49, 11.28],
|
||||
GPSLongitudeRef: "E",
|
||||
});
|
||||
|
||||
const metadata = await mediaMetadataService.extract(new File([new Uint8Array([1])], "photo.jpg", { type: "image/jpeg" }));
|
||||
|
||||
expect(metadata?.details.case).toBeUndefined();
|
||||
expect(metadata?.width).toBe(640);
|
||||
expect(metadata?.height).toBe(480);
|
||||
});
|
||||
|
||||
it("falls back to browser dimensions when EXIF parsing fails", async () => {
|
||||
mocks.parseExif.mockRejectedValue(new Error("unsupported image"));
|
||||
|
||||
const metadata = await mediaMetadataService.extract(new File([new Uint8Array([1])], "photo.webp", { type: "image/webp" }));
|
||||
|
||||
expect(metadata?.width).toBe(640);
|
||||
expect(metadata?.height).toBe(480);
|
||||
expect(metadata?.details.case).toBeUndefined();
|
||||
});
|
||||
|
||||
it("reads video dimensions and duration and revokes the object URL", async () => {
|
||||
const createElement = document.createElement.bind(document);
|
||||
vi.spyOn(document, "createElement").mockImplementation((tagName: string, options?: ElementCreationOptions) => {
|
||||
const element = createElement(tagName, options);
|
||||
if (tagName.toLowerCase() !== "video") return element;
|
||||
Object.defineProperties(element, {
|
||||
videoWidth: { configurable: true, value: 1920 },
|
||||
videoHeight: { configurable: true, value: 1080 },
|
||||
duration: { configurable: true, value: 12.5 },
|
||||
});
|
||||
vi.spyOn(element as HTMLVideoElement, "load").mockImplementation(() => {
|
||||
queueMicrotask(() => element.dispatchEvent(new Event("loadedmetadata")));
|
||||
});
|
||||
return element;
|
||||
});
|
||||
|
||||
const metadata = await mediaMetadataService.extract(new File([new Uint8Array([1])], "clip.mp4", { type: "video/mp4" }));
|
||||
|
||||
expect(metadata?.width).toBe(1920);
|
||||
expect(metadata?.height).toBe(1080);
|
||||
expect(metadata?.details.case).toBe("video");
|
||||
if (metadata?.details.case !== "video") throw new Error("expected video metadata");
|
||||
expect(metadata.details.value.durationSeconds).toBe(12.5);
|
||||
expect(URL.revokeObjectURL).toHaveBeenCalledWith("blob:test-media");
|
||||
});
|
||||
|
||||
it("times out video extraction, revokes the object URL, and returns no metadata", async () => {
|
||||
vi.useFakeTimers();
|
||||
const createElement = document.createElement.bind(document);
|
||||
vi.spyOn(document, "createElement").mockImplementation((tagName: string, options?: ElementCreationOptions) => {
|
||||
const element = createElement(tagName, options);
|
||||
if (tagName.toLowerCase() === "video") {
|
||||
vi.spyOn(element as HTMLVideoElement, "load").mockImplementation(() => undefined);
|
||||
}
|
||||
return element;
|
||||
});
|
||||
|
||||
const extraction = mediaMetadataService.extract(new File([new Uint8Array([1])], "clip.mp4", { type: "video/mp4" }));
|
||||
await vi.advanceTimersByTimeAsync(5_000);
|
||||
|
||||
await expect(extraction).resolves.toBeUndefined();
|
||||
expect(URL.revokeObjectURL).toHaveBeenCalledWith("blob:test-media");
|
||||
});
|
||||
|
||||
it("ignores non-media files", async () => {
|
||||
const metadata = await mediaMetadataService.extract(new File(["hello"], "notes.txt", { type: "text/plain" }));
|
||||
|
||||
expect(metadata).toBeUndefined();
|
||||
expect(mocks.parseExif).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
55
web/tests/preferences-media-metadata.test.tsx
Normal file
55
web/tests/preferences-media-metadata.test.tsx
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
mutate: vi.fn(),
|
||||
refetchSettings: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("@/contexts/AuthContext", () => ({
|
||||
useAuth: () => ({
|
||||
currentUser: { name: "users/alice" },
|
||||
userGeneralSetting: {
|
||||
locale: "en",
|
||||
memoVisibility: "PRIVATE",
|
||||
theme: "system",
|
||||
saveMediaMetadata: false,
|
||||
},
|
||||
refetchSettings: mocks.refetchSettings,
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("@/hooks/useUserQueries", () => ({
|
||||
useUpdateUserGeneralSetting: () => ({ mutate: mocks.mutate, isPending: false }),
|
||||
}));
|
||||
|
||||
vi.mock("@/utils/i18n", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import("@/utils/i18n")>()),
|
||||
loadLocale: vi.fn(),
|
||||
useTranslate: () => (key: string) => key,
|
||||
}));
|
||||
|
||||
vi.mock("@/utils/theme", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import("@/utils/theme")>()),
|
||||
loadTheme: vi.fn(),
|
||||
}));
|
||||
|
||||
import PreferencesSection from "@/components/Settings/PreferencesSection";
|
||||
|
||||
describe("PreferencesSection media metadata setting", () => {
|
||||
beforeEach(() => {
|
||||
mocks.mutate.mockReset();
|
||||
});
|
||||
|
||||
it("updates the account setting with the save_media_metadata field mask", () => {
|
||||
render(<PreferencesSection />);
|
||||
|
||||
fireEvent.click(screen.getByRole("switch", { name: "setting.preference.save-media-metadata" }));
|
||||
|
||||
expect(mocks.mutate).toHaveBeenCalledOnce();
|
||||
expect(mocks.mutate.mock.calls[0][0]).toEqual({
|
||||
generalSetting: { saveMediaMetadata: true },
|
||||
updateMask: ["save_media_metadata"],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,12 +1,78 @@
|
|||
import { create } from "@bufbuild/protobuf";
|
||||
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import PreviewImageDialog from "@/components/PreviewImageDialog";
|
||||
import {
|
||||
AttachmentSchema,
|
||||
MediaCaptureTimeSchema,
|
||||
MediaLocationSchema,
|
||||
MediaMetadataSchema,
|
||||
PhotoMetadataSchema,
|
||||
} from "@/types/proto/api/v1/attachment_service_pb";
|
||||
|
||||
vi.mock("@/hooks/useMediaQuery", () => ({
|
||||
__esModule: true,
|
||||
default: () => false,
|
||||
}));
|
||||
|
||||
vi.mock("@/components/map/LazyLocationPicker", () => ({
|
||||
LazyLocationPicker: () => <div data-testid="attachment-location-map" />,
|
||||
}));
|
||||
|
||||
const labels: Record<string, string> = {
|
||||
"attachment-details.actions.hide": "Hide attachment details",
|
||||
"attachment-details.actions.hide-map": "Hide map",
|
||||
"attachment-details.actions.show": "Show attachment details",
|
||||
"attachment-details.actions.show-map": "Show map",
|
||||
"attachment-details.empty": "No saved capture metadata.",
|
||||
"attachment-details.fields.altitude": "Altitude",
|
||||
"attachment-details.fields.camera": "Camera",
|
||||
"attachment-details.fields.captured": "Captured",
|
||||
"attachment-details.fields.dimensions": "Dimensions",
|
||||
"attachment-details.fields.exposure": "Exposure",
|
||||
"attachment-details.fields.file": "File",
|
||||
"attachment-details.fields.lens": "Lens",
|
||||
"attachment-details.fields.location": "Coordinates",
|
||||
"attachment-details.sections.camera": "Camera",
|
||||
"attachment-details.sections.capture": "Capture",
|
||||
"attachment-details.sections.file": "File",
|
||||
"attachment-details.sections.location": "Location",
|
||||
"attachment-details.timezone-unknown": "Time zone unknown",
|
||||
"attachment-details.title": "Details",
|
||||
};
|
||||
|
||||
vi.mock("@/utils/i18n", () => ({
|
||||
findNearestMatchedLanguage: (language: string) => language || "en",
|
||||
useTranslate: () => (key: string) => labels[key] ?? key,
|
||||
}));
|
||||
|
||||
const buildAttachmentWithPhotoMetadata = () =>
|
||||
create(AttachmentSchema, {
|
||||
name: "attachments/photo-1",
|
||||
filename: "photo.jpg",
|
||||
type: "image/jpeg",
|
||||
size: 4_200_000n,
|
||||
mediaMetadata: create(MediaMetadataSchema, {
|
||||
width: 4032,
|
||||
height: 3024,
|
||||
details: {
|
||||
case: "photo",
|
||||
value: create(PhotoMetadataSchema, {
|
||||
captureTime: create(MediaCaptureTimeSchema, { localDateTime: "2026-08-10T14:32:18" }),
|
||||
location: create(MediaLocationSchema, { latitude: 1.3521, longitude: 103.8198, altitudeMeters: 18.4 }),
|
||||
sourceExifOrientation: 6,
|
||||
cameraMake: "Apple",
|
||||
cameraModel: "iPhone",
|
||||
lensModel: "Main Camera",
|
||||
fNumber: 1.78,
|
||||
exposureTimeSeconds: 1 / 120,
|
||||
iso: 64,
|
||||
focalLengthMm: 6.86,
|
||||
}),
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
describe("<PreviewImageDialog>", () => {
|
||||
it("provides a dialog description without accessibility warnings", async () => {
|
||||
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});
|
||||
|
|
@ -115,4 +181,77 @@ describe("<PreviewImageDialog>", () => {
|
|||
expect(screen.getByRole("button", { name: /previous item/i })).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: /next item/i })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows saved media details on demand with grouped, lean facts", () => {
|
||||
const attachment = buildAttachmentWithPhotoMetadata();
|
||||
render(
|
||||
<PreviewImageDialog
|
||||
open
|
||||
onOpenChange={vi.fn()}
|
||||
items={[
|
||||
{
|
||||
id: attachment.name,
|
||||
kind: "image",
|
||||
sourceUrl: "/image.jpg",
|
||||
posterUrl: "/image.jpg",
|
||||
filename: attachment.filename,
|
||||
attachments: [attachment],
|
||||
},
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(screen.queryByText("4032 × 3024 px")).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Show attachment details" }));
|
||||
|
||||
expect(screen.getByText("4032 × 3024 px")).toBeInTheDocument();
|
||||
expect(screen.getByText("Apple iPhone")).toBeInTheDocument();
|
||||
expect(screen.getByText("ƒ/1.78 · 1/120 s · ISO 64 · 6.86 mm")).toBeInTheDocument();
|
||||
expect(screen.getByText("1.35210°, 103.81980°")).toBeInTheDocument();
|
||||
expect(screen.getByText("Time zone unknown")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("loads the attachment map only after an explicit action", () => {
|
||||
const attachment = buildAttachmentWithPhotoMetadata();
|
||||
render(
|
||||
<PreviewImageDialog
|
||||
open
|
||||
onOpenChange={vi.fn()}
|
||||
items={[
|
||||
{
|
||||
id: attachment.name,
|
||||
kind: "image",
|
||||
sourceUrl: "/image.jpg",
|
||||
filename: attachment.filename,
|
||||
attachments: [attachment],
|
||||
},
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Show attachment details" }));
|
||||
expect(screen.queryByTestId("attachment-location-map")).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Show map" }));
|
||||
expect(screen.getByTestId("attachment-location-map")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("closes details before closing the media dialog with Escape", async () => {
|
||||
const onOpenChange = vi.fn();
|
||||
render(
|
||||
<PreviewImageDialog
|
||||
open
|
||||
onOpenChange={onOpenChange}
|
||||
items={[{ id: "image-1", kind: "image", sourceUrl: "/image.jpg", filename: "image.jpg" }]}
|
||||
/>,
|
||||
);
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "Show attachment details" }));
|
||||
fireEvent.keyDown(document, { key: "Escape" });
|
||||
|
||||
await waitFor(() => expect(screen.queryByLabelText("Details")).not.toBeInTheDocument());
|
||||
expect(onOpenChange).not.toHaveBeenCalled();
|
||||
|
||||
fireEvent.keyDown(document, { key: "Escape" });
|
||||
await waitFor(() => expect(onOpenChange).toHaveBeenCalledWith(false));
|
||||
});
|
||||
});
|
||||
|
|
|
|||
95
web/tests/upload-media-metadata.test.ts
Normal file
95
web/tests/upload-media-metadata.test.ts
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
import { create } from "@bufbuild/protobuf";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { LocalFile } from "@/components/MemoEditor/types/attachment";
|
||||
import { MediaMetadataSchema } from "@/types/proto/api/v1/attachment_service_pb";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
createAttachment: vi.fn(),
|
||||
extractMetadata: vi.fn(),
|
||||
}));
|
||||
|
||||
// The ingest helper lives beside useFileUpload, whose module graph reaches
|
||||
// AuthContext and the query hooks; stub every client they name-import.
|
||||
vi.mock("@/connect", () => ({
|
||||
attachmentServiceClient: { createAttachment: mocks.createAttachment },
|
||||
authServiceClient: {},
|
||||
userServiceClient: {},
|
||||
memoViewServiceClient: {},
|
||||
refreshAccessToken: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("@/components/MemoEditor/services/mediaMetadataService", () => ({
|
||||
mediaMetadataService: { extract: mocks.extractMetadata },
|
||||
}));
|
||||
|
||||
import { toLocalFiles } from "@/components/MemoEditor/hooks/useFileUpload";
|
||||
import { uploadService } from "@/components/MemoEditor/services/uploadService";
|
||||
|
||||
const createBlobUrl = (file: File) => `blob:${file.name}`;
|
||||
|
||||
const localImage = (mediaMetadata?: LocalFile["mediaMetadata"]): LocalFile => ({
|
||||
file: new File(["image"], "photo.png", { type: "image/png" }),
|
||||
previewUrl: "blob:photo",
|
||||
origin: "upload",
|
||||
mediaMetadata,
|
||||
});
|
||||
|
||||
describe("media metadata at file ingest", () => {
|
||||
it("does not extract metadata when the setting is disabled", () => {
|
||||
const file = new File(["image"], "photo.png", { type: "image/png" });
|
||||
|
||||
const [localFile] = toLocalFiles([file], { createBlobUrl, saveMediaMetadata: false });
|
||||
|
||||
expect(mocks.extractMetadata).not.toHaveBeenCalled();
|
||||
expect(localFile.mediaMetadata).toBeUndefined();
|
||||
});
|
||||
|
||||
it("starts extraction per file when the setting is enabled", async () => {
|
||||
const metadata = create(MediaMetadataSchema, { width: 1200, height: 800 });
|
||||
mocks.extractMetadata.mockResolvedValue(metadata);
|
||||
const file = new File(["image"], "photo.png", { type: "image/png" });
|
||||
|
||||
const [localFile] = toLocalFiles([file], { createBlobUrl, saveMediaMetadata: true });
|
||||
|
||||
expect(mocks.extractMetadata).toHaveBeenCalledWith(file);
|
||||
await expect(localFile.mediaMetadata).resolves.toEqual(metadata);
|
||||
});
|
||||
});
|
||||
|
||||
describe("uploadService media metadata", () => {
|
||||
beforeEach(() => {
|
||||
mocks.createAttachment.mockImplementation(async ({ attachment }) => attachment);
|
||||
});
|
||||
|
||||
it("submits no metadata for files ingested without any", async () => {
|
||||
await uploadService.uploadFiles([localImage()]);
|
||||
|
||||
expect(mocks.createAttachment).toHaveBeenCalledOnce();
|
||||
expect(mocks.createAttachment.mock.calls[0][0].attachment.mediaMetadata).toBeUndefined();
|
||||
});
|
||||
|
||||
it("submits the metadata extracted at ingest", async () => {
|
||||
const metadata = create(MediaMetadataSchema, { width: 1200, height: 800 });
|
||||
|
||||
await uploadService.uploadFiles([localImage(Promise.resolve(metadata))]);
|
||||
|
||||
expect(mocks.createAttachment.mock.calls[0][0].attachment.mediaMetadata).toEqual(metadata);
|
||||
});
|
||||
|
||||
it("continues without metadata when extraction produced no usable values", async () => {
|
||||
await uploadService.uploadFiles([localImage(Promise.resolve(undefined))]);
|
||||
|
||||
expect(mocks.createAttachment).toHaveBeenCalledOnce();
|
||||
expect(mocks.createAttachment.mock.calls[0][0].attachment.mediaMetadata).toBeUndefined();
|
||||
});
|
||||
|
||||
it("submits ingest-time metadata end to end", async () => {
|
||||
const metadata = create(MediaMetadataSchema, { width: 640, height: 480 });
|
||||
mocks.extractMetadata.mockResolvedValue(metadata);
|
||||
const file = new File(["image"], "photo.png", { type: "image/png" });
|
||||
|
||||
await uploadService.uploadFiles(toLocalFiles([file], { createBlobUrl, saveMediaMetadata: true }));
|
||||
|
||||
expect(mocks.createAttachment.mock.calls[0][0].attachment.mediaMetadata).toEqual(metadata);
|
||||
});
|
||||
});
|
||||
|
|
@ -66,6 +66,19 @@ describe("useInlineImageUpload", () => {
|
|||
);
|
||||
});
|
||||
|
||||
test("passes the ingested local file, with its media metadata, straight to uploads", async () => {
|
||||
const upload = vi.spyOn(uploadService, "uploadFile").mockResolvedValue(remoteImage("first", "first.png"));
|
||||
const { controller } = makeController();
|
||||
const editorRef = { current: controller } as RefObject<EditorController>;
|
||||
const { result } = renderHook(() => useInlineImageUpload(editorRef), { wrapper });
|
||||
const localFile: LocalFile = { ...localImage("first.png"), mediaMetadata: Promise.resolve(undefined) };
|
||||
|
||||
act(() => result.current.insertLocalImages([localFile]));
|
||||
|
||||
await waitFor(() => expect(upload).toHaveBeenCalledTimes(1));
|
||||
expect(upload).toHaveBeenCalledWith(localFile);
|
||||
});
|
||||
|
||||
test("retries only failed files and preserves their original placement", async () => {
|
||||
const first = remoteImage("first", "first.png");
|
||||
const second = remoteImage("second", "second.png");
|
||||
|
|
|
|||
Loading…
Reference in a new issue