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 UserAdminController from './user-admin';
|
||||||
import EmailController from './email';
|
import EmailController from './email';
|
||||||
import UserFeedbackController from './user-feedback-controller';
|
import UserFeedbackController from './user-feedback-controller';
|
||||||
|
import UserSplashController from './user-splash-controller';
|
||||||
import ProjectApi from './project';
|
import ProjectApi from './project';
|
||||||
import { EnvironmentsController } from './environments-controller';
|
import { EnvironmentsController } from './environments-controller';
|
||||||
|
|
||||||
@ -92,6 +93,10 @@ class AdminApi extends Controller {
|
|||||||
'/environments',
|
'/environments',
|
||||||
new EnvironmentsController(config, services).router,
|
new EnvironmentsController(config, services).router,
|
||||||
);
|
);
|
||||||
|
this.app.use(
|
||||||
|
'/splash',
|
||||||
|
new UserSplashController(config, services).router,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
index(req, res) {
|
index(req, res) {
|
||||||
|
@ -74,3 +74,4 @@ class UserSplashController extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = UserSplashController;
|
module.exports = UserSplashController;
|
||||||
|
export default UserSplashController;
|
@ -7,7 +7,7 @@ import { IUnleashServices } from '../../types/services';
|
|||||||
import UserService from '../../services/user-service';
|
import UserService from '../../services/user-service';
|
||||||
import SessionService from '../../services/session-service';
|
import SessionService from '../../services/session-service';
|
||||||
import UserFeedbackService from '../../services/user-feedback-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 {
|
interface IChangeUserRequest {
|
||||||
password: string;
|
password: string;
|
||||||
@ -47,6 +47,7 @@ class UserController extends Controller {
|
|||||||
this.userService = userService;
|
this.userService = userService;
|
||||||
this.sessionService = sessionService;
|
this.sessionService = sessionService;
|
||||||
this.userFeedbackService = userFeedbackService;
|
this.userFeedbackService = userFeedbackService;
|
||||||
|
this.userSplashService = userSplashService;
|
||||||
|
|
||||||
this.get('/', this.getUser);
|
this.get('/', this.getUser);
|
||||||
this.post('/change-password', this.updateUserPass);
|
this.post('/change-password', this.updateUserPass);
|
||||||
@ -62,12 +63,14 @@ class UserController extends Controller {
|
|||||||
const feedback = await this.userFeedbackService.getAllUserFeedback(
|
const feedback = await this.userFeedbackService.getAllUserFeedback(
|
||||||
user,
|
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.
|
// TODO: remove this line after we remove it from db.
|
||||||
delete user.permissions;
|
delete user.permissions;
|
||||||
|
|
||||||
return res.status(200).json({ user, permissions, feedback }).end();
|
return res.status(200).json({ user, permissions, feedback, splash }).end();
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateUserPass(
|
async updateUserPass(
|
||||||
|
@ -20,12 +20,21 @@ export default class UserSplashService {
|
|||||||
this.logger = getLogger('services/user-splash-service.js');
|
this.logger = getLogger('services/user-splash-service.js');
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAllUserSplash(user: User): Promise<IUserSplash[]> {
|
async getAllUserSplashs(user: User): Promise<Object> {
|
||||||
if (user.isAPI) {
|
if (user.isAPI) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
try {
|
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) {
|
} catch (err) {
|
||||||
this.logger.error(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,
|
IUserSplashKey,
|
||||||
IUserSplash,
|
IUserSplash,
|
||||||
IUserSplashStore,
|
IUserSplashStore,
|
||||||
} from 'lib/types/stores/user-splash-store';
|
} from '../../lib/types/stores/user-splash-store'
|
||||||
|
|
||||||
export default class FakeUserSplashStore implements IUserSplashStore {
|
export default class FakeUserSplashStore implements IUserSplashStore {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// 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
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
getSplash(userId: number, splashId: string): Promise<IUserSplash> {
|
getSplash(userId: number, splashId: string): Promise<IUserSplash> {
|
||||||
return Promise.resolve({ seen: false, userId: 123, splashId: 'env' });
|
return Promise.resolve(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
updateSplash(splash: IUserSplash): Promise<IUserSplash> {
|
updateSplash(splash: IUserSplash): Promise<IUserSplash> {
|
||||||
return Promise.resolve({ seen: false, userId: 123, splashId: 'env' });
|
return Promise.resolve(undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
@ -35,21 +35,6 @@ export default class FakeUserSplashStore implements IUserSplashStore {
|
|||||||
return Promise.resolve([]);
|
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
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
delete(key: IUserSplashKey): Promise<void> {
|
delete(key: IUserSplashKey): Promise<void> {
|
||||||
return Promise.resolve(undefined);
|
return Promise.resolve(undefined);
|
||||||
|
Loading…
Reference in New Issue
Block a user