X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Ftemplate%2FPostAccessor.kt;h=406a6b0a242c3d5fb2c2ebf025f30950467724f6;hp=5222b945ab5ba51d44dc19ee8fcc4310fd501f16;hb=2f1e414e86c61435cd8b3991c475e0832f6de2fb;hpb=d9cffbf70e8504180328964511303c1d70207b84 diff --git a/src/main/kotlin/net/pterodactylus/sone/template/PostAccessor.kt b/src/main/kotlin/net/pterodactylus/sone/template/PostAccessor.kt index 5222b94..406a6b0 100644 --- a/src/main/kotlin/net/pterodactylus/sone/template/PostAccessor.kt +++ b/src/main/kotlin/net/pterodactylus/sone/template/PostAccessor.kt @@ -1,5 +1,5 @@ /* - * Sone - PostAccessor.java - Copyright © 2010–2019 David Roden + * Sone - PostAccessor.kt - Copyright © 2010–2019 David Roden * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,10 +14,12 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package net.pterodactylus.sone.template import net.pterodactylus.sone.core.* import net.pterodactylus.sone.data.* +import net.pterodactylus.sone.utils.* import net.pterodactylus.util.template.* /** @@ -39,9 +41,8 @@ class PostAccessor(private val core: Core) : ReflectionAccessor() { "liked" -> templateContext.currentSone?.isLikedPostId(post.id) ?: false "new" -> !post.isKnown "bookmarked" -> core.isBookmarked(post) - "replySone" -> core.getReplies(post) - .lastOrNull { it.sone.isLocal } - ?.sone + "replySone" -> core.getReplies(post).lastOrNull { it.sone.isLocal }?.sone + ?: post.recipient.let { it.takeIf { it.isLocal } } ?: post.sone.takeIf { it.isLocal } ?: templateContext.currentSone else -> super.get(templateContext, `object`, member)