merged from gramsrv upstream
This commit is contained in:
parent
79c64ee916
commit
21a0856587
651 changed files with 54774 additions and 4590 deletions
|
|
@ -301,7 +301,7 @@ func tgDocument(d domain.Document) tg.DocumentClass {
|
|||
Date: d.Date,
|
||||
MimeType: d.MimeType,
|
||||
Size: d.Size,
|
||||
Thumbs: tgDocumentThumbs(d.MimeType, d.Thumbs),
|
||||
Thumbs: tgDocumentThumbs(d.Thumbs),
|
||||
DCID: d.DCID,
|
||||
Attributes: tgDocumentAttributes(d.MimeType, d.Attributes),
|
||||
}
|
||||
|
|
@ -315,15 +315,12 @@ func tgDocuments(docs []domain.Document) []tg.DocumentClass {
|
|||
return out
|
||||
}
|
||||
|
||||
func tgDocumentThumbs(mimeType string, sizes []domain.PhotoSize) []tg.PhotoSizeClass {
|
||||
func tgDocumentThumbs(sizes []domain.PhotoSize) []tg.PhotoSizeClass {
|
||||
if len(sizes) == 0 {
|
||||
return nil
|
||||
}
|
||||
out := make([]tg.PhotoSizeClass, 0, len(sizes))
|
||||
for _, s := range sizes {
|
||||
if isSeedSyntheticTGStickerPreviewThumb(mimeType, s) {
|
||||
continue
|
||||
}
|
||||
if s.Kind == domain.PhotoSizeKindCached && len(s.Bytes) > 0 {
|
||||
size := s.Size
|
||||
if size == 0 {
|
||||
|
|
@ -339,17 +336,6 @@ func tgDocumentThumbs(mimeType string, sizes []domain.PhotoSize) []tg.PhotoSizeC
|
|||
return compactPhotoSizeClasses(out)
|
||||
}
|
||||
|
||||
func isSeedSyntheticTGStickerPreviewThumb(mimeType string, s domain.PhotoSize) bool {
|
||||
// Older seed imports gave TGS documents without thumbnails a 1x1 transparent
|
||||
// "m" PNG. Clients can prefer that unusable preview and render blank stickers.
|
||||
return mimeType == mimeApplicationXTGSticker &&
|
||||
s.Kind == domain.PhotoSizeKindCached &&
|
||||
s.Type == "m" &&
|
||||
s.W <= 1 &&
|
||||
s.H <= 1 &&
|
||||
len(s.Bytes) > 0
|
||||
}
|
||||
|
||||
func tgPhotoSizes(sizes []domain.PhotoSize) []tg.PhotoSizeClass {
|
||||
if len(sizes) == 0 {
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue