@opengis/admin 0.4.36 → 0.4.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{add-page-BbGCyn0k.js → add-page-N0vInKWp.js} +1 -1
- package/dist/{admin-interface-BbtDg4Fy.js → admin-interface-Djf6FADS.js} +1 -1
- package/dist/{admin-view-BT95LpxW.js → admin-view-CADr047o.js} +1 -1
- package/dist/admin.js +1 -1
- package/dist/admin.umd.cjs +24 -24
- package/dist/{card-view-Cwu20O9Z.js → card-view-CvtbWLOk.js} +1 -1
- package/dist/{edit-page-D1ZN9oak.js → edit-page-WH_P3Wte.js} +1 -1
- package/dist/{import-file-CGrExq_X.js → import-file-DxhzJKP_.js} +3020 -3002
- package/dist/{profile-page-Quk3Xc6g.js → profile-page-BEjpnhpW.js} +1 -1
- package/package.json +1 -1
- package/server/routes/notifications/index.mjs +12 -5
- package/server/routes/notifications/controllers/readNotifications.js +0 -18
- package/server/routes/notifications/controllers/userNotifications.js +0 -53
- package/server/routes/notifications/schema.js +0 -23
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as u, f as a } from "./import-file-
|
|
1
|
+
import { _ as u, f as a } from "./import-file-DxhzJKP_.js";
|
|
2
2
|
import "./user-DCzCj0wb.js";
|
|
3
3
|
import { resolveComponent as m, createElementBlock as p, openBlock as c, createElementVNode as r, createTextVNode as d, toDisplayString as b, createBlock as h, createCommentVNode as f } from "vue";
|
|
4
4
|
const g = {
|
package/package.json
CHANGED
|
@@ -2,8 +2,8 @@ import { addHook } from '@opengis/fastify-table/utils.js';
|
|
|
2
2
|
|
|
3
3
|
// api
|
|
4
4
|
import testEmail from './controllers/testEmail.js';
|
|
5
|
-
import readNotifications from './controllers/readNotifications.js'; // mark as read
|
|
6
|
-
import userNotifications from './controllers/userNotifications.js'; // check all, backend pagination
|
|
5
|
+
// import readNotifications from './controllers/readNotifications.js'; // mark as read
|
|
6
|
+
// import userNotifications from './controllers/userNotifications.js'; // check all, backend pagination
|
|
7
7
|
|
|
8
8
|
// hook
|
|
9
9
|
import onWidgetSet from './hook/onWidgetSet.js'; // send notification on comment
|
|
@@ -12,7 +12,14 @@ import onWidgetSet from './hook/onWidgetSet.js'; // send notification on comment
|
|
|
12
12
|
// import addNotification from '../notifications/funcs/addNotification.js'; // add to db
|
|
13
13
|
// import notification from '../notifications/funcs/sendNotification.js'; // send notification
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
const emailSchema = {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
quertstring: {
|
|
19
|
+
to: { type: 'string', pattern: '^((?!\\.)[\\w\\-_.]*[^.])(@\\w+)(\\.\\w+(\\.\\w+)?[^.\\W])$' },
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
16
23
|
|
|
17
24
|
export default async function route(fastify) {
|
|
18
25
|
|
|
@@ -20,7 +27,7 @@ export default async function route(fastify) {
|
|
|
20
27
|
// fastify.decorate('notification', notification);
|
|
21
28
|
|
|
22
29
|
fastify.get('/test-email', { config: { policy: ['user'] }, schema: emailSchema }, testEmail);
|
|
23
|
-
fastify.get('/notification', { config: { policy: ['user'] }, schema: notificationSchema }, userNotifications);
|
|
24
|
-
fastify.get('/notification-read/:id?', { config: { policy: ['user'] }, schema: notificationSchema }, readNotifications);
|
|
30
|
+
// fastify.get('/notification', { config: { policy: ['user'] }, schema: notificationSchema }, userNotifications); // moved to fastify-table
|
|
31
|
+
// fastify.get('/notification-read/:id?', { config: { policy: ['user'] }, schema: notificationSchema }, readNotifications); // moved to fastify-table
|
|
25
32
|
addHook('onWidgetSet', onWidgetSet);
|
|
26
33
|
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export default async function readNotifications({
|
|
2
|
-
pg, params = {}, query = {}, user = {},
|
|
3
|
-
}, reply) {
|
|
4
|
-
const { uid } = user || {};
|
|
5
|
-
|
|
6
|
-
if (!uid) {
|
|
7
|
-
return reply.status(401).send('access restricted: user ');
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const q = `update crm.notifications set read=true where read is not true
|
|
11
|
-
and ${params?.id ? 'notification_id=$2' : '1=1'} and addressee_id=$1`;
|
|
12
|
-
|
|
13
|
-
if (query.sql) return q;
|
|
14
|
-
|
|
15
|
-
const { rowCount = 0 } = await pg.query(q, [uid, params?.id].filter((el) => el));
|
|
16
|
-
|
|
17
|
-
return reply.status(200).send(`${rowCount} unread notifications marked as read`);
|
|
18
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// for example only
|
|
2
|
-
/*
|
|
3
|
-
const res = await dataInsert({
|
|
4
|
-
pg,
|
|
5
|
-
table: 'crm.notifications',
|
|
6
|
-
data: {
|
|
7
|
-
subject: 'notif title',
|
|
8
|
-
body: 'notif body',
|
|
9
|
-
link: 'http://localhost:3000/api/notification',
|
|
10
|
-
addressee_id: userId,
|
|
11
|
-
author_id: userId,
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import { getSelectVal } from '@opengis/fastify-table/utils.js';
|
|
17
|
-
|
|
18
|
-
const maxLimit = 100;
|
|
19
|
-
|
|
20
|
-
export default async function userNotifications({
|
|
21
|
-
pg, query = {}, user = {},
|
|
22
|
-
}) {
|
|
23
|
-
const time = Date.now();
|
|
24
|
-
|
|
25
|
-
const { uid } = user || {};
|
|
26
|
-
|
|
27
|
-
if (!uid) {
|
|
28
|
-
return { message: 'access restricted', status: 403 };
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const limit = Math.min(maxLimit, +(query.limit || 5));
|
|
32
|
-
const offset = query.page && query.page > 0 ? (query.page - 1) * limit : 0;
|
|
33
|
-
|
|
34
|
-
const q = `select notification_id as id, subject, body, cdate,
|
|
35
|
-
author_id, read, link, entity_id, (select avatar from admin.users where uid=a.author_id limit 1) as avatar from crm.notifications a where addressee_id=$1 order by cdate desc limit $2 offset $3`;
|
|
36
|
-
|
|
37
|
-
if (query.sql) return q;
|
|
38
|
-
|
|
39
|
-
const { rows = [] } = pg.pk?.['crm.notifications'] ? await pg.query(q, [uid, limit, offset]) : {};
|
|
40
|
-
|
|
41
|
-
const values = rows.map((el) => el.author_id)
|
|
42
|
-
?.filter((el, idx, arr) => el && arr.indexOf(el) === idx);
|
|
43
|
-
|
|
44
|
-
if (values?.length) {
|
|
45
|
-
const vals = await getSelectVal({ name: 'core.user_mentioned', values });
|
|
46
|
-
rows.forEach((row) => {
|
|
47
|
-
Object.assign(row, { author: vals?.[row.author_id] });
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return { time: Date.now() - time, total: rows?.length, rows };
|
|
52
|
-
|
|
53
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const notificationSchema = {
|
|
2
|
-
type: 'object',
|
|
3
|
-
properties: {
|
|
4
|
-
params: {
|
|
5
|
-
id: { type: 'string', pattern: '^([\\d\\w]+)$' },
|
|
6
|
-
},
|
|
7
|
-
querystring: {
|
|
8
|
-
nocache: { type: 'string', pattern: '^(\\d+)$' },
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const emailSchema = {
|
|
14
|
-
type: 'object',
|
|
15
|
-
properties: {
|
|
16
|
-
quertstring: {
|
|
17
|
-
to: { type: 'string', pattern: '^((?!\\.)[\\w\\-_.]*[^.])(@\\w+)(\\.\\w+(\\.\\w+)?[^.\\W])$' },
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default null;
|
|
23
|
-
export { notificationSchema, emailSchema }
|