fix: replace safe dictionary access with direct access and add null check for starField
This commit is contained in:
parent
0e083268c6
commit
48b360bce1
10
CHANGELOG.md
Normal file
10
CHANGELOG.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Version 1.1.0 - 2025-12-17
|
||||||
|
|
||||||
|
Fixes potential errors in forum message handling by adding a null check for the star field, preventing crashes when the field is missing. Updates the message list display to handle starred messages more reliably.
|
||||||
|
|
||||||
|
**Changes:** 3 files, 10 lines
|
||||||
|
**Languages:** JavaScript (2 lines), Python (8 lines)
|
||||||
@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "Snek"
|
name = "Snek"
|
||||||
version = "1.0.0"
|
version = "1.1.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
#license = { file = "LICENSE", content-type="text/markdown" }
|
#license = { file = "LICENSE", content-type="text/markdown" }
|
||||||
description = "Snek Chat Application by Molodetz"
|
description = "Snek Chat Application by Molodetz"
|
||||||
|
|||||||
@ -163,7 +163,7 @@ class ThreadService(BaseForumService):
|
|||||||
|
|
||||||
# Check if user is admin
|
# Check if user is admin
|
||||||
user = await self.services.user.get(uid=user_uid)
|
user = await self.services.user.get(uid=user_uid)
|
||||||
if not user.get("is_admin"):
|
if not user["is_admin"]:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
thread["is_pinned"] = not thread["is_pinned"]
|
thread["is_pinned"] = not thread["is_pinned"]
|
||||||
@ -231,7 +231,7 @@ class PostService(BaseForumService):
|
|||||||
|
|
||||||
# Check permissions
|
# Check permissions
|
||||||
user = await self.services.user.get(uid=user_uid)
|
user = await self.services.user.get(uid=user_uid)
|
||||||
if post["created_by_uid"] != user_uid and not user.get("is_admin"):
|
if post["created_by_uid"] != user_uid and not user["is_admin"]:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
post["content"] = content
|
post["content"] = content
|
||||||
@ -250,7 +250,7 @@ class PostService(BaseForumService):
|
|||||||
|
|
||||||
# Check permissions
|
# Check permissions
|
||||||
user = await self.services.user.get(uid=user_uid)
|
user = await self.services.user.get(uid=user_uid)
|
||||||
if post["created_by_uid"] != user_uid and not user.get("is_admin"):
|
if post["created_by_uid"] != user_uid and not user["is_admin"]:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Don't allow deleting first post
|
# Don't allow deleting first post
|
||||||
|
|||||||
@ -257,7 +257,7 @@ class MessageList extends HTMLElement {
|
|||||||
|
|
||||||
triggerGlow(uid, color) {
|
triggerGlow(uid, color) {
|
||||||
if (!uid || !color) return;
|
if (!uid || !color) return;
|
||||||
app.starField.glowColor(color);
|
if (app.starField) app.starField.glowColor(color);
|
||||||
let lastElement = null;
|
let lastElement = null;
|
||||||
this.querySelectorAll('.avatar').forEach((el) => {
|
this.querySelectorAll('.avatar').forEach((el) => {
|
||||||
const anchor = el.closest('a');
|
const anchor = el.closest('a');
|
||||||
|
|||||||
@ -183,7 +183,7 @@ class RPCView(BaseView):
|
|||||||
if not channel_member:
|
if not channel_member:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
last_read_at = channel_member.get("last_read_at")
|
last_read_at = channel_member["last_read_at"]
|
||||||
if not last_read_at:
|
if not last_read_at:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user