From 6055a509485598afa6aea9cbf841424d48f5e761 Mon Sep 17 00:00:00 2001 From: Mia Herkt Date: Tue, 13 Dec 2022 21:51:39 +0100 Subject: [PATCH] File: Add is_nsfw property --- fhost.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fhost.py b/fhost.py index 75702a1..641729d 100755 --- a/fhost.py +++ b/fhost.py @@ -149,13 +149,17 @@ class File(db.Model): self.expiration = expiration self.mgmt_token = mgmt_token + @property + def is_nsfw(self) -> bool: + return self.nsfw_score and self.nsfw_score > app.config["NSFW_THRESHOLD"] + def getname(self): return u"{0}{1}".format(su.enbase(self.id), self.ext) def geturl(self): n = self.getname() - if self.nsfw_score and self.nsfw_score > app.config["NSFW_THRESHOLD"]: + if self.is_nsfw: return url_for("get", path=n, secret=self.secret, _external=True, _anchor="nsfw") + "\n" else: return url_for("get", path=n, secret=self.secret, _external=True) + "\n"