-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f3cae6
commit 82333fa
Showing
17 changed files
with
221 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext' | ||
import Notification from 'App/Schemas/Notification' | ||
|
||
export default class NotificationsController { | ||
public async index({ auth }: HttpContextContract) { | ||
const notifications = await Notification.find({ ownerId: auth.user!.id }) | ||
return notifications | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { BasePolicy } from '@ioc:Adonis/Addons/Bouncer' | ||
import User from 'App/Models/User' | ||
import Board from 'App/Models/Board' | ||
|
||
export default class BoardChatPolicy extends BasePolicy { | ||
public async view(user: User, board: Board) { | ||
const exists = await board | ||
.related('players') | ||
.query() | ||
.where('board_players.player_id', user.id) | ||
.first() | ||
if (!!exists || board.masterId === user.id) { | ||
return true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Mongo from '@ioc:CuC/AdonisGoose' | ||
import INotification from 'Contracts/interfaces/INotification' | ||
|
||
const NotificationSchema = new Mongo.Schema<INotification>( | ||
{ | ||
content: { | ||
type: String, | ||
required: true, | ||
}, | ||
ownerId: { | ||
type: Number, | ||
required: true, | ||
}, | ||
sender: { | ||
type: Object, | ||
required: true, | ||
}, | ||
subject: { | ||
type: String, | ||
required: true, | ||
}, | ||
photoUrl: { | ||
type: String, | ||
}, | ||
read: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}, | ||
{ | ||
timestamps: true, | ||
} | ||
) | ||
|
||
export default Mongo.model<INotification>('Notification', NotificationSchema) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Board from 'App/Models/Board' | ||
import { Document } from 'mongoose' | ||
|
||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
export default interface INotification extends Document { | ||
ownerId: number | ||
sender: Board | ||
subject: string | ||
content: string | ||
photoUrl?: string | ||
read: boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,36 @@ | ||
export default () => ({ | ||
notifications: [], | ||
initNavbar(userId) { | ||
this.socket = io('/notification', { query: { id: userId } }) | ||
this.initEvents() | ||
this.getNotifications() | ||
}, | ||
getNotifications() { | ||
fetch('/notifications').then((data) => { | ||
data.json().then((notifications) => { | ||
this.notifications = notifications | ||
}) | ||
}) | ||
}, | ||
toggle() { | ||
this.open = !this.open | ||
}, | ||
toggleNotifications() { | ||
this.showNotifications = !this.showNotifications | ||
}, | ||
open: false, | ||
mobileShow: false, | ||
newNotifications: false, | ||
showNotifications: false, | ||
close() { | ||
this.open = false | ||
}, | ||
handleProfileManagement() { | ||
console.log('ook') | ||
}, | ||
handleMobileArea() { | ||
this.mobileShow = !this.mobileShow | ||
}, | ||
initEvents() { | ||
this.socket.on('notification', (data) => { | ||
this.notifications.push(data) | ||
}) | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.