Skip to content

Commit

Permalink
Unsubscribe by attributes should only match a subset of subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Jan 9, 2025
1 parent 87cd2c0 commit c06c363
Showing 1 changed file with 48 additions and 7 deletions.
55 changes: 48 additions & 7 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2054,21 +2054,47 @@ The [=remote end steps=] with |session| and |command parameters| are:

1. Let |new subscriptions| to be a [=/list=].

1. Let |match| be false.

1. For each |subscription| of |session|'s [=subscriptions=]:

1. If |match| is true:

1. [=list/append=] |subscription| to |new subscriptions|.

1. [=Continue=].

1. If [=set/intersection=] of |subscription|'s [=subscription/event names=] and |event names| is an empty [=/set=]:

1. [=list/append=] |subscription| to |new subscriptions|.

1. Continue.
1. [=Continue=].

1. If |top-level traversable context ids| is an empty [=/set=]:

1. [=list/Remove=] all items [=list/contains|contained=] in |event names| from |subscription|'s [=subscription/event names=].
1. If |subscription|'s [=subscription/top-level traversable ids=] [=set/size=] is not zero:

1. If |subscription|'s [=subscription/event names=] is not empty:
1. [=list/append=] |subscription| to |new subscriptions|.

1. [=list/append=] |subscription| to |new subscriptions|.
1. [=Continue=].

1. Let |subscription event names| be [=set/clone=] of |subscription|'s [=subscription/event names=].

1. For each |event name| of |event names|:

1. If |subscription event names| [=set/contains=] |event name|:

1. [=list/Remove=] |event name| from |event names|.

1. [=list/Remove=] |event name| from |subscription event names|.

1. If |event names| [=set/size=] is zero, set |match| to true.

1. If |subscription event names| is not empty:

1. Set |subscription|'s [=subscription/event names=] to |subscription event names|.

1. [=list/append=] |subscription| to |new subscriptions|.

1. Otherwise:

Expand All @@ -2086,18 +2112,29 @@ The [=remote end steps=] with |session| and |command parameters| are:

1. Set |event map|[|event name|] to [=set/clone=] of |subscription|'s [=subscription/top-level traversable ids=].

1. Let |context ids to remove| be an empty [=/set=].

1. For each |event name| in |event names|:

1. If |event map|[|event name|] does not exist,
continue.
[=continue=].

1. For each |top-level traversable id| of |top-level traversable context ids|:

1. If |event map|[|event name|] [=set/contains=] |top-level traversable id|:

1. Set |event map|[|event name|] to the [=set/difference=]
between |event map|[|event name|] and |top-level traversable context ids|.
1. [=list/Append=] |top-level traversable id| to |context ids to remove|.

1. [=list/Remove=] |top-level traversable id| from |event map|[|event name|].

1. If |event map|[|event name|] is an empty [=/set=],

1. [=map/Remove=] |event map|[|event name|].

1. For each |top-level traversable id| of |context ids to remove|:

1. [=list/Remove=] |top-level traversable id| from |top-level traversable context ids|.

1. For each |event name| → |remaining top-level traversable ids| in |event map|:

1. Let |partial subscription| be a [=subscription=] with
Expand All @@ -2107,6 +2144,10 @@ The [=remote end steps=] with |session| and |command parameters| are:

1. [=list/append=] |partial subscription| to |new subscriptions|.

1. If |top-level traversable context ids| is empty, set |match| to true.

1. If |match| is false, return [=error=] with [=error code=] [=invalid argument=].

1. Set |session|'s [=subscriptions=] to |new subscriptions|.

1. Otherwise:
Expand Down

0 comments on commit c06c363

Please sign in to comment.