pub async fn remove_member(
pool: &PgPool,
actor: &Actor,
project_id: Uuid,
user_id: Uuid,
) -> AppResult<i64>Expand description
Removes a member (managers and admins; everybody may leave a group). A manager cannot leave while no other active manager remains – an admin can still remove them. Returns how many check-outs the user still holds in the group.
§Invariants
- Permission: the group is visible to the actor (“not found” otherwise); removing someone else needs a manager (or an administrator; 403), leaving needs nothing more.
- Locks: the group row (
FOR UPDATE), so membership changes of one group are serialised. - Data: a manager cannot be removed (nor leave) when no other active manager remains, except by an administrator (409); a membership synchronised from the identity provider cannot be removed here while its user is active (409) – a deactivated user’s can, since SSO refuses them and it cannot come back; a non-member is “not found”. Check-outs of the removed user are kept and only counted.
- Audit:
project.remove_member. - Notifications / webhooks: none.
- Atomic: one transaction.