mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Merge pull request #2 from po5/priv-view-unsafe-posts
server: prevent cache key collision
This commit is contained in:
@ -228,6 +228,11 @@ class PostSearchConfig(BaseSearchConfig):
|
|||||||
)
|
)
|
||||||
return query.order_by(model.Post.post_id.desc())
|
return query.order_by(model.Post.post_id.desc())
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def can_list_unsafe(self) -> bool:
|
||||||
|
return self.user and auth.has_privilege(self.user, "posts:list:unsafe")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def id_column(self) -> SaColumn:
|
def id_column(self) -> SaColumn:
|
||||||
return model.Post.post_id
|
return model.Post.post_id
|
||||||
|
@ -93,7 +93,10 @@ class Executor:
|
|||||||
if token.name == "random":
|
if token.name == "random":
|
||||||
disable_eager_loads = True
|
disable_eager_loads = True
|
||||||
|
|
||||||
key = (id(self.config), hash(search_query), offset, limit)
|
|
||||||
|
can_list_unsafe = getattr(self.config, "can_list_unsafe", False)
|
||||||
|
|
||||||
|
key = (id(self.config), hash(search_query), offset, limit, can_list_unsafe)
|
||||||
if cache.has(key):
|
if cache.has(key):
|
||||||
return cache.get(key)
|
return cache.get(key)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user