mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-07-07 02:10:58 +02:00
feat(api): add advertisement history API endpoint (Task 2.8)
Add GET /api/advertisements with optional pubkey filter and limit. Enriches results with contact name lookup from cache. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -414,6 +414,23 @@ class Database:
|
||||
kwargs.get('raw_payload'))
|
||||
)
|
||||
|
||||
def get_advertisements(self, limit: int = 100, public_key: str = None) -> list:
|
||||
with self._connect() as conn:
|
||||
if public_key:
|
||||
rows = conn.execute(
|
||||
"""SELECT * FROM advertisements
|
||||
WHERE public_key = ?
|
||||
ORDER BY timestamp DESC LIMIT ?""",
|
||||
(public_key.lower(), limit)
|
||||
).fetchall()
|
||||
else:
|
||||
rows = conn.execute(
|
||||
"""SELECT * FROM advertisements
|
||||
ORDER BY timestamp DESC LIMIT ?""",
|
||||
(limit,)
|
||||
).fetchall()
|
||||
return [dict(r) for r in rows]
|
||||
|
||||
# ================================================================
|
||||
# Read Status
|
||||
# ================================================================
|
||||
|
||||
Reference in New Issue
Block a user