Redmage/api/bmessage/bmessage.go

59 lines
972 B
Go
Raw Normal View History

2024-04-10 22:38:19 +07:00
package bmessage
import (
"github.com/alecthomas/units"
)
type ImageMetadata struct {
2024-04-11 16:04:13 +07:00
Kind ImageKind
URL string
2024-04-14 00:32:55 +07:00
Height int64
Width int64
2024-04-10 22:38:19 +07:00
}
2024-04-11 16:04:13 +07:00
type ImageKind int
const (
KindImage ImageKind = iota
KindThumbnail
)
2024-04-14 00:32:55 +07:00
type DownloadEvent int
func (do DownloadEvent) MarshalJSON() ([]byte, error) {
return []byte(`"` + do.String() + `"`), nil
}
func (do DownloadEvent) String() string {
switch do {
case DownloadStart:
return "DownloadStart"
case DownloadProgress:
return "DownloadProgress"
case DownloadEnd:
return "DownloadEnd"
case DownloadError:
return "DownloadError"
default:
return "Unknown"
}
}
const (
DownloadStart DownloadEvent = iota
DownloadProgress
DownloadEnd
DownloadError
)
2024-04-11 16:04:13 +07:00
type ImageDownloadMessage struct {
2024-04-14 00:32:55 +07:00
Event DownloadEvent
2024-04-10 22:38:19 +07:00
Metadata ImageMetadata
2024-04-11 16:04:13 +07:00
ContentLength units.MetricBytes
2024-04-10 22:38:19 +07:00
Downloaded units.MetricBytes
Subreddit string
PostURL string
PostID string
Error error
}