From 5e67fe81aa34f6ae3ca76a7dbafd02d681ac4f39 Mon Sep 17 00:00:00 2001
From: Martin Lees <drov0@users.noreply.github.com>
Date: Tue, 25 Mar 2025 15:03:08 -0400
Subject: [PATCH 1/3] Set community settings to JSONB

---
 hive/db/schema.py                                              | 3 ++-
 .../postgrest/bridge_api/bridge_api_get_community.sql          | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/hive/db/schema.py b/hive/db/schema.py
index 1923ef279..a872d6bee 100644
--- a/hive/db/schema.py
+++ b/hive/db/schema.py
@@ -4,6 +4,7 @@ import logging
 from pathlib import Path
 
 import sqlalchemy as sa
+from sqlalchemy.dialects.postgresql import JSONB
 from sqlalchemy.sql import text as sql_text
 from sqlalchemy.types import BOOLEAN
 from sqlalchemy.types import CHAR
@@ -346,7 +347,7 @@ def build_metadata_community(metadata=None):
         sa.Column('avatar_url', sa.String(1024), nullable=False, server_default=''),
         sa.Column('description', sa.String(5000), nullable=False, server_default=''),
         sa.Column('flag_text', sa.String(5000), nullable=False, server_default=''),
-        sa.Column('settings', TEXT, nullable=False, server_default='{}'),
+        sa.Column('settings', JSONB, nullable=False, server_default='{}'),
         sa.Column('block_num', sa.Integer, nullable=False),
         sa.UniqueConstraint('name', name='hive_communities_ux1'),
         sa.Index('hive_communities_ix1', 'rank', 'id'),
diff --git a/hive/db/sql_scripts/postgrest/bridge_api/bridge_api_get_community.sql b/hive/db/sql_scripts/postgrest/bridge_api/bridge_api_get_community.sql
index 31dc88b4c..c7dde3632 100644
--- a/hive/db/sql_scripts/postgrest/bridge_api/bridge_api_get_community.sql
+++ b/hive/db/sql_scripts/postgrest/bridge_api/bridge_api_get_community.sql
@@ -43,7 +43,7 @@ BEGIN
         hc.avatar_url,
         hc.description,
         hc.flag_text,
-        hc.settings::JSONB,
+        hc.settings,
         (
           CASE
             WHEN _observer_id <> 0 THEN hivemind_postgrest_utilities.get_community_context(_observer_id, _community_id)
-- 
GitLab


From 05002d01d1717c29929f2e70f6b399dad8e19e84 Mon Sep 17 00:00:00 2001
From: Martin Lees <drov0@users.noreply.github.com>
Date: Tue, 25 Mar 2025 17:47:36 -0400
Subject: [PATCH 2/3] update tests to include settings tests + avatar_url

---
 .../block_data/community_op/mock_block_data_community.json      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mock_data/block_data/community_op/mock_block_data_community.json b/mock_data/block_data/community_op/mock_block_data_community.json
index f2ce048e0..ed6857cbb 100644
--- a/mock_data/block_data/community_op/mock_block_data_community.json
+++ b/mock_data/block_data/community_op/mock_block_data_community.json
@@ -716,7 +716,7 @@
                 "test-safari"
               ],
               "id": "community",
