model block/mute/... created/removed as bounded changes
1 files changed, 25 insertions(+), 12 deletions(-)

M wispwot/server.w
M wispwot/server.w +25 -12
@@ 580,25 580,38 @@ define : handle-webhook-event wotstate e
         define ownid : assoc-ref json-object "account_id"
         define trustee : assoc-ref json-object "target_account_id"
         define : +-max-0 increment trust
-            min 0
-                + increment trust
-        let ;; FIXME: something wrong.
+            min 0 : + increment trust
+        define : +-min-0 increment trust
+            max 0 : + increment trust
+        define : +-min-inc increment trust
+            max increment : + increment trust
+        define : +-max-inc increment trust
+            min increment : + increment trust
+        let
             : ownid : id->string ownid
               trustee : id->string trustee
             define previous-trust
               get-trust-edge wotstate ownid trustee
+            ;; giving trust below 0 gives a ceiling for the trust to
+            ;; set to ensure that the ID disappears on block or mute.
+
+            ;; giving trust above 0 gives a floor for the trust to
+            ;; set, to ensure that the ID becomes visible.
+            
+            ;; removing any of these, does not cross the
+            ;; zero-boundary, so a node which gets unblocked does not
+            ;; get advocated without being followed afterwards, and a
+            ;; node which gets unfollowed does not get reported.
             define trust
               cond
-                (equal? event "block.created") -50
-                (equal? event "follow.created") 30
-                (equal? event "mute.created") -1
-                (equal? event "block.removed") 0
-                (equal? event "follow.removed") 0
-                (equal? event "mute.removed") 0
+                (equal? event "block.created") : +-max-inc -50 previous-trust
+                (equal? event "follow.created") : +-min-inc 30 previous-trust
+                (equal? event "mute.created") : +-max-inc -1 previous-trust
+                (equal? event "block.removed") : +-max-0 50 previous-trust
+                (equal? event "follow.removed") : +-min-0 -30 previous-trust
+                (equal? event "mute.removed") : +-max-0 1 previous-trust
                 else previous-trust
-            if trust
-              add-trust-edge! wotstate ownid trustee trust
-              
+            add-trust-edge! wotstate ownid trustee trust
             update-wotcache-from-wotstate! wotstate ownid
             . event