Commit Diff


commit - c8840e5830575e3de3bd404314314298b6dc26ec
commit + a0cb657e5a71361f57f2ddd8fafadec12dd800fb
blob - 4d100c52dbb7449684f02167309fa1de91a4fd54
blob + e88c537ebddf4ea8b45cb2ebf2574f87155859f3
--- lonk.py
+++ lonk.py
@@ -413,10 +413,11 @@ def page_lonk(db_con, client_id, lonk_url, honk_url):
     gethonks_answer = honk_url.get("gethonks", page="home")
 
     lonk_page = {}
+    convoy_map = {}
     for honk in reversed(gethonks_answer.pop("honks", None) or []):
-        convoy = honk["Convoy"]
+        convoy = convoy_map.get(honk["Convoy"], honk["Convoy"])
 
-        if convoy not in lonk_page:
+        def _select_convoy_from_db(convoy):
             row = db_con.execute(
                 """
                 SELECT
@@ -444,6 +445,9 @@ def page_lonk(db_con, client_id, lonk_url, honk_url):
                         lonk_page[convoy].donks.append((donk_url, donk_mime, donk_text))
 
         if convoy not in lonk_page:
+            _select_convoy_from_db(convoy)
+
+        if convoy not in lonk_page:
             def _save_convoy(convoy, honk):
                 is_public = 1 if honk.get("Public") else 0
                 row = db_con.execute(
@@ -470,8 +474,14 @@ def page_lonk(db_con, client_id, lonk_url, honk_url):
 
             if honk.get("RID"):
                 for honk_in_convoy in honk_url.get("gethonks", page="convoy", c=convoy)["honks"]:
-                    if not honk_in_convoy.get("RID"):
-                        _save_convoy(convoy, honk_in_convoy)
+                    if honk_in_convoy["What"] == "honked":
+                        if convoy != honk_in_convoy["Convoy"]:
+                            convoy_map[convoy] = honk_in_convoy["Convoy"]
+                            convoy = honk_in_convoy["Convoy"]
+                            if convoy not in lonk_page:
+                                _select_convoy_from_db(convoy)
+                        if convoy not in lonk_page:
+                            _save_convoy(convoy, honk_in_convoy)
                         break
                 else:
                     _save_convoy(convoy, {"ID": None, "Handle": None, "XID": None, "HTML": None, "Date": None, "Handles": None})