mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
ff7be7696c
Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com>
48 lines
1.3 KiB
TypeScript
48 lines
1.3 KiB
TypeScript
import { Logger } from '../logger';
|
|
import { IUnleashStores } from '../types/stores';
|
|
import { IUnleashConfig } from '../types/option';
|
|
import User from '../types/user';
|
|
import {
|
|
IUserFeedback,
|
|
IUserFeedbackStore,
|
|
} from '../types/stores/user-feedback-store';
|
|
|
|
export default class UserFeedbackService {
|
|
private userFeedbackStore: IUserFeedbackStore;
|
|
|
|
private logger: Logger;
|
|
|
|
constructor(
|
|
{ userFeedbackStore }: Pick<IUnleashStores, 'userFeedbackStore'>,
|
|
{ getLogger }: Pick<IUnleashConfig, 'getLogger'>,
|
|
) {
|
|
this.userFeedbackStore = userFeedbackStore;
|
|
this.logger = getLogger('services/user-feedback-service.js');
|
|
}
|
|
|
|
async getAllUserFeedback(user: User): Promise<IUserFeedback[]> {
|
|
if (user.isAPI) {
|
|
return [];
|
|
}
|
|
try {
|
|
return await this.userFeedbackStore.getAllUserFeedback(user.id);
|
|
} catch (err) {
|
|
this.logger.error(err);
|
|
return [];
|
|
}
|
|
}
|
|
|
|
async getFeedback(
|
|
user_id: number,
|
|
feedback_id: string,
|
|
): Promise<IUserFeedback> {
|
|
return this.userFeedbackStore.getFeedback(user_id, feedback_id);
|
|
}
|
|
|
|
async updateFeedback(feedback: IUserFeedback): Promise<IUserFeedback> {
|
|
return this.userFeedbackStore.updateFeedback(feedback);
|
|
}
|
|
}
|
|
|
|
module.exports = UserFeedbackService;
|