mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-25 00:07:47 +01:00
send splash data in the user object
This commit is contained in:
parent
cc516618a1
commit
96f2514fc5
@ -21,6 +21,7 @@ import ApiTokenController from './api-token-controller';
|
||||
import UserAdminController from './user-admin';
|
||||
import EmailController from './email';
|
||||
import UserFeedbackController from './user-feedback-controller';
|
||||
import UserSplashController from './user-splash-controller';
|
||||
import ProjectApi from './project';
|
||||
import { EnvironmentsController } from './environments-controller';
|
||||
|
||||
@ -92,6 +93,10 @@ class AdminApi extends Controller {
|
||||
'/environments',
|
||||
new EnvironmentsController(config, services).router,
|
||||
);
|
||||
this.app.use(
|
||||
'/splash',
|
||||
new UserSplashController(config, services).router,
|
||||
);
|
||||
}
|
||||
|
||||
index(req, res) {
|
||||
|
@ -74,3 +74,4 @@ class UserSplashController extends Controller {
|
||||
}
|
||||
|
||||
module.exports = UserSplashController;
|
||||
export default UserSplashController;
|
@ -7,7 +7,7 @@ import { IUnleashServices } from '../../types/services';
|
||||
import UserService from '../../services/user-service';
|
||||
import SessionService from '../../services/session-service';
|
||||
import UserFeedbackService from '../../services/user-feedback-service';
|
||||
import UserSplashService from 'lib/services/user-splash-service';
|
||||
import UserSplashService from '../../services/user-splash-service';
|
||||
|
||||
interface IChangeUserRequest {
|
||||
password: string;
|
||||
@ -47,6 +47,7 @@ class UserController extends Controller {
|
||||
this.userService = userService;
|
||||
this.sessionService = sessionService;
|
||||
this.userFeedbackService = userFeedbackService;
|
||||
this.userSplashService = userSplashService;
|
||||
|
||||
this.get('/', this.getUser);
|
||||
this.post('/change-password', this.updateUserPass);
|
||||
@ -62,12 +63,14 @@ class UserController extends Controller {
|
||||
const feedback = await this.userFeedbackService.getAllUserFeedback(
|
||||
user,
|
||||
);
|
||||
//const splash = await this.userSplashService.getAllUserSplash(user);
|
||||
const splash = await this.userSplashService.getAllUserSplashs(
|
||||
user,
|
||||
);
|
||||
|
||||
// TODO: remove this line after we remove it from db.
|
||||
delete user.permissions;
|
||||
|
||||
return res.status(200).json({ user, permissions, feedback }).end();
|
||||
return res.status(200).json({ user, permissions, feedback, splash }).end();
|
||||
}
|
||||
|
||||
async updateUserPass(
|
||||
|
@ -20,12 +20,21 @@ export default class UserSplashService {
|
||||
this.logger = getLogger('services/user-splash-service.js');
|
||||
}
|
||||
|
||||
async getAllUserSplash(user: User): Promise<IUserSplash[]> {
|
||||
async getAllUserSplashs(user: User): Promise<Object> {
|
||||
if (user.isAPI) {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
return await this.userSplashStore.getAllUserSplashs(user.id);
|
||||
const splashs = await (
|
||||
await this.userSplashStore.getAllUserSplashs(user.id)
|
||||
).reduce(
|
||||
(splashObject, splash) => ({
|
||||
...splashObject,
|
||||
[splash.splashId]: splash.seen,
|
||||
}),
|
||||
{},
|
||||
);
|
||||
return splashs;
|
||||
} catch (err) {
|
||||
this.logger.error(err);
|
||||
|
||||
|
25
src/test/fixtures/fake-user-splash-store.ts
vendored
25
src/test/fixtures/fake-user-splash-store.ts
vendored
@ -2,7 +2,7 @@ import {
|
||||
IUserSplashKey,
|
||||
IUserSplash,
|
||||
IUserSplashStore,
|
||||
} from 'lib/types/stores/user-splash-store';
|
||||
} from '../../lib/types/stores/user-splash-store'
|
||||
|
||||
export default class FakeUserSplashStore implements IUserSplashStore {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
@ -11,13 +11,13 @@ export default class FakeUserSplashStore implements IUserSplashStore {
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
getSplash(userId: number, splashId: string): Promise<IUserSplash> {
|
||||
return Promise.resolve({ seen: false, userId: 123, splashId: 'env' });
|
||||
getSplash(userId: number, splashId: string): Promise<IUserSplash> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
updateSplash(splash: IUserSplash): Promise<IUserSplash> {
|
||||
return Promise.resolve({ seen: false, userId: 123, splashId: 'env' });
|
||||
updateSplash(splash: IUserSplash): Promise<IUserSplash> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
@ -35,21 +35,6 @@ export default class FakeUserSplashStore implements IUserSplashStore {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
getAllUserFeedback(userId: number): Promise<IUserSplash[]> {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
getFeedback(userId: number, feedbackId: string): Promise<IUserSplash> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
updateFeedback(feedback: IUserSplash): Promise<IUserSplash> {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
delete(key: IUserSplashKey): Promise<void> {
|
||||
return Promise.resolve(undefined);
|
||||
|
Loading…
Reference in New Issue
Block a user