2024-02-04 10:40:20 +00:00
|
|
|
package services
|
|
|
|
|
|
|
|
import (
|
2024-05-17 12:52:13 +00:00
|
|
|
"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
|
|
|
)
|
|
|
|
|
2024-05-17 12:52:13 +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
|
|
|
|
2024-05-17 12:52:13 +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
|
|
|
}
|
2024-05-18 08:59:58 +00:00
|
|
|
|
|
|
|
func CheckAttachmentByUUIDExists(uuid string, usage string) bool {
|
|
|
|
_, err := grpc.Attachments.CheckAttachmentExists(context.Background(), &pcpb.AttachmentLookupRequest{
|
|
|
|
Uuid: &uuid,
|
|
|
|
Usage: &usage,
|
|
|
|
})
|
|
|
|
|
|
|
|
return err == nil
|
|
|
|
}
|