nodebb-plugin-simple-contact 1.1.3 → 1.1.5

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/library.js CHANGED
@@ -3,6 +3,7 @@
3
3
  const db = require.main.require('./src/database');
4
4
  const notifications = require.main.require('./src/notifications');
5
5
  const groups = require.main.require('./src/groups');
6
+ const socketIndex = require.main.require('./src/socket.io/index');
6
7
 
7
8
  const ContactPlugin = {};
8
9
 
@@ -57,11 +58,10 @@ async function handleContactSubmission(req, res) {
57
58
 
58
59
  if (adminUids && adminUids.length > 0) {
59
60
  await Promise.all(adminUids.map(async (uid) => {
60
- const userUnreadKey = 'contact:unread_names:' + uid;
61
- const userNid = 'contact:notification:' + uid;
61
+ const userUnreadKey = 'contact:unread_names:' + uid;
62
+ const userNid = 'contact:notification:' + uid;
62
63
 
63
64
  await db.listAppend(userUnreadKey, contactData.fullName);
64
-
65
65
  const myNames = await db.getListRange(userUnreadKey, 0, -1);
66
66
 
67
67
  let notificationTitle = '';
@@ -75,7 +75,7 @@ async function handleContactSubmission(req, res) {
75
75
  type: 'new-contact',
76
76
  bodyShort: notificationTitle,
77
77
  bodyLong: contactData.content,
78
- nid: userNid,
78
+ nid: userNid,
79
79
  path: '/admin/plugins/contact',
80
80
  from: 0
81
81
  });
@@ -100,6 +100,13 @@ async function renderAdminPage(req, res) {
100
100
  await notifications.markRead(userNid, req.uid);
101
101
 
102
102
  await db.delete(userUnreadKey);
103
+
104
+ const unreadCount = await notifications.getUnreadCount(req.uid);
105
+
106
+ socketIndex.in('uid:' + req.uid).emit('event:unread.updateCount', unreadCount);
107
+
108
+ socketIndex.in('uid:' + req.uid).emit('event:notifications.updateCount', unreadCount);
109
+
103
110
  } catch (e) {
104
111
  console.error('Error handling notifications logic', e);
105
112
  }
@@ -153,12 +160,25 @@ async function deleteRequest(req, res) {
153
160
  }
154
161
 
155
162
  ContactPlugin.addNavigation = async function (header) {
156
- header.navigation.push({ route: '/contact', iconClass: 'fa-envelope', text: 'צור קשר' });
163
+ if (header && Array.isArray(header.navigation)) {
164
+ header.navigation.push({
165
+ route: '/contact',
166
+ iconClass: 'fa-envelope',
167
+ text: 'צור קשר',
168
+ title: 'צור קשר'
169
+ });
170
+ }
157
171
  return header;
158
172
  };
159
173
 
160
174
  ContactPlugin.addAdminNavigation = async function (header) {
161
- header.plugins.push({ route: '/plugins/contact', icon: 'fa-envelope', name: 'פניות צור קשר' });
175
+ if (header && Array.isArray(header.plugins)) {
176
+ header.plugins.push({
177
+ route: '/plugins/contact',
178
+ icon: 'fa-envelope',
179
+ name: 'פניות צור קשר'
180
+ });
181
+ }
162
182
  return header;
163
183
  };
164
184
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-simple-contact",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
4
4
  "description": "תוסף טופס צור קשר עם התראות למנהלים וניהול פניות",
5
5
  "main": "library.js",
6
6
  "nbbpm": {
@@ -12,22 +12,22 @@
12
12
 
13
13
  <div class="form-group" style="margin-bottom:16px;">
14
14
  <label for="fullName" style="font-weight:600; display:block; margin-bottom:6px;">שם מלא *</label>
15
- <input type="text" class="form-control text-center" id="fullName" name="fullName" required style="border-radius:10px; padding:10px;">
15
+ <input type="text" class="form-control" id="fullName" name="fullName" required style="border-radius:10px; padding:10px;">
16
16
  </div>
17
17
 
18
18
  <div class="form-group" style="margin-bottom:16px;">
19
19
  <label for="username" style="font-weight:600; display:block; margin-bottom:6px;">שם משתמש בפורום</label>
20
- <input type="text" class="form-control text-center" id="username" name="username" style="border-radius:10px; padding:10px;">
20
+ <input type="text" class="form-control" id="username" name="username" style="border-radius:10px; padding:10px;">
21
21
  </div>
22
22
 
23
23
  <div class="form-group" style="margin-bottom:16px;">
24
24
  <label for="email" style="font-weight:600; display:block; margin-bottom:6px;">כתובת מייל *</label>
25
- <input type="email" class="form-control text-center" id="email" name="email" required style="border-radius:10px; padding:10px;">
25
+ <input type="email" class="form-control" id="email" name="email" required style="border-radius:10px; padding:10px;">
26
26
  </div>
27
27
 
28
28
  <div class="form-group" style="margin-bottom:20px;">
29
29
  <label for="content" style="font-weight:600; display:block; margin-bottom:6px;">תוכן הפנייה *</label>
30
- <textarea class="form-control text-center" id="content" name="content" rows="6" required style="border-radius:10px; padding:10px;"></textarea>
30
+ <textarea class="form-control" id="content" name="content" rows="6" required style="border-radius:10px; padding:10px;"></textarea>
31
31
  </div>
32
32
 
33
33
  <button type="submit" class="btn btn-primary btn-block" id="submit-btn" style="border-radius:22px; font-weight:600; padding:12px; margin-top:10px;">