nodebb-plugin-phone-verification 1.2.2 → 1.2.4

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 (3) hide show
  1. package/library.js +45 -10
  2. package/package.json +1 -1
  3. package/plugin.json +1 -1
package/library.js CHANGED
@@ -76,7 +76,7 @@ plugin.checkPostingPermissions = async function (data) {
76
76
  if (!phoneData || !phoneData.phoneVerified) {
77
77
  const userSlug = await User.getUserField(uid, 'userslug');
78
78
  const editUrl = userSlug ? `/user/${userSlug}/edit` : '/user/me/edit';
79
- throw new Error('חובה לאמת מספר טלפון כדי להמשיך את הפעילות בפורום.<br/>אנא גש להגדרות הפרופיל שלך.');
79
+ throw new Error(`חובה לאמת מספר טלפון כדי להמשיך את הפעילות בפורום.<br/>אנא גש ל<a href="${editUrl}">הגדרות הפרופיל שלך</a>.`);
80
80
  }
81
81
  return data;
82
82
  };
@@ -93,35 +93,70 @@ plugin.checkVotingPermissions = async function (data) {
93
93
 
94
94
  const phoneData = await plugin.getUserPhone(uid);
95
95
  if (!phoneData || !phoneData.phoneVerified) {
96
- throw new Error('חובה לאמת מספר טלפון כדי להמשיך את הפעילות בפורום.<br/>אנא גש להגדרות הפרופיל שלך.');
96
+ const userSlug = await User.getUserField(uid, 'userslug');
97
+ const editUrl = userSlug ? `/user/${userSlug}/edit` : '/user/me/edit';
98
+ throw new Error(`חובה לאמת מספר טלפון כדי להמשיך את הפעילות בפורום.<br/>אנא גש ל<a href="${editUrl}">הגדרות הפרופיל שלך</a>.`);
97
99
  }
98
100
  return data;
99
101
  };
100
102
 
101
103
  plugin.checkMessagingPermissions = async function (data) {
102
- const uid = data.fromUid;
104
+ // --- תיקון: בדיקת כל הווריאציות האפשריות (כולל fromuid באותיות קטנות) ---
105
+ const uid = data.fromuid || data.fromUid || data.uid;
106
+
107
+ // לוג לבדיקה שזה עובד עכשיו
108
+ // console.log(`[Phone-Verify] Checking message from UID: ${uid}`);
109
+
110
+ // אם עדיין לא מצאנו מזהה משתמש, מחזירים את המידע כמו שהוא
103
111
  if (!uid || parseInt(uid, 10) === 0) return data;
112
+
104
113
  const settings = await plugin.getSettings();
114
+ // אם ההגדרות כבויות - משחררים
105
115
  if (!settings.blockUnverifiedUsers) return data;
116
+
117
+ // מנהלים מורשים תמיד
106
118
  const isAdmin = await User.isAdministrator(uid);
107
119
  if (isAdmin) return data;
120
+
121
+ // משתמשים מאומתים מורשים תמיד
108
122
  const phoneData = await plugin.getUserPhone(uid);
109
123
  if (phoneData && phoneData.phoneVerified) {
110
124
  return data;
111
125
  }
126
+
127
+ // --- המשתמש לא מאומת -> בדיקת שאר המשתתפים ---
128
+
112
129
  const Messaging = require.main.require('./src/messaging');
130
+
131
+ // וידוא שיש לנו roomId
132
+ if (!data.roomId) return data;
133
+
134
+ // שליפת המשתתפים בחדר
113
135
  const roomUids = await Messaging.getUidsInRoom(data.roomId, 0, -1);
136
+
137
+ // סינון השולח עצמו
114
138
  const targetUids = roomUids.filter(id => parseInt(id, 10) !== parseInt(uid, 10));
115
- let isChattingWithAdmin = false;
139
+
140
+ // הכנת הקישור לפרופיל
141
+ const userSlug = await User.getUserField(uid, 'userslug');
142
+ const editUrl = userSlug ? `/user/${userSlug}/edit` : '/user/me/edit';
143
+ const errorMsg = `חובה לאמת מספר טלפון כדי לשלוח הודעות.<br/>אנא גש ל<a href="${editUrl}">הגדרות הפרופיל שלך</a>.`;
144
+
145
+ // אם אין אף אחד אחר בשיחה (מדבר לעצמו) - חוסמים
146
+ if (targetUids.length === 0) {
147
+ throw new Error(errorMsg);
148
+ }
149
+
150
+ // בדיקה שכל המשתתפים האחרים הם מנהלים
116
151
  for (const targetUid of targetUids) {
117
- const targetIsAdmin = await User.isAdministrator(targetUid);
118
- if (targetIsAdmin) {
119
- isChattingWithAdmin = true;
120
- break;
152
+ const isTargetAdmin = await User.isAdministrator(targetUid);
153
+ // אם נמצא אפילו משתתף אחד שאינו מנהל -> חסימה
154
+ if (!isTargetAdmin) {
155
+ throw new Error(errorMsg);
121
156
  }
122
157
  }
123
- if (isChattingWithAdmin) return data;
124
- throw new Error('חובה לאמת מספר טלפון כדי להמשיך את הפעילות בפורום.<br/>אנא גש להגדרות הפרופיל שלך.');
158
+
159
+ return data;
125
160
  };
126
161
 
127
162
  // ==================== שליחת שיחה קולית ====================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-phone-verification",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "אימות מספר טלפון נייד בתהליך ההרשמה לפורום NodeBB",
5
5
  "main": "library.js",
6
6
  "repository": {
package/plugin.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "nodebb-plugin-phone-verification",
3
3
  "name": "Phone Verification",
4
4
  "description": "אימות מספר טלפון נייד בתהליך ההרשמה לפורום ובפרופיל המשתמש",
5
- "version": "1.2.2",
5
+ "version": "1.2.3",
6
6
  "library": "./library.js",
7
7
  "hooks": [
8
8
  { "hook": "filter:register.check", "method": "checkRegistration" },