public async Task Repository(DateTimeOffset eventDate, RepositoryPayload payload) { var updater = new DataUpdater(_contextFactory, _mapper); switch (payload.Action) { case "created": case "publicized": case "privatized": case "archived": case "unarchived": await updater.UpdateRepositories(eventDate, new[] { payload.Repository }); break; case "deleted": { // Sync contributors on deletion try { // Use the account links before we delete them var repoActor = _grainFactory.GetGrain <IRepositoryActor>(payload.Repository.Id); await repoActor.ForceSyncAllLinkedAccountRepositories(); } catch (InvalidOperationException) { // If the repo has already been deleted it can't be activated. } catch (OrleansException) { // If the repo has already been deleted it can't be activated. } // Now delete await updater.DeleteRepository(payload.Repository.Id); } break; default: throw new NotImplementedException($"Action '{payload.Action}' is not valid for event {nameof(Repository)}."); } // Sync org members on both creation and deletion if (payload.Action == "created" || payload.Action == "deleted") { if (payload.Repository.Owner.Type == GitHubAccountType.Organization) { var orgActor = _grainFactory.GetGrain <IOrganizationActor>(payload.Repository.Owner.Id); orgActor.ForceSyncAllMemberRepositories().LogFailure(); // Best effort only } } await updater.Changes.Submit(_queueClient); }