forked from retoor/devplacepy
docs: add block/mute user relations, emoji-sync CLI, and uid indexes
- Add `/block`, `/mute` endpoints with block/unblock and mute/unmute functionality in `routers/relations.py`, hiding blocked users' content everywhere except their own profile while muting only suppresses notifications - Introduce `devplace emoji-sync` CLI command to regenerate `static/js/emoji-shortcodes.js` from the emoji library, documented in `CLAUDE.md` and wired in `cli.py` - Create `get_blocked_uids()` database helper and apply it in `content.py` `load_detail()` to filter blocked users' posts from detail views - Implement `_uid_index()` and `_drop_index()` helpers in `database.py` for unique uid indexes across tables, with `user_relations` added to `SOFT_DELETE_TABLES` - Document new routes in `AGENTS.md` and `README.md`, including emoji shortcodes rendering behavior distinct from the emoji picker
This commit is contained in:
@@ -4,6 +4,7 @@ CATEGORY_BY_PREFIX: dict[str, str] = {
|
||||
"auth": "auth",
|
||||
"profile": "account",
|
||||
"follow": "social",
|
||||
"relation": "social",
|
||||
"push": "push",
|
||||
"notification": "notification",
|
||||
"message": "message",
|
||||
|
||||
@@ -264,6 +264,7 @@ class DevPlaceBot:
|
||||
or []
|
||||
)
|
||||
self.state.username = self._next_handle()
|
||||
self.state.account_api_key = ""
|
||||
self.state.email = self.faker.email()
|
||||
self.state.password = self.faker.password(length=random.randint(12, 18))
|
||||
self.state.started_at = datetime.now().isoformat()
|
||||
@@ -312,6 +313,7 @@ class DevPlaceBot:
|
||||
self.state.username = f"{base}{random.randint(10, 9999)}"[:20]
|
||||
else:
|
||||
self.state.username = self._next_handle()
|
||||
self.state.account_api_key = ""
|
||||
self.state.email = self.faker.email()
|
||||
self._log(f"Signup failed, retrying as {self.state.username}")
|
||||
return False
|
||||
@@ -337,16 +339,14 @@ class DevPlaceBot:
|
||||
return (key or "").strip()
|
||||
|
||||
async def _adopt_account_api_key(self) -> bool:
|
||||
if self.state.account_api_key:
|
||||
self.llm.api_key = self.state.account_api_key
|
||||
return True
|
||||
for attempt in range(5):
|
||||
key = await self._fetch_account_api_key()
|
||||
if key:
|
||||
self.state.account_api_key = key
|
||||
if key != self.state.account_api_key:
|
||||
self.state.account_api_key = key
|
||||
self._save()
|
||||
self._log("Adopted account API key for gateway calls")
|
||||
self.llm.api_key = key
|
||||
self._save()
|
||||
self._log("Adopted account API key for gateway calls")
|
||||
return True
|
||||
if attempt < 4:
|
||||
await asyncio.sleep(2)
|
||||
|
||||
@@ -853,6 +853,34 @@ ACTIONS: tuple[Action, ...] = (
|
||||
summary="Unfollow a user",
|
||||
params=(path("username", "Username to unfollow."),),
|
||||
),
|
||||
Action(
|
||||
name="block_user",
|
||||
method="POST",
|
||||
path="/block/{username}",
|
||||
summary="Block a user so their posts, comments and messages are hidden and they cannot notify you",
|
||||
params=(path("username", "Username to block."),),
|
||||
),
|
||||
Action(
|
||||
name="unblock_user",
|
||||
method="POST",
|
||||
path="/block/unblock/{username}",
|
||||
summary="Unblock a user",
|
||||
params=(path("username", "Username to unblock."),),
|
||||
),
|
||||
Action(
|
||||
name="mute_user",
|
||||
method="POST",
|
||||
path="/mute/{username}",
|
||||
summary="Mute a user so they can no longer create notifications for you",
|
||||
params=(path("username", "Username to mute."),),
|
||||
),
|
||||
Action(
|
||||
name="unmute_user",
|
||||
method="POST",
|
||||
path="/mute/unmute/{username}",
|
||||
summary="Unmute a user",
|
||||
params=(path("username", "Username to unmute."),),
|
||||
),
|
||||
Action(
|
||||
name="list_followers",
|
||||
method="GET",
|
||||
|
||||
@@ -5,7 +5,7 @@ from datetime import datetime, timezone
|
||||
from typing import Any, Optional
|
||||
|
||||
from devplacepy.attachments import get_attachments, link_attachments
|
||||
from devplacepy.database import get_table
|
||||
from devplacepy.database import get_table, get_blocked_uids
|
||||
from devplacepy.templating import clear_messages_cache
|
||||
from devplacepy.utils import (
|
||||
create_mention_notifications,
|
||||
@@ -72,6 +72,9 @@ def persist_message(
|
||||
if not receiver:
|
||||
return None
|
||||
|
||||
if sender["uid"] in get_blocked_uids(receiver_uid):
|
||||
return None
|
||||
|
||||
sender_uid = sender["uid"]
|
||||
sender_username = sender.get("username", "")
|
||||
messages_table = get_table("messages")
|
||||
|
||||
Reference in New Issue
Block a user