Syncing was originally done on the client because cloud functions didn't exist. When functions launched, I didn't consider moving the logic because I thought it would be too expensive. Upon further consideration, it would probably be cheaper to do syncing on the server for a number of reasons:
We get 5 free GBs of outbound data per month
The app will no longer be erroneously woken up, thus fixing the broken last used timestamp and allowing for additional account cleanup
Multiple devices won't step over each other trying to update teams and writing multiple times to the DB
It's nicer to TBA since we can make a single query and update teams access users
Furthermore, this is better for the client since there won't be wasted bandwidth and app wake-ups.
From an implementation perspective, we query all the teams that haven't been updated in X days and then sync them with TBA. We also add a function that listens to team changes and syncs the team immediately if it's out-of-date.
Syncing was originally done on the client because cloud functions didn't exist. When functions launched, I didn't consider moving the logic because I thought it would be too expensive. Upon further consideration, it would probably be cheaper to do syncing on the server for a number of reasons:
Furthermore, this is better for the client since there won't be wasted bandwidth and app wake-ups.
From an implementation perspective, we query all the teams that haven't been updated in X days and then sync them with TBA. We also add a function that listens to team changes and syncs the team immediately if it's out-of-date.