nodebb-plugin-simple-contact 2.0.0 → 2.0.2

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.
Files changed (2) hide show
  1. package/library.js +32 -4
  2. package/package.json +1 -1
package/library.js CHANGED
@@ -219,14 +219,42 @@ async function markAsHandled(req, res) {
219
219
  async function deleteRequest(req, res) {
220
220
  try { await db.delete('contact-request:' + req.body.id); await db.sortedSetRemove('contact-requests:sorted', req.body.id); res.json({ success: true }); } catch (err) { res.status(500).json({ error: err.message }); }
221
221
  }
222
+
222
223
  async function replyToContact(req, res) {
223
224
  const { email, subject, content, original_id } = req.body;
224
- if (!email || !content) return res.status(400).json({ error: 'חסרים נתונים לשליחה' });
225
+
226
+ if (!email || !content) {
227
+ return res.status(400).json({ error: 'חסרים נתונים לשליחה' });
228
+ }
229
+
225
230
  try {
226
- await emailer.sendToEmail('banned', email, 'he', { subject: subject || 'תשובה', username: email, message: content.replace(/\n/g, '<br>'), body: content.replace(/\n/g, '<br>') });
227
- if (original_id) await db.setObjectField('contact-request:' + original_id, 'handled', true);
231
+ const htmlContent = content.replace(/\n/g, '<br>');
232
+
233
+ await emailer.sendToEmail('notification', email, 'he', {
234
+ subject: subject || 'תשובה לפנייתך בצור קשר',
235
+ username: email,
236
+
237
+ notification: {
238
+ type: 'contact-reply',
239
+ bodyShort: subject || 'תשובה לפנייה',
240
+ bodyLong: htmlContent,
241
+ path: '/'
242
+ },
243
+
244
+ body: htmlContent,
245
+ message: htmlContent,
246
+ intro: 'קיבלת תשובה חדשה לפנייתך:'
247
+ });
248
+
249
+ if (original_id) {
250
+ await db.setObjectField('contact-request:' + original_id, 'handled', true);
251
+ }
252
+
228
253
  res.json({ success: true });
229
- } catch (err) { res.status(500).json({ error: err.message }); }
254
+ } catch (err) {
255
+ console.error(err);
256
+ res.status(500).json({ error: 'שגיאה בשליחת המייל: ' + err.message });
257
+ }
230
258
  }
231
259
 
232
260
  ContactPlugin.addNavigation = async function (header) { if (header && Array.isArray(header.navigation)) { header.navigation.push({ route: '/contact', iconClass: 'fa-envelope', text: 'צור קשר', title: 'צור קשר' }); } return header; };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-simple-contact",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "תוסף טופס צור קשר עם התראות למנהלים וניהול פניות",
5
5
  "main": "library.js",
6
6
  "nbbpm": {