Skip to content

[#424] implement `unsubscribe`

aguestuser requested to merge 424-sc-unsubscribe-account into main

Closes #424 (closed) Closes #425 (closed)

context

  • we are slowly but surely bringing signalc up to feature parity with signald (for the subset of features needed by signalboost)
  • this MR implements the unsubscribe command, and sets us up to play #473 (closed) (in which we will need to unsubscribe from channels as part of gracefully handling restarts)
  • as a bonus: we also make it impossible to subscribe to messages for the same account twice (#425 (closed))

changes

data model:

  • add socket response types for unsubscribe success & failure
  • add new username accessor on requests (to make it easier to call this property on an arbitrary request)

signal layer:

  • modify SignalReceiver#subscribe:
    • add subscription jobs to a concurrent hash map as created (so they can be retrieved later for cancelation)
    • don't create a new subscription if one already exists for a given account
  • add SignalReceiver#unsubscribe:
    • shuts down the signal service message pipe
    • cancels the listening job (with a custom exception to signal to the original subscribe caller that it was intentionally cancelled and not unintentionally disrupted due to -- eg -- a broken connection to the signal server)
    • removes all resources particular to this account from hash map cashes (eg: message sender, message pipe, subscribe job, cipher)
  • modify SignalRecever#rejectUnverified to be more generalizable, and thus suitable for use in both #subscribe and #unsubscribe

socket layer:

  • implement SocketReceiver#unsubscribe: handle subscribe socket requests, forward them to signal layer and signal success/error back to client
  • modify SocketReceiver#subscribe to distinguish a subscribe job cancelled on purpose from one cancelled due to connection disruption and not attempt to resubscribe in the former case

Merge request reports

Loading