-              "json": "[\"updateProps\",{\"community\":\"hive-135485\",\"props\":{\"title\":\"World News\",\"about\":\"A place for major news from around the world.\",\"is_nsfw\":true,\"description\":\"\",\"flag_text\":\"\"}}]"
+              "json": "[\"updateProps\",{\"community\":\"hive-135485\",\"props\":{\"title\":\"World News\",\"about\":\"A place for major news from around the world.\",\"is_nsfw\":true,\"description\":\"\",\"flag_text\":\"\",\"settings\":{\"streams\":[[\"Say It Here\",\"0\",[\"member\"],[\"member\"]],[\"About\",\"\\/about\",null,null],[\"Visit Community\",\"\\/created\",null,null]],\"emotes\":{},\"avatar_url\":\"http://example.com\"}}}]"
             }
           },
           {
-- 
GitLab


From a503d4331d69bc6317e659622f72944a0acc4398 Mon Sep 17 00:00:00 2001
From: Martin Lees <drov0@users.noreply.github.com>
Date: Wed, 26 Mar 2025 12:38:53 -0400
Subject: [PATCH 3/3] fix tests

---
 .../get_community/hive-135485.pat.json        | 35 ++++++++++++++++---
 .../list_communities/empty_last.pat.json      |  4 +--
 .../list_communities/max_limit.pat.json       |  4 +--
 .../list_communities/max_limit_new.pat.json   |  4 +--
 .../list_communities/max_limit_rank.pat.json  |  4 +--
 .../list_communities/max_limit_subs.pat.json  |  4 +--
 .../list_communities/no_parameters.pat.json   |  4 +--
 .../list_communities/one.pat.json             |  6 ++--
 .../list_communities/query_major.pat.json     |  6 ++--
 9 files changed, 49 insertions(+), 22 deletions(-)

diff --git a/tests/api_tests/hivemind/tavern/bridge_api_patterns/get_community/hive-135485.pat.json b/tests/api_tests/hivemind/tavern/bridge_api_patterns/get_community/hive-135485.pat.json
index 02f736c7d..c75d9dd77 100644
--- a/tests/api_tests/hivemind/tavern/bridge_api_patterns/get_community/hive-135485.pat.json
+++ b/tests/api_tests/hivemind/tavern/bridge_api_patterns/get_community/hive-135485.pat.json
@@ -1,17 +1,44 @@
 {
   "about": "A place for major news from around the world.",
-  "avatar_url": "",
+  "avatar_url": "http://example.com",
   "context": {},
   "created_at": "2016-09-15 18:01:30",
   "description": "",
   "flag_text": "",
-  "id": 92457,
+  "id": 92458,
   "is_nsfw": true,
   "lang": "en",
   "name": "hive-135485",
   "num_authors": 5,
   "num_pending": 28,
-  "settings": {},
+  "settings": {
+    "avatar_url": "http://example.com",
+    "emotes": {},
+    "streams": [
+      [
+        "Say It Here",
+        "0",
+        [
+          "member"
+        ],
+        [
+          "member"
+        ]
+      ],
+      [
+        "About",
+        "/about",
+        null,
+        null
+      ],
+      [
+        "Visit Community",
+        "/created",
+        null,
+        null
+      ]
+    ]
+  },
   "subscribers": 4,
   "sum_pending": 0,
   "team": [
@@ -33,4 +60,4 @@
   ],
   "title": "World News",
   "type_id": 1
-}
+}
\ No newline at end of file
diff --git a/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/empty_last.pat.json b/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/empty_last.pat.json
index 516b56a4e..8303b94ee 100644
--- a/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/empty_last.pat.json
+++ b/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/empty_last.pat.json
@@ -5,7 +5,7 @@
       "blocktrades",
       "test-safari"
     ],
-    "avatar_url": "",
+    "avatar_url": "http://example.com",
     "context": {},
     "created_at": "2016-09-15 18:01:30",
     "id": 92458,
@@ -241,4 +241,4 @@
     "title": "@hive-103459",
     "type_id": 1
   }
-]
+]
\ No newline at end of file
diff --git a/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/max_limit.pat.json b/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/max_limit.pat.json
index 516b56a4e..8303b94ee 100644
--- a/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/max_limit.pat.json
+++ b/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/max_limit.pat.json
@@ -5,7 +5,7 @@
       "blocktrades",
       "test-safari"
     ],
-    "avatar_url": "",
+    "avatar_url": "http://example.com",
     "context": {},
     "created_at": "2016-09-15 18:01:30",
     "id": 92458,
@@ -241,4 +241,4 @@
     "title": "@hive-103459",
     "type_id": 1
   }
