Skip to content

Commit 0693fc7

Browse files
committed
move non-compliant animated sticker log and rename test file
1 parent 448a2f2 commit 0693fc7

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/main/java/com/github/stickerifier/stickerify/media/MediaHelper.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,12 @@ private static boolean isAnimatedStickerCompliant(File file, String mimeType) th
133133
try {
134134
var sticker = GSON.fromJson(uncompressedContent, AnimationDetails.class);
135135

136-
return isAnimationCompliant(sticker) && isFileSizeLowerThan(file, MAX_ANIMATION_FILE_SIZE);
136+
boolean isAnimationCompliant = isAnimationCompliant(sticker);
137+
if (isAnimationCompliant) {
138+
return isFileSizeLowerThan(file, MAX_ANIMATION_FILE_SIZE);
139+
}
140+
141+
LOGGER.atWarn().log("The {} doesn't meet Telegram's requirements", sticker);
137142
} catch (JsonSyntaxException _) {
138143
LOGGER.atInfo().log("The archive isn't an animated sticker");
139144
}
@@ -166,17 +171,11 @@ public String toString() {
166171
* @return {@code true} if the animation is compliant
167172
*/
168173
private static boolean isAnimationCompliant(AnimationDetails animation) {
169-
boolean isCompliant = animation != null
174+
return animation != null
170175
&& animation.frameRate() <= MAX_ANIMATION_FRAME_RATE
171176
&& animation.duration() <= MAX_ANIMATION_DURATION_SECONDS
172177
&& animation.width() == MAX_SIDE_LENGTH
173178
&& animation.height() == MAX_SIDE_LENGTH;
174-
175-
if (!isCompliant) {
176-
LOGGER.atWarn().log("The {} doesn't meet Telegram's requirements", animation);
177-
}
178-
179-
return isCompliant;
180179
}
181180

182181
/**

src/test/java/com/github/stickerifier/stickerify/media/MediaHelperTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ void noLowFpsAnimatedStickerConversionNeeded() throws Exception {
241241

242242
@Test
243243
void nonCompliantAnimatedSticker() {
244-
var archive = loadResource("non_compliant_animated_sticker.gz");
244+
var archive = loadResource("non_compliant_animated_sticker.tgs");
245245

246246
assertThrows(MediaException.class, () -> MediaHelper.convert(archive));
247247
}
File renamed without changes.

0 commit comments

Comments
 (0)