subscriptions: add forum_enabled toggle for trust circle
This commit is contained in:
parent
b07ca37663
commit
f27321888d
3 changed files with 23 additions and 0 deletions
|
|
@ -270,6 +270,12 @@ def init_db():
|
|||
db.execute("ALTER TABLE pages ADD COLUMN reticulum_dest TEXT DEFAULT ''")
|
||||
db.commit()
|
||||
|
||||
# Migrate subscriptions: add forum_enabled column
|
||||
sub_cols = [row[1] for row in db.execute("PRAGMA table_info(subscriptions)").fetchall()]
|
||||
if "forum_enabled" not in sub_cols:
|
||||
db.execute("ALTER TABLE subscriptions ADD COLUMN forum_enabled INTEGER DEFAULT 0")
|
||||
db.commit()
|
||||
|
||||
# Chunks table for semantic search embeddings
|
||||
db.execute(
|
||||
"CREATE TABLE IF NOT EXISTS chunks ("
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ from .subscriptions import (
|
|||
handle_subscriptions, handle_subscription_add, handle_subscription_browse,
|
||||
handle_subscription_pick, _sync_subscription,
|
||||
handle_subscription_sync, handle_subscription_autosync,
|
||||
handle_subscription_forum,
|
||||
handle_subscription_delete, handle_subscription_syncall,
|
||||
_sync_threads,
|
||||
)
|
||||
|
|
@ -150,6 +151,9 @@ def _dispatch_inner(data):
|
|||
elif path.startswith("/subscriptions/autosync/"):
|
||||
sid = extract_id("/subscriptions/autosync/")
|
||||
return handle_subscription_autosync(sid) if sid is not None else _error(400)
|
||||
elif path.startswith("/subscriptions/forum/"):
|
||||
sid = extract_id("/subscriptions/forum/")
|
||||
return handle_subscription_forum(sid) if sid is not None else _error(400)
|
||||
elif path.startswith("/subscriptions/delete/"):
|
||||
sid = extract_id("/subscriptions/delete/")
|
||||
return handle_subscription_delete(sid) if sid is not None else _error(400)
|
||||
|
|
|
|||
|
|
@ -146,6 +146,7 @@ def handle_subscriptions(msg=""):
|
|||
for s in subs:
|
||||
sub_id = s["id"]
|
||||
auto_label = "on" if s["auto_sync"] else "off"
|
||||
forum_label = "on" if s.get("forum_enabled") else "off"
|
||||
last = s["last_sync"] or "never"
|
||||
sync_status = get_setting(f"sync_status_{sub_id}", "")
|
||||
is_syncing = sub_id in _sync_threads and _sync_threads[sub_id].is_alive()
|
||||
|
|
@ -177,6 +178,8 @@ def handle_subscriptions(msg=""):
|
|||
f'{sync_btn}'
|
||||
f'<form method="post" action="/subscriptions/autosync/{sub_id}" style="display:inline-block;margin:0">'
|
||||
f'{_csrf_field()}<button>auto-sync: {auto_label}</button></form>'
|
||||
f'<form method="post" action="/subscriptions/forum/{sub_id}" style="display:inline-block;margin:0">'
|
||||
f'{_csrf_field()}<button>forum: {forum_label}</button></form>'
|
||||
f'<form method="post" action="/subscriptions/delete/{sub_id}" style="display:inline-block;margin:0">'
|
||||
f'{_csrf_field()}<button>remove</button></form>'
|
||||
f'</div>'
|
||||
|
|
@ -430,6 +433,16 @@ def handle_subscription_autosync(sub_id):
|
|||
return _redirect("/subscriptions")
|
||||
|
||||
|
||||
def handle_subscription_forum(sub_id):
|
||||
db = get_db()
|
||||
try:
|
||||
db.execute("UPDATE subscriptions SET forum_enabled = 1 - forum_enabled WHERE id = ?", (sub_id,))
|
||||
db.commit()
|
||||
finally:
|
||||
return_db(db)
|
||||
return _redirect("/subscriptions")
|
||||
|
||||
|
||||
def handle_subscription_delete(sub_id):
|
||||
db = get_db()
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue