Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
358 changes: 184 additions & 174 deletions Valour/Sdk/Nodes/Node.cs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions Valour/Server/Services/AutomodService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public async Task<TaskResult<AutomodTrigger>> CreateTriggerAsync(AutomodTrigger
// Invalidate cache
_triggerCache.TryRemove(trigger.PlanetId, out _);

_coreHub.NotifyPlanetItemChange(trigger);
_coreHub.NotifyPlanetItemCreate(trigger);
return new(true, "Success", trigger);
}

Expand Down Expand Up @@ -131,9 +131,9 @@ public async Task<TaskResult<AutomodTrigger>> CreateTriggerWithActionsAsync(Auto
_triggerCache.TryRemove(trigger.PlanetId, out _);
_actionCache.TryRemove(trigger.Id, out _);

_coreHub.NotifyPlanetItemChange(trigger);
_coreHub.NotifyPlanetItemCreate(trigger);
foreach (var action in actions)
_coreHub.NotifyPlanetItemChange(action.PlanetId, action);
_coreHub.NotifyPlanetItemCreate(action.PlanetId, action);

return new(true, "Success", trigger);
}
Expand Down Expand Up @@ -220,7 +220,7 @@ public async Task<TaskResult<AutomodAction>> CreateActionAsync(AutomodAction act
// Invalidate cache
_actionCache.TryRemove(action.TriggerId, out _);

_coreHub.NotifyPlanetItemChange(action.PlanetId, action);
_coreHub.NotifyPlanetItemCreate(action.PlanetId, action);
return new(true, "Success", action);
}

Expand Down
4 changes: 2 additions & 2 deletions Valour/Server/Services/ChannelService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,10 @@ public async Task<TaskResult<Channel>> CreateAsync(Channel channel, List<Permiss
if (associatedChatChannel is not null)
{
hostedPlanet.UpsertChannel(associatedChatChannel);
_coreHub.NotifyPlanetItemChange(channel.PlanetId!.Value, associatedChatChannel);
_coreHub.NotifyPlanetItemCreate(channel.PlanetId!.Value, associatedChatChannel);
}
await _planetPermissionService.HandleChannelTopologyChange(channel.PlanetId!.Value);
_coreHub.NotifyPlanetItemChange(channel.PlanetId!.Value, channel);
_coreHub.NotifyPlanetItemCreate(channel.PlanetId!.Value, channel);
}

return TaskResult<Channel>.FromData(channel);
Expand Down
6 changes: 6 additions & 0 deletions Valour/Server/Services/CoreHubService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,15 @@ public void NotifyVoiceSessionReplace(long userId, VoiceSessionReplaceEvent upda
public void NotifyVoiceChannelParticipants(long planetId, VoiceChannelParticipantsUpdate update) =>
_ = _hub.Clients.Group($"p-{planetId}").SendAsync("Voice-Channel-Participants", update);

public void NotifyPlanetItemCreate<T>(long planetId, T model, int flags = 0) =>
_ = _hub.Clients.Group($"p-{planetId}").SendAsync($"{typeof(T).Name}-Create", model, flags);

public void NotifyPlanetItemChange<T>(long planetId, T model, int flags = 0) =>
_ = _hub.Clients.Group($"p-{planetId}").SendAsync($"{typeof(T).Name}-Update", model, flags);

public async void NotifyPlanetItemCreate<T>(T model, int flags = 0) where T : ISharedPlanetModel =>
await _hub.Clients.Group($"p-{model.PlanetId}").SendAsync($"{typeof(T).Name}-Create", model, flags);

public async void NotifyPlanetItemChange<T>(T model, int flags = 0) where T : ISharedPlanetModel =>
await _hub.Clients.Group($"p-{model.PlanetId}").SendAsync($"{typeof(T).Name}-Update", model, flags);

Expand Down
2 changes: 1 addition & 1 deletion Valour/Server/Services/PlanetBanService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public async Task<TaskResult<PlanetBan>> CreateAsync(
await tran.CommitAsync();

// Notify of changes
_coreHub.NotifyPlanetItemChange(ban);
_coreHub.NotifyPlanetItemCreate(ban);
_coreHub.NotifyPlanetItemDelete(target);

var actorUserId = source == ModerationActionSource.Automod
Expand Down
4 changes: 2 additions & 2 deletions Valour/Server/Services/PlanetEmojiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public async Task<TaskResult<PlanetEmoji>> CreateAsync(
hosted.UpsertEmoji(model);

if (notify)
_coreHub.NotifyPlanetItemChange(model);
_coreHub.NotifyPlanetItemCreate(model);

return TaskResult<PlanetEmoji>.FromData(model);
}
Expand Down Expand Up @@ -122,7 +122,7 @@ public async Task<TaskResult> DeleteAsync(long planetId, long emojiId, bool noti

public void NotifyCreated(PlanetEmoji emoji)
{
_coreHub.NotifyPlanetItemChange(emoji);
_coreHub.NotifyPlanetItemCreate(emoji);
}

public async Task<bool> AreAllIdsValidForPlanetAsync(long planetId, IEnumerable<long> ids)
Expand Down
2 changes: 1 addition & 1 deletion Valour/Server/Services/PlanetInviteService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task<TaskResult<PlanetInvite>> CreateAsync(PlanetInvite invite, Pla
return new(false, e.Message);
}

_coreHub.NotifyPlanetItemChange(invite);
_coreHub.NotifyPlanetItemCreate(invite);

return new(true, "Success", invite);
}
Expand Down
3 changes: 2 additions & 1 deletion Valour/Server/Services/PlanetMemberService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ public async Task<TaskResult<PlanetMember>> AddMemberAsync(long planetId, long u

var model = member.ToModel();

_coreHub.NotifyPlanetItemChange(model);
// Notify subscribers that an item has been created (Member added)
_coreHub.NotifyPlanetItemCreate(model);

await _automodService.HandleMemberJoinAsync(model);

Expand Down
2 changes: 1 addition & 1 deletion Valour/Server/Services/PlanetRoleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public async Task<TaskResult<PlanetRole>> CreateAsync(PlanetRole role)
}

hostedPlanet.UpsertRole(role);
_coreHub.NotifyPlanetItemChange(role);
_coreHub.NotifyPlanetItemCreate(role);

// If we bumped the default role, update cache and notify clients
if (defaultRoleUpdated)
Expand Down