cabal-club / cabal-client

interface for writing peer-to-peer chat clients
GNU General Public License v3.0
95 stars 14 forks source link

Channel archiving #74

Closed cblgh closed 3 years ago

cblgh commented 3 years ago

This PR adds implements support for channel archiving, enabling people to hide channels from being listed. This can be useful for abuse mitigation as well as handling mistakenly created channels, or cleaning up unused ones.

The system is centered around the subjective moderation system. This means that:

  1. the local user can always archive/restore channels (you are always an admin from your own perspective)
  2. the local user's moderators and admins will have their archiving actions be applied to the local user's view
  3. if rando mcrando archives a channel, it will have no effect for the local user (unless the above applies)
  4. people can still join & talk in archived channels, they will just be hidden from channel listings

Currently implemented commands:

/archives, /archived
    view the list of currently archived channels
/archive <channel name>
    archive <channel name>
/unarchive, /restore <channel name>
    restore <channel name> from the archives

This closes #68 and is related to #16. It is also dependent on merging https://github.com/cabal-club/cabal-core/pull/103.

cblgh commented 3 years ago

dunno why the tests are failing, cabal-core's pass

from cabal-client's ci error above

> cabal-client@6.2.7 test /home/travis/build/cabal-club/cabal-client
> tape test/*.js

TAP version 13
# create a cabal
ok 1 cabal created ok
ok 2 should be equivalent
ok 3 should be equivalent
/home/travis/build/cabal-club/cabal-client/node_modules/leveldown/leveldown.js:119
    throw new Error('cannot call iterator() before open()')
    ^

Error: cannot call iterator() before open()
    at LevelDOWN._iterator (/home/travis/build/cabal-club/cabal-client/node_modules/leveldown/leveldown.js:119:11)
    at LevelDOWN.AbstractLevelDOWN.iterator (/home/travis/build/cabal-club/cabal-client/node_modules/leveldown/node_modules/abstract-leveldown/abstract-leveldown.js:280:15)
    at SubDown._iterator (/home/travis/build/cabal-club/cabal-client/node_modules/subleveldown/leveldown.js:181:47)
    at SubDown.AbstractLevelDOWN.iterator (/home/travis/build/cabal-club/cabal-client/node_modules/abstract-leveldown/abstract-leveldown.js:280:15)
    at new Iterator (/home/travis/build/cabal-club/cabal-client/node_modules/encoding-down/index.js:116:19)
    at DB._iterator (/home/travis/build/cabal-club/cabal-client/node_modules/encoding-down/index.js:102:10)
    at DB.AbstractLevelDOWN.iterator (/home/travis/build/cabal-club/cabal-client/node_modules/abstract-leveldown/abstract-leveldown.js:280:15)
    at LevelUP.readStream.LevelUP.createReadStream (/home/travis/build/cabal-club/cabal-client/node_modules/levelup/lib/levelup.js:318:37)
    at LevelUP.keyStream.LevelUP.createKeyStream (/home/travis/build/cabal-club/cabal-client/node_modules/levelup/lib/levelup.js:323:15)
    at /home/travis/build/cabal-club/cabal-client/node_modules/cabal-core/views/channels.js:44:15

edit: kira helped me debug ^__^ massively refactored CabalDetails._initialize to account for race conditions & only call done when all the callbacks are actually done. Moved the callbacks into their own file in src/initialization-callbacks.js.

cblgh commented 3 years ago

published cabal-client@6.3.0