Interactive/pkg/services/attachments.go

30 lines
770 B
Go
Raw Normal View History

2024-02-04 10:40:20 +00:00
package services
import (
"context"
"git.solsynth.dev/hydrogen/interactive/pkg/grpc"
pcpb "git.solsynth.dev/hydrogen/paperclip/pkg/grpc/proto"
"github.com/samber/lo"
2024-02-04 10:40:20 +00:00
)
func GetAttachmentByID(id uint) (*pcpb.Attachment, error) {
return grpc.Attachments.GetAttachment(context.Background(), &pcpb.AttachmentLookupRequest{
Id: lo.ToPtr(uint64(id)),
})
2024-02-04 10:40:20 +00:00
}
2024-03-24 10:31:36 +00:00
func GetAttachmentByUUID(uuid string) (*pcpb.Attachment, error) {
return grpc.Attachments.GetAttachment(context.Background(), &pcpb.AttachmentLookupRequest{
Uuid: &uuid,
})
2024-03-24 10:31:36 +00:00
}
func CheckAttachmentByUUIDExists(uuid string, usage string) bool {
_, err := grpc.Attachments.CheckAttachmentExists(context.Background(), &pcpb.AttachmentLookupRequest{
Uuid: &uuid,
Usage: &usage,
})
return err == nil
}