0.11.15 : add notification and private field on PostRelationship
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "harmony-back",
|
||||
"version": "0.11.14",
|
||||
"version": "0.11.15",
|
||||
"private": true,
|
||||
"description": "A Strapi application",
|
||||
"scripts": {
|
||||
|
||||
45
src/api/notification/content-types/notification/schema.json
Normal file
45
src/api/notification/content-types/notification/schema.json
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"kind": "collectionType",
|
||||
"collectionName": "notifications",
|
||||
"info": {
|
||||
"singularName": "notification",
|
||||
"pluralName": "notifications",
|
||||
"displayName": "Notification"
|
||||
},
|
||||
"options": {
|
||||
"draftAndPublish": false
|
||||
},
|
||||
"pluginOptions": {},
|
||||
"attributes": {
|
||||
"title": {
|
||||
"type": "string"
|
||||
},
|
||||
"message": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"type": "enumeration",
|
||||
"enum": [
|
||||
"info",
|
||||
"success",
|
||||
"warning",
|
||||
"error"
|
||||
]
|
||||
},
|
||||
"target_user": {
|
||||
"type": "relation",
|
||||
"relation": "oneToOne",
|
||||
"target": "plugin::users-permissions.user"
|
||||
},
|
||||
"read": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"source": {
|
||||
"type": "string"
|
||||
},
|
||||
"payload": {
|
||||
"type": "json"
|
||||
}
|
||||
}
|
||||
}
|
||||
7
src/api/notification/controllers/notification.ts
Normal file
7
src/api/notification/controllers/notification.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* notification controller
|
||||
*/
|
||||
|
||||
import { factories } from '@strapi/strapi'
|
||||
|
||||
export default factories.createCoreController('api::notification.notification');
|
||||
7
src/api/notification/routes/notification.ts
Normal file
7
src/api/notification/routes/notification.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* notification router
|
||||
*/
|
||||
|
||||
import { factories } from '@strapi/strapi';
|
||||
|
||||
export default factories.createCoreRouter('api::notification.notification');
|
||||
51
src/api/notification/services/notification.ts
Normal file
51
src/api/notification/services/notification.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
interface NotificationPayload {
|
||||
title: string;
|
||||
message: string;
|
||||
type?: "info" | "success" | "warning" | "error";
|
||||
target_user?: number;
|
||||
source?: string;
|
||||
payload?: Record<string, any>;
|
||||
}
|
||||
|
||||
interface NotificationEntity {
|
||||
id: number;
|
||||
title: string;
|
||||
message: string;
|
||||
type: string;
|
||||
target_user?: number;
|
||||
source?: string;
|
||||
payload?: Record<string, any>;
|
||||
read: boolean;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* notification service
|
||||
*/
|
||||
import { factories } from "@strapi/strapi";
|
||||
|
||||
export default factories.createCoreService(
|
||||
"api::notification.notification",
|
||||
({ strapi }: { strapi }) => ({
|
||||
//Custom service for add notification.
|
||||
async createNotification({
|
||||
title,
|
||||
message,
|
||||
type = "info",
|
||||
target_user,
|
||||
source,
|
||||
payload,
|
||||
}: NotificationPayload): Promise<NotificationEntity> {
|
||||
const data = { title, message, type, target_user, source, payload };
|
||||
|
||||
const notification = await strapi.entityService.create(
|
||||
"api::notification.notification",
|
||||
{ data }
|
||||
);
|
||||
|
||||
strapi.log.info(`🔔 Notification créée: ${title}`);
|
||||
return notification;
|
||||
},
|
||||
})
|
||||
);
|
||||
@@ -47,6 +47,10 @@
|
||||
"relation": "manyToOne",
|
||||
"target": "api::post.post",
|
||||
"inversedBy": "post_ownerships"
|
||||
},
|
||||
"public": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
40
types/generated/contentTypes.d.ts
vendored
40
types/generated/contentTypes.d.ts
vendored
@@ -1176,6 +1176,44 @@ export interface ApiMessageMessage extends Struct.CollectionTypeSchema {
|
||||
};
|
||||
}
|
||||
|
||||
export interface ApiNotificationNotification
|
||||
extends Struct.CollectionTypeSchema {
|
||||
collectionName: 'notifications';
|
||||
info: {
|
||||
displayName: 'Notification';
|
||||
pluralName: 'notifications';
|
||||
singularName: 'notification';
|
||||
};
|
||||
options: {
|
||||
draftAndPublish: false;
|
||||
};
|
||||
attributes: {
|
||||
createdAt: Schema.Attribute.DateTime;
|
||||
createdBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
|
||||
Schema.Attribute.Private;
|
||||
locale: Schema.Attribute.String & Schema.Attribute.Private;
|
||||
localizations: Schema.Attribute.Relation<
|
||||
'oneToMany',
|
||||
'api::notification.notification'
|
||||
> &
|
||||
Schema.Attribute.Private;
|
||||
message: Schema.Attribute.String;
|
||||
payload: Schema.Attribute.JSON;
|
||||
publishedAt: Schema.Attribute.DateTime;
|
||||
read: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo<false>;
|
||||
source: Schema.Attribute.String;
|
||||
target_user: Schema.Attribute.Relation<
|
||||
'oneToOne',
|
||||
'plugin::users-permissions.user'
|
||||
>;
|
||||
title: Schema.Attribute.String;
|
||||
type: Schema.Attribute.Enumeration<['info', 'success', 'warning', 'error']>;
|
||||
updatedAt: Schema.Attribute.DateTime;
|
||||
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
|
||||
Schema.Attribute.Private;
|
||||
};
|
||||
}
|
||||
|
||||
export interface ApiPermissionsTemplatePermissionsTemplate
|
||||
extends Struct.CollectionTypeSchema {
|
||||
collectionName: 'permissions_templates';
|
||||
@@ -1241,6 +1279,7 @@ export interface ApiPostOwnershipPostOwnership
|
||||
Schema.Attribute.Private;
|
||||
metas: Schema.Attribute.JSON;
|
||||
post: Schema.Attribute.Relation<'manyToOne', 'api::post.post'>;
|
||||
public: Schema.Attribute.Boolean & Schema.Attribute.DefaultTo<false>;
|
||||
publishedAt: Schema.Attribute.DateTime;
|
||||
relation: Schema.Attribute.Enumeration<
|
||||
['owner', 'saved', 'hidden', 'link']
|
||||
@@ -1922,6 +1961,7 @@ declare module '@strapi/strapi' {
|
||||
'api::group.group': ApiGroupGroup;
|
||||
'api::invite.invite': ApiInviteInvite;
|
||||
'api::message.message': ApiMessageMessage;
|
||||
'api::notification.notification': ApiNotificationNotification;
|
||||
'api::permissions-template.permissions-template': ApiPermissionsTemplatePermissionsTemplate;
|
||||
'api::post-ownership.post-ownership': ApiPostOwnershipPostOwnership;
|
||||
'api::post.post': ApiPostPost;
|
||||
|
||||
Reference in New Issue
Block a user