mirror of
https://git.0x0.st/mia/0x0.git
synced 2024-11-22 16:57:12 +01:00
File: Add is_nsfw property
This commit is contained in:
parent
b1ed63c401
commit
6055a50948
1 changed files with 5 additions and 1 deletions
6
fhost.py
6
fhost.py
|
@ -149,13 +149,17 @@ class File(db.Model):
|
||||||
self.expiration = expiration
|
self.expiration = expiration
|
||||||
self.mgmt_token = mgmt_token
|
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):
|
def getname(self):
|
||||||
return u"{0}{1}".format(su.enbase(self.id), self.ext)
|
return u"{0}{1}".format(su.enbase(self.id), self.ext)
|
||||||
|
|
||||||
def geturl(self):
|
def geturl(self):
|
||||||
n = self.getname()
|
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"
|
return url_for("get", path=n, secret=self.secret, _external=True, _anchor="nsfw") + "\n"
|
||||||
else:
|
else:
|
||||||
return url_for("get", path=n, secret=self.secret, _external=True) + "\n"
|
return url_for("get", path=n, secret=self.secret, _external=True) + "\n"
|
||||||
|
|
Loading…
Reference in a new issue