forked from retoor/devplacepy
feat: add telegram notification channel with outbox service and per-user preferences
Extend the notification system with a third channel (telegram) alongside existing in_app and push channels. Add `telegram_enabled` column to `notification_preferences` table, update `NOTIFICATION_CHANNELS` and `_NOTIFICATION_CHANNEL_COLUMNS` mappings, and set telegram default to off (`_NOTIFICATION_CHANNEL_DEFAULTS`). Create `telegram_outbox` table with columns for uid, user_uid, chat_id, text, status, attempts, created_at, and sent_at, plus an index on status/id for efficient polling. Register `TelegramOutboxService` in the service manager lifecycle. Update API documentation strings to describe the new channel and its pairing requirement. Extend admin notification defaults view to include telegram column. Pass `notif_telegram_paired` flag to profile template based on `telegram_store.is_paired()` check. Update `NotificationPrefForm` and `NotificationDefaultForm` model literals to accept "telegram" as a valid channel value.
This commit is contained in:
@@ -526,7 +526,7 @@ def test_serialize_handles_legacy_row_without_new_columns(local_db):
|
||||
# --- leaderboard -------------------------------------------------------------
|
||||
|
||||
|
||||
def test_leaderboard_orders_by_level_then_xp(local_db):
|
||||
def test_leaderboard_orders_by_score(local_db):
|
||||
high = _reset("unit_lb_high")
|
||||
low = _reset("unit_lb_low")
|
||||
_set(high, level=8, xp=economy.xp_threshold(8))
|
||||
@@ -535,3 +535,23 @@ def test_leaderboard_orders_by_level_then_xp(local_db):
|
||||
names = [entry["username"] for entry in board]
|
||||
assert "unit_lb_high" in names and "unit_lb_low" in names
|
||||
assert names.index("unit_lb_high") < names.index("unit_lb_low")
|
||||
|
||||
|
||||
def test_leaderboard_prestige_lifts_above_lower_level(local_db):
|
||||
refactorer = _reset("unit_lb_refactor")
|
||||
grinder = _reset("unit_lb_grind")
|
||||
_set(refactorer, level=1, xp=200, prestige=1)
|
||||
_set(grinder, level=5, xp=economy.xp_threshold(5))
|
||||
board = store.leaderboard(50)
|
||||
names = [entry["username"] for entry in board]
|
||||
assert names.index("unit_lb_refactor") < names.index("unit_lb_grind")
|
||||
|
||||
|
||||
def test_leaderboard_entry_exposes_score_and_prestige(local_db):
|
||||
user = _reset("unit_lb_fields")
|
||||
_set(user, prestige=3, total_harvests=12, ci_tier=2)
|
||||
entry = next(e for e in store.leaderboard(50) if e["username"] == "unit_lb_fields")
|
||||
farm = store.get_farm(user["uid"])
|
||||
assert entry["prestige"] == 3
|
||||
assert entry["score"] == economy.farm_score(farm)
|
||||
assert {"rank", "username", "level", "xp", "coins", "total_harvests", "prestige", "score"} <= set(entry)
|
||||
|
||||
Reference in New Issue
Block a user