package com.atlassian.stash.internal.web.conditions;

import com.atlassian.plugin.PluginParseException;
import com.atlassian.plugin.web.Condition;
import com.atlassian.stash.internal.avatar.InternalAvatarService;

import java.util.Map;

/**
 * A condition determining whether avatars are enabled. When this is disabled, default avatars are displayed for
 * all users.
 */
public class HasAvatarServiceEnabledCondition implements Condition {

    private final InternalAvatarService avatarService;

    public HasAvatarServiceEnabledCondition(InternalAvatarService avatarService) {
        this.avatarService = avatarService;
    }

    @Override
    public void init(Map<String, String> params) throws PluginParseException {
    }

    @Override
    public boolean shouldDisplay(Map<String, Object> context) {
        return avatarService.isEnabled();
    }
}
