ErrorxCode / EasyInsta

A Java library of Instagram's private API and wrapper of instagram4j. Surf Instagram programmatically, build bots, and a lot more. Just a line of code for every operation.
Apache License 2.0
47 stars 10 forks source link

Bug, checking image extension when sending image message #25

Closed ss-brandon closed 1 year ago

ss-brandon commented 1 year ago

Instagram.java

    public AsyncTask<Void> directMessage(@NotNull String username, @NotNull File photo) {
        if (!photo.getName().endsWith(".jpg") || !photo.getName().endsWith(".png") || !photo.getName().endsWith("jpeg"))
            throw new InstagramException("Unsupported file format. Only photos with jpg/png/jpeg extensions are allowed", Reasons.UNSUPPORTED_FILE_FORMAT);

         ....
    }

    ==> || to &&

     public AsyncTask<Void> directMessage(@NotNull String username, @NotNull File photo) {
        if (!photo.getName().endsWith(".jpg") && !photo.getName().endsWith(".png") && !photo.getName().endsWith("jpeg"))
            throw new InstagramException("Unsupported file format. Only photos with jpg/png/jpeg extensions are allowed", Reasons.UNSUPPORTED_FILE_FORMAT);

         ....
    }       
ErrorxCode commented 1 year ago

Thanks for figuring out this bug. You should create a pull request editing the code yourself. Go ahead 👍🏻