Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.

Commit

Permalink
fix null pointer exception
Browse files Browse the repository at this point in the history
closes #539
  • Loading branch information
sk22 committed Jun 1, 2023
1 parent f373e7d commit bfcff1e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;

@Parcel
public class Instance extends BaseModel{
Expand Down Expand Up @@ -147,6 +148,22 @@ public boolean isAkkoma() {
return pleroma != null;
}

public boolean hasFeature(Feature feature) {
Optional<List<String>> pleromaFeatures = Optional.ofNullable(pleroma)
.map(p -> p.metadata)
.map(m -> m.features);

return switch (feature) {
case BUBBLE_TIMELINE -> pleromaFeatures
.map(f -> f.contains("bubble_timeline"))
.orElse(false);
};
}

public enum Feature {
BUBBLE_TIMELINE
}

@Parcel
public static class Rule{
public String id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public boolean isCompatible(AccountSession session) {
@Override
public boolean wantsDefault(AccountSession session) {
return session.getInstance()
.map(i -> i.isAkkoma() && i.pleroma.metadata.features.contains("bubble_timeline"))
.map(i -> i.hasFeature(Instance.Feature.BUBBLE_TIMELINE))
.orElse(false);
}
};
Expand Down

0 comments on commit bfcff1e

Please sign in to comment.