Skip to content

Group lifecycle

Group can be created, updated, closed (= either archived or deleted) and previewed & restored from archive.

New group

Creating a new group requires setting the following data:

/groups/<groupId>
/members/<groupId>/<memberId>` (initial member based on the user's profile)
/permissions/<groupId>/<uid>` (level set to 30 - owner)
/userGroups/<uid>/<groupId>`
/users/<user_id>/currentTabId` (set to new groupId)

Due to limitation of Firebase Database this can only be done while online.

Edit group

Only the owner can change groups/<groupId> data. Other members can change their group color, which should write to /userGroups/<uid>/<groupId>/color.

Changing group currency is only supported via a server task because it requires iterating over all transactions and updating their exchange rates.

Leave group

Leaving group means deleting from

/userGroups/<uid>/<groupId>
/permissions/<groupId>/<uid>

The owner can't leave a group, they can only close it or transfer the ownership to someone else first.

Transfer ownership

The owner can transfer the ownership, which means updating

/permissions/<groupId>/<my-uid>
/permissions/<groupId>/<their-uid>

Make sure to do it atomically - if you first remove your owner permission you will no longer be able to assign it to the other user.

Archive group

Archived groups are removed from Firebase DB and stored as json files into Storage. This saves space (= money). Users can "hide" groups which they are not actively using, but they don’t want to delete them completely. Who can do what:

  • Archive - the owner at any time, or anyone if debts are settled
  • Restore - the owner
  • Preview - anyone

See server tasks for paths & payloads.

Preview group

Preview should use the same UI as regular preview when joining a group from a link. It only restores the group partially, e.g. permissions are not restored and the first previewing user automatically receives the owner permission.

Preview groups can be identified by their id ending with --temp. These are automatically cleaned up from the database every day, so the apps don't have to worry about cleanup.

Delete group

When a user chooses to delete their group it gets soft-deleted. It is put into archive and an entry is created under /deletedGroups/<groupId>. After 1 month, these groups are deleted permanently.

Automatic archival of old groups

Read more about group auto archival.