RFC: Improve Team model
As the case in xpub's reviewers has shown, there's a need to store more information about members of teams. In the case of reviewers, this is e.g. what their status is, have they received an email, etc.
This is metadata that's important to store sensibly, currently xpub stores this in reviewers
properties on collections and fragments, but semantically, reviewers are best represented as members of a team. Having them as team members also reduces the friction when writing authsome/authorization modes.
My suggestion is that core's Team model gets a new property membersMetadata
, an object that contains team-related information about specific members. The Team model should also manage this property, e.g. if a user is no longer a member of a team, remove the associated memberMetadata
, etc.
Team {
id
teamType: 'reviewers'
object: { type: 'fragment', id: 'someId' }
members: [ids of reviewers]
membersMetadata: {
reviewer1Id: { status: 'invited', email: 'sent' }
reviewer2Id: { status: 'declined' }
reviewer3Id: { status: 'accepted' }
}
}
Storing this in teams also means that we can have some reusable (cross-app) helpers in our authsome modes, for example isActiveReviewer
, where this goes and checks if there is a team, around this object, that the user is a member of, where team.membersMetadata[reviewerId].status === acccepted
.