Fix typescript errors

develop
trivernis 5 years ago
parent ab25ae1703
commit f465a4aa2e

@ -84,7 +84,7 @@ export class Event extends Model<Event> {
public async deletable({userId}: { userId: number }, request: any): Promise<boolean> { public async deletable({userId}: { userId: number }, request: any): Promise<boolean> {
userId = userId ?? request.session.userId; userId = userId ?? request.session.userId;
if (userId) { if (userId) {
const group = await this.$get<Group>("rGroup") as Group; const group = await this.$get("rGroup") as Group;
const user = await User.findByPk(userId); const user = await User.findByPk(userId);
return (await group.$has("rAdmins", user)) || user.isAdmin; return (await group.$has("rAdmins", user)) || user.isAdmin;
} else { } else {

@ -93,7 +93,7 @@ export class Group extends Model<Group> {
* Returns the media url of the group which is the profile picture * Returns the media url of the group which is the profile picture
*/ */
public async picture(): Promise<string> { public async picture(): Promise<string> {
const media = await this.$get<Media>("rMedia") as Media; const media = await this.$get("rMedia") as Media;
return media ? media.url : undefined; return media ? media.url : undefined;
} }

@ -149,7 +149,7 @@ export class Post extends Model<Post> {
* Returns the media description object of the post * Returns the media description object of the post
*/ */
public async media() { public async media() {
return await this.$get<Media>("rMedia") as Media; return await this.$get("rMedia") as Media;
} }
/** /**

@ -267,7 +267,7 @@ export class User extends Model<User> {
* Returns the media url which is the profile picture * Returns the media url which is the profile picture
*/ */
public async profilePicture(): Promise<string> { public async profilePicture(): Promise<string> {
const media = await this.$get<Media>("rMedia") as Media; const media = await this.$get("rMedia") as Media;
return media ? media.url : undefined; return media ? media.url : undefined;
} }

@ -40,7 +40,7 @@ class HomeRoute extends Route {
} }
}); });
globals.internalEmitter.on(InternalEvents.REQUESTCREATE, async (request: Request) => { globals.internalEmitter.on(InternalEvents.REQUESTCREATE, async (request: Request) => {
if ((await request.$get("sender") as User).id === socket.handshake.session.userId) { if ((await request.$get("rSender") as User).id === socket.handshake.session.userId) {
socket.emit("request", request); socket.emit("request", request);
} }
}); });
@ -92,7 +92,7 @@ class HomeRoute extends Route {
} }
}); });
globals.internalEmitter.on(InternalEvents.GQLCHATMESSAGE, async (message: ChatMessage) => { globals.internalEmitter.on(InternalEvents.GQLCHATMESSAGE, async (message: ChatMessage) => {
if ((await message.$get("chat") as ChatRoom).id === chatId) { if ((await message.$get("rChat") as ChatRoom).id === chatId) {
socket.emit("chatMessage", Object.assign(message, {htmlContent: message.htmlContent})); socket.emit("chatMessage", Object.assign(message, {htmlContent: message.htmlContent}));
} }
}); });

Loading…
Cancel
Save