2025-05-10 02:09:06 +02:00
|
|
|
/*!
|
|
|
|
|
* Copyright (c) 2024 PLANKA Software GmbH
|
|
|
|
|
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
|
|
|
|
*/
|
|
|
|
|
|
2019-08-31 04:07:25 +05:00
|
|
|
/**
|
|
|
|
|
* Notification.js
|
|
|
|
|
*
|
|
|
|
|
* @description :: A model definition represents a database table/collection.
|
|
|
|
|
* @docs :: https://sailsjs.com/docs/concepts/models-and-orm/models
|
|
|
|
|
*/
|
|
|
|
|
|
2025-09-08 16:20:27 +02:00
|
|
|
/**
|
|
|
|
|
* @swagger
|
|
|
|
|
* components:
|
|
|
|
|
* schemas:
|
|
|
|
|
* Notification:
|
|
|
|
|
* type: object
|
|
|
|
|
* required:
|
|
|
|
|
* - id
|
|
|
|
|
* - userId
|
2025-09-12 12:17:01 +02:00
|
|
|
* - creatorUserId
|
2025-09-08 16:20:27 +02:00
|
|
|
* - boardId
|
|
|
|
|
* - cardId
|
2025-09-12 12:17:01 +02:00
|
|
|
* - commentId
|
|
|
|
|
* - actionId
|
2025-09-08 16:20:27 +02:00
|
|
|
* - type
|
|
|
|
|
* - data
|
|
|
|
|
* - isRead
|
2025-09-12 12:17:01 +02:00
|
|
|
* - createdAt
|
|
|
|
|
* - updatedAt
|
2025-09-08 16:20:27 +02:00
|
|
|
* properties:
|
|
|
|
|
* id:
|
|
|
|
|
* type: string
|
|
|
|
|
* description: Unique identifier for the notification
|
2025-09-08 19:14:31 +02:00
|
|
|
* example: "1357158568008091264"
|
2025-09-08 16:20:27 +02:00
|
|
|
* userId:
|
|
|
|
|
* type: string
|
|
|
|
|
* description: ID of the user who receives the notification
|
2025-09-08 19:14:31 +02:00
|
|
|
* example: "1357158568008091265"
|
2025-09-08 16:20:27 +02:00
|
|
|
* creatorUserId:
|
|
|
|
|
* type: string
|
|
|
|
|
* nullable: true
|
|
|
|
|
* description: ID of the user who created the notification
|
2025-09-08 19:14:31 +02:00
|
|
|
* example: "1357158568008091266"
|
2025-09-08 16:20:27 +02:00
|
|
|
* boardId:
|
|
|
|
|
* type: string
|
|
|
|
|
* description: ID of the board associated with the notification (denormalized)
|
2025-09-08 19:14:31 +02:00
|
|
|
* example: "1357158568008091267"
|
2025-09-08 16:20:27 +02:00
|
|
|
* cardId:
|
|
|
|
|
* type: string
|
|
|
|
|
* description: ID of the card associated with the notification
|
2025-09-08 19:14:31 +02:00
|
|
|
* example: "1357158568008091268"
|
2025-09-08 16:20:27 +02:00
|
|
|
* commentId:
|
|
|
|
|
* type: string
|
|
|
|
|
* nullable: true
|
|
|
|
|
* description: ID of the comment associated with the notification
|
2025-09-08 19:14:31 +02:00
|
|
|
* example: "1357158568008091269"
|
2025-09-08 16:20:27 +02:00
|
|
|
* actionId:
|
|
|
|
|
* type: string
|
|
|
|
|
* nullable: true
|
|
|
|
|
* description: ID of the action associated with the notification
|
2025-09-08 19:14:31 +02:00
|
|
|
* example: "1357158568008091270"
|
2025-09-08 16:20:27 +02:00
|
|
|
* type:
|
|
|
|
|
* type: string
|
|
|
|
|
* enum: [moveCard, commentCard, addMemberToCard, mentionInComment]
|
|
|
|
|
* description: Type of the notification
|
|
|
|
|
* example: commentCard
|
|
|
|
|
* data:
|
|
|
|
|
* type: object
|
2025-09-12 12:17:01 +02:00
|
|
|
* description: Notification specific data (varies by type)
|
2025-09-08 16:20:27 +02:00
|
|
|
* example: {"card": {"name": "Implement user authentication"}, "text": "This task is almost complete..."}
|
|
|
|
|
* isRead:
|
|
|
|
|
* type: boolean
|
2025-09-12 12:17:01 +02:00
|
|
|
* default: false
|
2025-09-08 16:20:27 +02:00
|
|
|
* description: Whether the notification has been read
|
|
|
|
|
* example: false
|
|
|
|
|
* createdAt:
|
|
|
|
|
* type: string
|
|
|
|
|
* format: date-time
|
|
|
|
|
* nullable: true
|
|
|
|
|
* description: When the notification was created
|
|
|
|
|
* example: 2024-01-01T00:00:00.000Z
|
|
|
|
|
* updatedAt:
|
|
|
|
|
* type: string
|
|
|
|
|
* format: date-time
|
|
|
|
|
* nullable: true
|
|
|
|
|
* description: When the notification was last updated
|
|
|
|
|
* example: 2024-01-01T00:00:00.000Z
|
|
|
|
|
*/
|
|
|
|
|
|
2025-05-10 02:09:06 +02:00
|
|
|
const Types = {
|
|
|
|
|
MOVE_CARD: 'moveCard',
|
|
|
|
|
COMMENT_CARD: 'commentCard',
|
2025-05-17 01:50:40 +02:00
|
|
|
ADD_MEMBER_TO_CARD: 'addMemberToCard',
|
2025-05-30 22:01:29 +02:00
|
|
|
MENTION_IN_COMMENT: 'mentionInComment',
|
2025-05-10 02:09:06 +02:00
|
|
|
};
|
|
|
|
|
|
2019-08-31 04:07:25 +05:00
|
|
|
module.exports = {
|
2025-05-10 02:09:06 +02:00
|
|
|
Types,
|
|
|
|
|
|
2019-08-31 04:07:25 +05:00
|
|
|
attributes: {
|
|
|
|
|
// ╔═╗╦═╗╦╔╦╗╦╔╦╗╦╦ ╦╔═╗╔═╗
|
|
|
|
|
// ╠═╝╠╦╝║║║║║ ║ ║╚╗╔╝║╣ ╚═╗
|
|
|
|
|
// ╩ ╩╚═╩╩ ╩╩ ╩ ╩ ╚╝ ╚═╝╚═╝
|
|
|
|
|
|
2025-05-10 02:09:06 +02:00
|
|
|
type: {
|
|
|
|
|
type: 'string',
|
|
|
|
|
isIn: Object.values(Types),
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
|
|
|
|
data: {
|
|
|
|
|
type: 'json',
|
|
|
|
|
required: true,
|
|
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
isRead: {
|
|
|
|
|
type: 'boolean',
|
|
|
|
|
defaultsTo: false,
|
2019-11-05 18:01:42 +05:00
|
|
|
columnName: 'is_read',
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
|
|
|
|
|
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
|
|
|
|
|
// ╚═╝╩ ╩╚═╝╚═╝═╩╝╚═╝
|
|
|
|
|
|
|
|
|
|
// ╔═╗╔═╗╔═╗╔═╗╔═╗╦╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
|
|
|
|
|
// ╠═╣╚═╗╚═╗║ ║║ ║╠═╣ ║ ║║ ║║║║╚═╗
|
|
|
|
|
// ╩ ╩╚═╝╚═╝╚═╝╚═╝╩╩ ╩ ╩ ╩╚═╝╝╚╝╚═╝
|
|
|
|
|
|
|
|
|
|
userId: {
|
|
|
|
|
model: 'User',
|
|
|
|
|
required: true,
|
2019-11-05 18:01:42 +05:00
|
|
|
columnName: 'user_id',
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
2025-05-10 02:09:06 +02:00
|
|
|
creatorUserId: {
|
|
|
|
|
model: 'User',
|
|
|
|
|
columnName: 'creator_user_id',
|
|
|
|
|
},
|
|
|
|
|
// Denormalization
|
|
|
|
|
boardId: {
|
|
|
|
|
model: 'Board',
|
2019-08-31 04:07:25 +05:00
|
|
|
required: true,
|
2025-05-10 02:09:06 +02:00
|
|
|
columnName: 'board_id',
|
2019-08-31 04:07:25 +05:00
|
|
|
},
|
|
|
|
|
cardId: {
|
|
|
|
|
model: 'Card',
|
|
|
|
|
required: true,
|
2019-11-05 18:01:42 +05:00
|
|
|
columnName: 'card_id',
|
|
|
|
|
},
|
2025-05-10 02:09:06 +02:00
|
|
|
commentId: {
|
|
|
|
|
model: 'Comment',
|
|
|
|
|
columnName: 'comment_id',
|
|
|
|
|
},
|
|
|
|
|
actionId: {
|
|
|
|
|
model: 'Action',
|
|
|
|
|
columnName: 'action_id',
|
|
|
|
|
},
|
2019-11-05 18:01:42 +05:00
|
|
|
},
|
2019-08-31 04:07:25 +05:00
|
|
|
};
|