This commit is contained in:
2025-12-14 18:11:59 +01:00
parent acc15e8d8d
commit 217337862c
91 changed files with 5919 additions and 1999 deletions

View File

@@ -1,4 +1,5 @@
import type { AsyncUseCase } from '@gridpilot/shared/application';
import type { ILogger } from '../../../shared/src/logging/ILogger';
import type { ISocialGraphRepository } from '../../domain/repositories/ISocialGraphRepository';
import type { CurrentUserSocialDTO } from '../dto/CurrentUserSocialDTO';
import type { FriendDTO } from '../dto/FriendDTO';
@@ -22,33 +23,46 @@ export class GetCurrentUserSocialUseCase
constructor(
private readonly socialGraphRepository: ISocialGraphRepository,
public readonly presenter: ICurrentUserSocialPresenter,
private readonly logger: ILogger,
) {}
async execute(params: GetCurrentUserSocialParams): Promise<void> {
const { driverId } = params;
this.logger.debug('GetCurrentUserSocialUseCase: Starting execution', { params });
try {
const { driverId } = params;
const friendsDomain = await this.socialGraphRepository.getFriends(driverId);
this.logger.debug(`GetCurrentUserSocialUseCase: Fetching friends for driverId: ${driverId}`);
const friendsDomain = await this.socialGraphRepository.getFriends(driverId);
this.logger.debug('GetCurrentUserSocialUseCase: Successfully fetched friends from social graph repository', { friendsCount: friendsDomain.length });
if (friendsDomain.length === 0) {
this.logger.warn(`GetCurrentUserSocialUseCase: No friends found for driverId: ${driverId}`);
}
const friends: FriendDTO[] = friendsDomain.map((friend) => ({
driverId: friend.id,
displayName: friend.name,
avatarUrl: '',
isOnline: false,
lastSeen: new Date(),
}));
const friends: FriendDTO[] = friendsDomain.map((friend) => ({
driverId: friend.id,
displayName: friend.name,
avatarUrl: '',
isOnline: false,
lastSeen: new Date(),
}));
const currentUser: CurrentUserSocialDTO = {
driverId,
displayName: '',
avatarUrl: '',
countryCode: '',
};
const currentUser: CurrentUserSocialDTO = {
driverId,
displayName: '',
avatarUrl: '',
countryCode: '',
};
const viewModel: CurrentUserSocialViewModel = {
currentUser,
friends,
};
const viewModel: CurrentUserSocialViewModel = {
currentUser,
friends,
};
this.presenter.present(viewModel);
this.presenter.present(viewModel);
this.logger.info('GetCurrentUserSocialUseCase: Successfully presented current user social data');
} catch (error) {
this.logger.error('GetCurrentUserSocialUseCase: Error during execution', { error });
throw error;
}
}
}