Keep composers usable, group actions and notifications, and drop the tool-count cap
DevPlace CI / test (push) Failing after 3h10m39s
DevPlace CI / test (push) Failing after 3h10m39s
Comment and post layouts stay full width on small screens. Secondary actions live in the More menu. Notifications can be grouped and throttled, and Enter can submit when that profile setting is on. Emulated-tool models accept large catalogs, with reserved names aliased on the wire and the catalog cached per owner. A dropped service-worker navigation is retried once. The test server waits 120s to finish importing before it is stopped.
This commit is contained in:
@@ -32,7 +32,8 @@ from .seo_meta import SEO_META_TYPES, get_seo_metadata, get_seo_metadata_batch,
|
||||
from .activity import record_activity, record_unique_activity, get_user_activity, _activity_cache, _ACTIVITY_TABLES, get_activity_calendar, _activity_level, get_first_activity_date, HEATMAP_WEEKS, get_activity_heatmap, get_activity_months, get_streaks
|
||||
from .customization import CUSTOMIZATION_GLOBAL_SCOPE, CUSTOMIZATION_LANGS, _customizations_cache, _customization_key, CUSTOMIZATION_PREF_COLUMNS, get_customization_prefs, set_customization_pref, get_custom_overrides, get_custom_override, list_custom_overrides, set_custom_override, delete_custom_override
|
||||
from .email import EMAIL_ACCOUNT_DEFAULTS, list_email_accounts, get_email_account, set_email_account, delete_email_account
|
||||
from .notifications import NOTIFICATION_TYPES, NOTIFICATION_CHANNELS, _NOTIFICATION_CHANNEL_COLUMNS, _NOTIFICATION_CHANNEL_DEFAULTS, _NOTIFICATION_TYPE_KEYS, _notification_prefs_cache, _notification_default, get_notification_default, set_notification_default, _notification_overrides, notification_enabled, get_notification_prefs, set_notification_pref, reset_notification_prefs, mark_notifications_read_by_target
|
||||
from .notifications import NOTIFICATION_TYPES, NOTIFICATION_CHANNELS, _NOTIFICATION_CHANNEL_COLUMNS, _NOTIFICATION_CHANNEL_DEFAULTS, _NOTIFICATION_TYPE_KEYS, _notification_prefs_cache, _notification_default, get_notification_default, set_notification_default, _notification_overrides, notification_enabled, get_notification_prefs, set_notification_pref, reset_notification_prefs, mark_notifications_read_by_target, NOTIFICATION_GROUP_KEYS, notification_group_key, notification_throttle_key, get_notification_grouping_enabled, set_notification_grouping_enabled, get_notification_throttle_enabled, set_notification_throttle_enabled, count_unread_groups
|
||||
from .enter_submit import get_enter_to_submit, set_enter_to_submit
|
||||
from .forks import record_fork, get_fork_parent, count_forks, soft_delete_fork_relations, delete_fork_relations
|
||||
from .follows import get_follow_counts, get_follow_list, get_following_among
|
||||
from .deepsearch import _ds_now, create_deepsearch_session, update_deepsearch_session, get_deepsearch_session, list_deepsearch_sessions, add_deepsearch_message, get_deepsearch_messages, get_cached_deepsearch_url, upsert_deepsearch_url_cache
|
||||
@@ -251,6 +252,16 @@ __all__ = [
|
||||
"set_notification_pref",
|
||||
"reset_notification_prefs",
|
||||
"mark_notifications_read_by_target",
|
||||
"NOTIFICATION_GROUP_KEYS",
|
||||
"notification_group_key",
|
||||
"notification_throttle_key",
|
||||
"get_notification_grouping_enabled",
|
||||
"set_notification_grouping_enabled",
|
||||
"get_notification_throttle_enabled",
|
||||
"set_notification_throttle_enabled",
|
||||
"count_unread_groups",
|
||||
"get_enter_to_submit",
|
||||
"set_enter_to_submit",
|
||||
"record_fork",
|
||||
"get_fork_parent",
|
||||
"count_forks",
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
# retoor <retoor@molodetz.nl>
|
||||
|
||||
from .core import db, get_table
|
||||
|
||||
|
||||
def get_enter_to_submit(owner_id: str) -> bool:
|
||||
if "users" not in db.tables:
|
||||
return True
|
||||
user = db["users"].find_one(uid=owner_id)
|
||||
if user is None:
|
||||
return True
|
||||
value = user.get("enter_to_submit")
|
||||
return True if value is None else bool(value)
|
||||
|
||||
|
||||
def set_enter_to_submit(owner_id: str, enabled: bool) -> None:
|
||||
from devplacepy.utils import clear_user_cache
|
||||
|
||||
get_table("users").update(
|
||||
{"uid": owner_id, "enter_to_submit": 1 if enabled else 0}, ["uid"]
|
||||
)
|
||||
clear_user_cache(owner_id)
|
||||
@@ -204,3 +204,87 @@ def mark_notifications_read_by_target(user_uid: str, target_url: str) -> int:
|
||||
|
||||
clear_unread_cache(user_uid)
|
||||
return len(ids)
|
||||
|
||||
|
||||
NOTIFICATION_GROUP_KEYS = {
|
||||
"comment": "actor",
|
||||
"reply": "actor",
|
||||
"thread": "actor",
|
||||
"mention": "actor",
|
||||
"message": "actor",
|
||||
"harvest_stolen": "actor",
|
||||
"award": "actor",
|
||||
"quiz_attempt": "actor",
|
||||
"vote": "target",
|
||||
"follow": "target",
|
||||
"badge": "single",
|
||||
"level": "single",
|
||||
"issue": "single",
|
||||
"reminder": "single",
|
||||
"battle": "single",
|
||||
"workspace": "single",
|
||||
"moderation": "single",
|
||||
"system": "single",
|
||||
"ai_quota_warning": "single",
|
||||
"game_upkeep": "single",
|
||||
}
|
||||
|
||||
|
||||
def notification_group_key(row) -> tuple:
|
||||
ntype = (row.get("type") or "")
|
||||
shape = NOTIFICATION_GROUP_KEYS.get(ntype, "single")
|
||||
if shape == "actor":
|
||||
return (ntype, row.get("related_uid") or "", row.get("target_url") or "")
|
||||
if shape == "target":
|
||||
if ntype == "follow":
|
||||
return (ntype,)
|
||||
return (ntype, row.get("target_url") or "")
|
||||
return (ntype, row.get("uid") or "")
|
||||
|
||||
|
||||
def notification_throttle_key(user_uid: str, notification_type: str, related_uid: str, target_url) -> tuple:
|
||||
row = {"type": notification_type, "related_uid": related_uid or "", "target_url": target_url or "", "uid": ""}
|
||||
return (user_uid,) + notification_group_key(row)
|
||||
|
||||
|
||||
def _user_bool_pref(user_uid: str, column: str) -> bool:
|
||||
if "users" not in db.tables:
|
||||
return True
|
||||
user = db["users"].find_one(uid=user_uid)
|
||||
if user is None:
|
||||
return True
|
||||
value = user.get(column)
|
||||
return True if value is None else bool(value)
|
||||
|
||||
|
||||
def get_notification_grouping_enabled(user_uid: str) -> bool:
|
||||
return _user_bool_pref(user_uid, "notif_grouping_enabled")
|
||||
|
||||
|
||||
def get_notification_throttle_enabled(user_uid: str) -> bool:
|
||||
return _user_bool_pref(user_uid, "notif_throttle_enabled")
|
||||
|
||||
|
||||
def _set_user_bool_pref(user_uid: str, column: str, enabled: bool) -> None:
|
||||
from devplacepy.utils import clear_user_cache
|
||||
|
||||
get_table("users").update({"uid": user_uid, column: 1 if enabled else 0}, ["uid"])
|
||||
clear_user_cache(user_uid)
|
||||
bump_cache_version("notif_prefs")
|
||||
|
||||
|
||||
def set_notification_grouping_enabled(user_uid: str, enabled: bool) -> None:
|
||||
_set_user_bool_pref(user_uid, "notif_grouping_enabled", enabled)
|
||||
|
||||
|
||||
def set_notification_throttle_enabled(user_uid: str, enabled: bool) -> None:
|
||||
_set_user_bool_pref(user_uid, "notif_throttle_enabled", enabled)
|
||||
|
||||
|
||||
def count_unread_groups(user_uid: str) -> int:
|
||||
if "notifications" not in db.tables:
|
||||
return 0
|
||||
rows = list(get_table("notifications").find(user_uid=user_uid, read=False))
|
||||
if not get_notification_grouping_enabled(user_uid):
|
||||
return len(rows)
|
||||
return len({notification_group_key(row) for row in rows})
|
||||
|
||||
@@ -2758,6 +2758,12 @@ def backfill_api_keys() -> int:
|
||||
users.create_column_by_example("cust_disable_global", 0)
|
||||
if not users.has_column("cust_disable_pagetype"):
|
||||
users.create_column_by_example("cust_disable_pagetype", 0)
|
||||
if not users.has_column("enter_to_submit"):
|
||||
users.create_column_by_example("enter_to_submit", 1)
|
||||
if not users.has_column("notif_grouping_enabled"):
|
||||
users.create_column_by_example("notif_grouping_enabled", 1)
|
||||
if not users.has_column("notif_throttle_enabled"):
|
||||
users.create_column_by_example("notif_throttle_enabled", 1)
|
||||
if not users.has_column("ai_correction_enabled"):
|
||||
users.create_column_by_example("ai_correction_enabled", 0)
|
||||
if not users.has_column("ai_correction_prompt"):
|
||||
|
||||
Reference in New Issue
Block a user