Internal grpc apis

This commit is contained in:
2025-01-24 00:54:16 +08:00
parent 1a9e670d3d
commit 143afdb885
4 changed files with 189 additions and 3 deletions

View File

@ -3,6 +3,8 @@ package models
import (
"context"
"fmt"
"git.solsynth.dev/hypernet/paperclip/pkg/proto"
"strconv"
"time"
"git.solsynth.dev/hypernet/nexus/pkg/nex/cruda"
@ -77,6 +79,23 @@ type Attachment struct {
IsMature bool `json:"is_mature" gorm:"-"`
}
func (v *Attachment) ToAttachmentInfo() *proto.AttachmentInfo {
if v == nil {
return nil
}
return &proto.AttachmentInfo{
Id: v.Uuid,
Rid: v.Rid,
Name: v.Name,
Type: v.MimeType,
Size: strconv.FormatInt(v.Size, 10),
Hash: v.HashCode,
Mime: v.MimeType,
IsIndexable: v.IsIndexable,
}
}
func (v *Attachment) AfterUpdate(tx *gorm.DB) error {
cacheManager := cache.New[any](localCache.S)
marshal := marshaler.New(cacheManager)