-]
+]
\ No newline at end of file
diff --git a/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/max_limit_new.pat.json b/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/max_limit_new.pat.json
index a4246b5db..a48f383cb 100644
--- a/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/max_limit_new.pat.json
+++ b/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/max_limit_new.pat.json
@@ -253,7 +253,7 @@
       "blocktrades",
       "test-safari"
     ],
-    "avatar_url": "",
+    "avatar_url": "http://example.com",
     "context": {},
     "created_at": "2016-09-15 18:01:30",
     "id": 92458,
@@ -305,4 +305,4 @@
     "title": "Banana",
     "type_id": 1
   }
-]
+]
\ No newline at end of file
diff --git a/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/max_limit_rank.pat.json b/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/max_limit_rank.pat.json
index 516b56a4e..8303b94ee 100644
--- a/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/max_limit_rank.pat.json
+++ b/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/max_limit_rank.pat.json
@@ -5,7 +5,7 @@
       "blocktrades",
       "test-safari"
     ],
-    "avatar_url": "",
+    "avatar_url": "http://example.com",
     "context": {},
     "created_at": "2016-09-15 18:01:30",
     "id": 92458,
@@ -241,4 +241,4 @@
     "title": "@hive-103459",
     "type_id": 1
   }
-]
+]
\ No newline at end of file
diff --git a/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/max_limit_subs.pat.json b/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/max_limit_subs.pat.json
index 81a7fca52..cb85f23f8 100644
--- a/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/max_limit_subs.pat.json
+++ b/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/max_limit_subs.pat.json
@@ -56,7 +56,7 @@
       "blocktrades",
       "test-safari"
     ],
-    "avatar_url": "",
+    "avatar_url": "http://example.com",
     "context": {},
     "created_at": "2016-09-15 18:01:30",
     "id": 92458,
@@ -305,4 +305,4 @@
     "title": "@hive-103459",
     "type_id": 1
   }
-]
+]
\ No newline at end of file
diff --git a/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/no_parameters.pat.json b/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/no_parameters.pat.json
index 516b56a4e..8303b94ee 100644
--- a/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/no_parameters.pat.json
+++ b/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/no_parameters.pat.json
@@ -5,7 +5,7 @@
       "blocktrades",
       "test-safari"
     ],
-    "avatar_url": "",
+    "avatar_url": "http://example.com",
     "context": {},
     "created_at": "2016-09-15 18:01:30",
     "id": 92458,
@@ -241,4 +241,4 @@
     "title": "@hive-103459",
     "type_id": 1
   }
-]
+]
\ No newline at end of file
diff --git a/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/one.pat.json b/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/one.pat.json
index 896b65ae5..a7dc7d8f6 100644
--- a/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/one.pat.json
+++ b/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/one.pat.json
@@ -5,10 +5,10 @@
       "blocktrades",
       "test-safari"
     ],
-    "avatar_url": "",
+    "avatar_url": "http://example.com",
     "context": {},
     "created_at": "2016-09-15 18:01:30",
-    "id": 92457,
+    "id": 92458,
     "is_nsfw": true,
     "lang": "en",
     "name": "hive-135485",
@@ -19,4 +19,4 @@
     "title": "World News",
     "type_id": 1
   }
-]
+]
\ No newline at end of file
diff --git a/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/query_major.pat.json b/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/query_major.pat.json
index 896b65ae5..a7dc7d8f6 100644
--- a/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/query_major.pat.json
+++ b/tests/api_tests/hivemind/tavern/bridge_api_patterns/list_communities/query_major.pat.json
@@ -5,10 +5,10 @@
       "blocktrades",
       "test-safari"
     ],
-    "avatar_url": "",
+    "avatar_url": "http://example.com",
     "context": {},
     "created_at": "2016-09-15 18:01:30",
-    "id": 92457,
+    "id": 92458,
     "is_nsfw": true,
     "lang": "en",
     "name": "hive-135485",
@@ -19,4 +19,4 @@
     "title": "World News",
     "type_id": 1
   }
-]
+]
\ No newline at end of file
-- 
GitLab