/**
* Page that lets the user edit the name of a profile field.
*/
-class EditProfileFieldPage(template: Template, webInterface: WebInterface):
+class EditProfileFieldPage(template: Template, webInterface: WebInterface) :
LoggedInPage("editProfileField.html", template, "Page.EditProfileField.Title", webInterface) {
override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
- currentSone.profile.let { profile ->
- if (freenetRequest.isPOST) {
- if (freenetRequest.httpRequest.getPartAsStringFailsafe("cancel", 4) == "true") {
- throw RedirectException("editProfile.html#profile-fields")
- }
- val field = profile.getFieldById(freenetRequest.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html")
- freenetRequest.httpRequest.getPartAsStringFailsafe("name", 256).let { name ->
- try {
- if (name != field.name) {
- field.name = name
- currentSone.profile = profile
- }
- throw RedirectException("editProfile.html#profile-fields")
- } catch (e: IllegalArgumentException) {
- templateContext["duplicateFieldName"] = true
- return
+ currentSone.profile.let { profile ->
+ if (freenetRequest.isPOST) {
+ if (freenetRequest.httpRequest.getPartAsStringFailsafe("cancel", 4) == "true") {
+ throw RedirectException("editProfile.html#profile-fields")
+ }
+ val field = profile.getFieldById(freenetRequest.httpRequest.getPartAsStringFailsafe("field", 36)) ?: throw RedirectException("invalid.html")
+ freenetRequest.httpRequest.getPartAsStringFailsafe("name", 256).let { name ->
+ try {
+ if (name != field.name) {
+ field.name = name
+ currentSone.profile = profile
}
+ throw RedirectException("editProfile.html#profile-fields")
+ } catch (e: IllegalArgumentException) {
+ templateContext["duplicateFieldName"] = true
+ return
}
}
- templateContext["field"] = profile.getFieldById(freenetRequest.httpRequest.getParam("field")) ?: throw RedirectException("invalid.html")
}
+ templateContext["field"] = profile.getFieldById(freenetRequest.httpRequest.getParam("field")) ?: throw RedirectException("invalid.html")
+ }
}
}
* Page that lets the user like [net.pterodactylus.sone.data.Post]s and [net.pterodactylus.sone.data.Reply]s.
*/
class LikePage(template: Template, webInterface: WebInterface) :
- LoggedInPage("like.html", template, "Page.Like.Title", webInterface) {
+ LoggedInPage("like.html", template, "Page.Like.Title", webInterface) {
override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
if (freenetRequest.isPOST) {
- freenetRequest.parameters["type", 16]?.also { type ->
- when(type) {
- "post" -> currentSone.addLikedPostId(freenetRequest.parameters["post", 36]!!)
- "reply" -> currentSone.addLikedReplyId(freenetRequest.parameters["reply", 36]!!)
- }
+ freenetRequest.parameters["type", 16]?.also { type ->
+ when (type) {
+ "post" -> currentSone.addLikedPostId(freenetRequest.parameters["post", 36]!!)
+ "reply" -> currentSone.addLikedReplyId(freenetRequest.parameters["reply", 36]!!)
}
- throw RedirectException(freenetRequest.parameters["returnPage", 256]!!)
+ }
+ throw RedirectException(freenetRequest.parameters["returnPage", 256]!!)
}
}
* Page that lets the user trust another Sone. This will assign a configurable
* amount of trust to an identity.
*/
-class TrustPage(template: Template, webInterface: WebInterface):
+class TrustPage(template: Template, webInterface: WebInterface) :
LoggedInPage("trust.html", template, "Page.Trust.Title", webInterface) {
override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
if (freenetRequest.isPOST) {
- webInterface.core.getSone(freenetRequest.parameters["sone"]!!)?.let { sone ->
- webInterface.core.trustSone(currentSone, sone)
- }
+ webInterface.core.getSone(freenetRequest.parameters["sone"]!!)?.let { sone ->
+ webInterface.core.trustSone(currentSone, sone)
+ }
throw RedirectException(freenetRequest.parameters["returnPage", 256])
}
}
/**
* This page lets the user unfollow another Sone.
*/
-class UnfollowSonePage(template: Template, webInterface: WebInterface):
+class UnfollowSonePage(template: Template, webInterface: WebInterface) :
LoggedInPage("unfollowSone.html", template, "Page.UnfollowSone.Title", webInterface) {
override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
if (freenetRequest.isPOST) {
- freenetRequest.parameters["sone"]!!.split(Regex("[ ,]+"))
- .forEach { webInterface.core.unfollowSone(currentSone, it) }
+ freenetRequest.parameters["sone"]!!.split(Regex("[ ,]+"))
+ .forEach { webInterface.core.unfollowSone(currentSone, it) }
throw RedirectException(freenetRequest.parameters["returnPage", 256])
}
}
* Page that lets the user untrust another Sone. This will remove all trust
* assignments for an identity.
*/
-class UntrustPage(template: Template, webInterface: WebInterface):
+class UntrustPage(template: Template, webInterface: WebInterface) :
LoggedInPage("untrust.html", template, "Page.Untrust.Title", webInterface) {
override fun handleRequest(freenetRequest: FreenetRequest, currentSone: Sone, templateContext: TemplateContext) {
if (freenetRequest.isPOST) {
- freenetRequest.parameters["sone", 44]!!
- .let(webInterface.core::getSone)
- ?.also { webInterface.core.untrustSone(currentSone, it) }
+ freenetRequest.parameters["sone", 44]!!
+ .let(webInterface.core::getSone)
+ ?.also { webInterface.core.untrustSone(currentSone, it) }
throw RedirectException(freenetRequest.parameters["returnPage", 256])
}
}