Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic member exclusion flow #65

Merged
merged 40 commits into from
Mar 22, 2023
Merged

Basic member exclusion flow #65

merged 40 commits into from
Mar 22, 2023

Conversation

Powersource
Copy link
Collaborator

@Powersource Powersource commented Feb 22, 2023

Starting to implement https://github.com/ssbc/ssb-group-exclusion-spec

  • Publish init msg on new epoch.
  • Test that messages are published like they should
  • Message sharing new key to existing members should be add-member message
  • Message announcing exclude should follow exclude spec
  • Init epoch tangle on root. Moved here Update group/init schema #73
  • Make sure we ourselves can post on the new key
  • clarify errors
  • Update readme
  • create says "NOTE: If create finds an empty (i.e. seemingly unused) group feed, it will start using that feed instead of creating a new one.". I think we might run into that situation the way the new feedKeys options work.
  • check that create's recovery search for "add-member" messages works

index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
@Powersource
Copy link
Collaborator Author

ssbc/ssb-box2#27

@Powersource
Copy link
Collaborator Author

Updating to the new box2 here #67

@Powersource
Copy link
Collaborator Author

Moving spec checking to a new issue #68

index.js Outdated Show resolved Hide resolved
@Powersource
Copy link
Collaborator Author

Made issue about updating members tangle logic #69

@Powersource
Copy link
Collaborator Author

Issue for looping member re-addition #70

@Powersource Powersource marked this pull request as ready for review March 20, 2023 09:30
@Powersource Powersource requested review from staltz, mixmix and arj03 March 20, 2023 09:31
@mixmix
Copy link
Member

mixmix commented Mar 20, 2023

I'm reviewing this now

Copy link
Member

@mixmix mixmix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really great. There's a lot of detail here and you're handling it well 👌

The change I'm keen to see is in testing the behavior around Bob post exclusion. Critically - can they read or post to the new group. This is the foundational definition of "excluded" IMO

Comment on lines 49 to 53
} = await alice.tribes2.create().catch((err) => {
console.error('alice failed to create group', err)
t.fail(err)
})
t.pass('alice created a group')
Copy link
Member

@mixmix mixmix Mar 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your test says "pass" regardless of if it did, which could confuse people debugging tests. I think the following suggestion is more clear (and less lines)

Suggested change
} = await alice.tribes2.create().catch((err) => {
console.error('alice failed to create group', err)
t.fail(err)
})
t.pass('alice created a group')
} = await alice.tribes2.create()
.then(res => t.pass('alice created a group') && res)
.catch(err => t.error(err, 'alice created a group'))

your fail/ catch case will also cause a bad failure because it will return undefined which will then fail to be destructured 🤷 (don't care about that that much)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t.error(err, msg)

  • if there is no err prints: ":heavy_check_mark: msg"
  • if the is an err prints: ":x: msg"
    • i can't remember if it logs the error details, but you only really need that when debugging I guess

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was just copy pasted from some other test. since it's better tested in other places i should maybe just remove it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried the && res thing but didn't work (i guess pass() returns undefined) so just removed the pass lines. cleaned up the console statements though

test/exclude-members.test.js Outdated Show resolved Hide resolved

t.equal(reinviteMsg.type, 'group/add-member')
t.deepEqual(reinviteMsg.recps, [groupId, aliceRoot.id])
// TODO: check members tangle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for #69

test/exclude-members.test.js Outdated Show resolved Hide resolved
const post = secondContents[1]

t.equal(post.text, 'post', 'found post on second feed')

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 we need to test more of Bob's experience, specifically:

  1. confirm he sees the exclude dumping him
  2. confirm he can no longer publish to the group using ssb.tribes2.publish after exclude

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was gonna save that for this #71

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I support doing this in a separate PR to avoid "PR constipation".

index.js Outdated Show resolved Hide resolved
index.js Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
index.js Outdated
publishAndPrune(
ssb,
content,
opts?.feedKeys ?? groupFeed.keys,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🌶️ (not a bug but semi-dangerous) the fact that you have getFeed which pivots functionality, then also this line which also has to pivot correctly for things to work makes this feel really brittle to me.

I would request change to any of these

  • code duplication (have the two cases clearly seperated)
  • a function getFeedKeys which calls back with the keys that are used in this line
  • a warning comment
Suggested change
opts?.feedKeys ?? groupFeed.keys,
opts?.feedKeys ?? groupFeed.keys,
// WARNING: this line is tightly coupled to getFeed logic

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make the same change in addMembers

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

went with passing the keys through the cb

index.js Outdated Show resolved Hide resolved
@Powersource Powersource requested a review from mixmix March 21, 2023 18:51
Copy link
Member

@staltz staltz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, this looks good. I just have README suggestions, the implementation and the tests look 100% in my opinion.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
test/exclude-members.test.js Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Copy link
Member

@staltz staltz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Goodness

@Powersource Powersource merged commit db66745 into master Mar 22, 2023
@Powersource Powersource deleted the exclude-member branch March 22, 2023 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants