Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: address multiple issues and refactor role normalization logic #203

Merged
merged 4 commits into from
Sep 14, 2024
Merged
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
1 change: 1 addition & 0 deletions lib/services.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export 'package:mineral/src/infrastructure/internals/cache/cache_provider_contract.dart';
export 'package:mineral/src/infrastructure/internals/environment/env_schema.dart';
export 'package:mineral/src/infrastructure/internals/environment/environment.dart';
export 'package:mineral/src/infrastructure/internals/marshaller/marshaller.dart';
export 'package:mineral/src/infrastructure/services/http/header.dart';
export 'package:mineral/src/infrastructure/services/http/http_client.dart';
export 'package:mineral/src/infrastructure/services/http/http_client_config.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ final class GuildCreatePacket implements ListenablePacket {
Future<void> listen(ShardMessage message, DispatchEvent dispatch) async {
final rawServer =
await marshaller.serializers.server.normalize(message.payload);

final server = await marshaller.serializers.server.serialize(rawServer);

final bot = ioc.resolve<Bot>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class GuildRoleDeletePacket implements ListenablePacket {
final server = await marshaller.dataStore.server
.getServer(message.payload['guild_id']);

final roleId = message.payload['role']['id'];
final roleId = message.payload['role_id'];

final roleCacheKey = marshaller.cacheKey.serverRole(server.id, roleId);
final rawRole = await marshaller.cache.get(roleCacheKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ final class GuildRoleUpdatePacket implements ListenablePacket {
? marshaller.serializers.role.serialize(rawBefore)
: null;

final rawRole =
await marshaller.serializers.role.normalize(message.payload['role']);
final rawRole = await marshaller.serializers.role.normalize({
'server_id': server.id,
...message.payload['role'],
});
final role = await marshaller.serializers.role.serialize(rawRole);

server.roles.list.update(role.id, (_) => role);
Expand Down