Commit Diff


commit - 9bfc216b59d0136876cfb9a75353054d0c0518a6
commit + 7c41d2555ab3a031a8ec5b52779a65413fc33939
blob - cc2de86de87a68e6d41f4b2a9cbc8e9ec8ea924b
blob + 0ef848b046556ce47cd1009940c80817b1a60558
--- lonk.py
+++ lonk.py
@@ -233,6 +233,7 @@ def _create_schema(db_con):
                 url TEXT,
                 html TEXT,
                 date TEXT,
+                public INTEGER,
                 FOREIGN KEY (client_id) REFERENCES client (client_id),
                 UNIQUE (convoy, client_id),
                 UNIQUE (honk_id, client_id)
@@ -277,7 +278,7 @@ def db_connect():
 
 
 class _LonkTreeItem:
-    def __init__(self, convoy_id, convoy, honk_id, honker, url, html, date):
+    def __init__(self, convoy_id, convoy, honk_id, honker, url, html, date, public):
         self.convoy_id = convoy_id
         self.convoy = convoy
         self.honk_id = honk_id
@@ -285,6 +286,7 @@ class _LonkTreeItem:
         self.url = url
         self.html = html
         self.date = date
+        self.public = bool(public)
         self.donks = []
         self.reposters = []
         self.thread = []
@@ -301,6 +303,7 @@ class _LonkTreeItem:
                 "XID": self.url,
                 "HTML": self.html,
                 "Date": self.date,
+                "Public": self.public,
                 "Donks": [
                     {"URL": donk[0], "Media": donk[1], "Desc": donk[2]}
                     for donk in self.donks
@@ -320,7 +323,7 @@ def page_lonk(db_con, client_id, lonk_url, honk_url):
 
         if convoy not in lonk_page:
             row = db_con.execute(
-                "SELECT convoy_id, convoy, honk_id, honker, url, html, date FROM convoy WHERE client_id=? AND convoy=?",
+                "SELECT convoy_id, convoy, honk_id, honker, url, html, date, public FROM convoy WHERE client_id=? AND convoy=?",
                 (client_id, convoy)
             ).fetchone()
             if row:
@@ -340,20 +343,21 @@ def page_lonk(db_con, client_id, lonk_url, honk_url):
 
         if convoy not in lonk_page:
             def _save_convoy(convoy, honker, honk):
+                is_public = 1 if honk.get("Public") else 0
                 row = db_con.execute(
                     """
                     INSERT INTO 
-                        convoy(convoy, client_id, honk_id, honker, url, html, date)
+                        convoy(convoy, client_id, honk_id, honker, url, html, date, public)
                     VALUES 
-                        (?, ?, ?, ?, ?, ?, ?)
+                        (?, ?, ?, ?, ?, ?, ?, ?)
                     RETURNING
                         convoy_id
                     """,
-                    (convoy, client_id, honk["ID"], honker, honk["XID"], honk["HTML"], honk["Date"])
+                    (convoy, client_id, honk["ID"], honker, honk["XID"], honk["HTML"], honk["Date"], is_public)
                 ).fetchone()
                 convoy_id, = row
                 lonk_page[convoy] = _LonkTreeItem(
-                    convoy_id, convoy, honk["ID"], honker, honk["XID"], honk["HTML"], honk["Date"]
+                    convoy_id, convoy, honk["ID"], honker, honk["XID"], honk["HTML"], honk["Date"], is_public
                 )
 
                 for donk in (honk.get("Donks") or []):
@@ -422,6 +426,7 @@ def print_gethonks(gethonks_answer, lonk_url, honk_url
     def _menu():
         print(f"=> {honk_url.build_url(path='newhonk')} new honk\r")
 
+        print(f"=> {lonk_url.build([])} lonk home\r")
         line = f"=> {lonk_url.build('atme')} @me"
         if gethonks_answer["mecount"]:
             line += f' ({gethonks_answer["mecount"]})'
@@ -459,7 +464,8 @@ def print_gethonks(gethonks_answer, lonk_url, honk_url
             if donk_text:
                 lines.append(donk_text)
         lines.append("")
-        lines.append(f'=> {lonk_url.build("bonk", urlencode({"w": honk["XID"]}))} ↺ bonk')
+        if honk.get("Public"):
+            lines.append(f'=> {lonk_url.build("bonk", urlencode({"w": honk["XID"]}))} ↺ bonk')
         lines.append(f'=> {honk_url.build_url(path="newhonk", query=urlencode({"rid": honk["XID"]}))} ↱ honk back')
         print("\r\n".join(lines))
         print("\r")