use of com.erudika.scoold.core.Profile in project scoold by Erudika.
the class AdminController method toggleWebhook.
@PostMapping("/toggle-webhook")
public String toggleWebhook(@RequestParam String id, HttpServletRequest req, HttpServletResponse res) {
Profile authUser = utils.getAuthUser(req);
if (!StringUtils.isBlank(id) && utils.isAdmin(authUser) && utils.isWebhooksEnabled()) {
Webhook webhook = pc.read(id);
if (webhook != null) {
webhook.setActive(!webhook.getActive());
pc.update(webhook);
}
}
if (utils.isAjaxRequest(req)) {
res.setStatus(200);
return "base";
} else {
return "redirect:" + ADMINLINK;
}
}
use of com.erudika.scoold.core.Profile in project scoold by Erudika.
the class DefaultAvatarRepositoryTest method getLink_should_return_always_default_avatar.
@Test
public void getLink_should_return_always_default_avatar() {
Profile profile = new Profile();
assertEquals(ScooldUtils.getDefaultAvatar(), repository.getLink(profile, AvatarFormat.Profile));
assertEquals(repository.getLink(new Profile(), AvatarFormat.Square32), repository.getLink(new Profile(), AvatarFormat.Profile));
}
use of com.erudika.scoold.core.Profile in project scoold by Erudika.
the class DefaultAvatarRepositoryTest method store_should_nothing.
@Test
public void store_should_nothing() {
Profile profile = new Profile();
boolean result = repository.store(profile, "https://avatar");
assertEquals(ScooldUtils.getDefaultAvatar(), profile.getPicture());
assertEquals(true, result);
}
use of com.erudika.scoold.core.Profile in project scoold by Erudika.
the class GravatarAvatarRepositoryTest method setUp.
@Before
public void setUp() {
this.profile = new Profile();
this.profile.setUser(new User());
this.defaultRepository = new DefaultAvatarRepository();
this.gravatarGenerator = new GravatarAvatarGenerator();
this.repository = new GravatarAvatarRepository(gravatarGenerator, defaultRepository);
}
use of com.erudika.scoold.core.Profile in project scoold by Erudika.
the class SettingsController method post.
@PostMapping
public String post(@RequestParam(required = false) String tags, @RequestParam(required = false) String latlng, @RequestParam(required = false) String replyEmailsOn, @RequestParam(required = false) String commentEmailsOn, HttpServletRequest req) {
if (utils.isAuthenticated(req)) {
Profile authUser = utils.getAuthUser(req);
if (!StringUtils.isBlank(tags)) {
Set<String> ts = new LinkedHashSet<String>();
for (String tag : tags.split(",")) {
if (!StringUtils.isBlank(tag) && ts.size() <= MAX_FAV_TAGS) {
ts.add(tag);
}
}
authUser.setFavtags(new LinkedList<String>(ts));
}
if (!StringUtils.isBlank(latlng)) {
authUser.setLatlng(latlng);
}
authUser.setReplyEmailsEnabled(Boolean.valueOf(replyEmailsOn));
authUser.setCommentEmailsEnabled(Boolean.valueOf(commentEmailsOn));
authUser.update();
}
return "redirect:" + settingslink;
}
Aggregations