Skip to content

Commit 2b76efd

Browse files
Add Host name to getCoasterSession for Guests
1 parent ec0d0a9 commit 2b76efd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/controller/Sessions.controller.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,24 @@ import { connect } from '../config/config';
77
import { Coasters } from '../entity/Coasters';
88
import { MusicProviders } from '../entity/MusicProviders';
99
import { Session } from '../entity/Session';
10+
import { Users } from '../entity/Users';
1011

1112
exports.getCoasterSessionForGuest = (coasterId) => {
1213
return new Promise(async (resolve, reject) => {
1314
try {
1415
const connection = await connect();
1516
const coasterRepo = connection.getRepository(Coasters);
1617
const sessionRepo = connection.getRepository(Session);
18+
const usersRepo = connection.getRepository(Users);
1719

1820
const coaster = await coasterRepo.findOne({ where: { coasterId } });
1921
if(coaster?.userId == undefined || null) reject({ message: "There coaster does not have a host.", status: 403, code: "COASTER_NO_HOST" });
2022
const session = await sessionRepo.findOne({ where: { userId: coaster.userId } }) || reject({ message: "No active session", status: 403 });
23+
const host = await usersRepo.findOne({ where: { userId: coaster.userId }});
2124

22-
resolve({ coaster, session });
25+
const hostName = host.displayName;
26+
27+
resolve({ coaster, session, hostName });
2328

2429
} catch (error) {
2530
console.error(error)

0 commit comments

Comments
 (0)