chiark / gitweb /
Fix the various 'user's posts' variations.
authorSimon Tatham <anakin@pobox.com>
Fri, 22 Dec 2023 10:18:55 +0000 (10:18 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 22 Dec 2023 10:18:55 +0000 (10:18 +0000)
By generalising the True/False -> true/false mapping across all
booleans submitted as request parameters.

client.py

index b1bd560cf182f378bd7893da84858a155fadbff9..ea1619a0087531edd260c177b6a61b3efbd8a390 100644 (file)
--- a/client.py
+++ b/client.py
@@ -76,6 +76,11 @@ class Client:
         self.readonly = True
 
     def method_start(self, method, path, base, params, stream, links={}):
+        def transform(value):
+            if isinstance(value, bool):
+                return {False:"false", True:"true"}[value]
+            return value
+        params = {key: transform(value) for key, value in params.items()}
         headers = {}
         if self.bearer_token is not None:
             headers['Authorization'] = 'Bearer ' + self.bearer_token
@@ -254,7 +259,7 @@ class HomeTimelineFeed(IncrementalServerFeed):
 class PublicTimelineFeed(IncrementalServerFeed):
     def __init__(self, client, local):
         super().__init__(client, "timelines/public", {
-            'local': {False:"false", True:"true"}[local]
+            'local': local
         })
 
 class MentionsFeed(IncrementalServerFeed):