nodebb-plugin-facebook-post 1.0.25 → 1.0.28
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 +5 -1
- package/package.json +1 -1
- package/static/lib/composer.js +8 -7
package/library.js
CHANGED
|
@@ -295,6 +295,7 @@ Plugin.init = async function (params) {
|
|
|
295
295
|
});
|
|
296
296
|
|
|
297
297
|
router.get('/api/facebook-post/search-place', middleware.ensureLoggedIn, async (req, res) => {
|
|
298
|
+
const winston = require.main.require('winston');
|
|
298
299
|
res.set('Cache-Control', 'no-store');
|
|
299
300
|
try {
|
|
300
301
|
await loadSettings();
|
|
@@ -316,13 +317,16 @@ Plugin.init = async function (params) {
|
|
|
316
317
|
}
|
|
317
318
|
);
|
|
318
319
|
const data = (resp.data && resp.data.data) || [];
|
|
320
|
+
winston.info(`[facebook-post] search-place: q="${q}" → ${data.length} résultat(s)`);
|
|
319
321
|
const results = data.map(p => ({
|
|
320
322
|
id: p.id,
|
|
321
323
|
name: p.name,
|
|
322
324
|
city: (p.location && (p.location.city || p.location.country)) || '',
|
|
323
325
|
}));
|
|
324
326
|
return res.json({ results });
|
|
325
|
-
} catch {
|
|
327
|
+
} catch (e) {
|
|
328
|
+
const detail = e?.response?.data ? JSON.stringify(e.response.data) : e?.message;
|
|
329
|
+
winston.warn(`[facebook-post] search-place erreur: ${detail}`);
|
|
326
330
|
return res.json({ results: [] });
|
|
327
331
|
}
|
|
328
332
|
});
|
package/package.json
CHANGED
package/static/lib/composer.js
CHANGED
|
@@ -112,17 +112,18 @@
|
|
|
112
112
|
if ($results.children().length) $results.show();
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
// NodeBB 4.x fires 'action:composer.submit' with { composerData } (the object
|
|
116
|
+
// sent to the socket). Modifying composerData by reference is enough.
|
|
117
|
+
$(window).off('action:composer.submit.fbpost')
|
|
118
|
+
.on('action:composer.submit.fbpost', function (ev2, data) {
|
|
117
119
|
const enabled = $enabled.is(':checked');
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
120
|
+
const postData = (data && data.composerData) || (data && data.postData) || data;
|
|
121
|
+
if (!postData || typeof postData !== 'object') return;
|
|
122
|
+
postData.fbPostEnabled = enabled;
|
|
121
123
|
if (enabled) {
|
|
122
124
|
const placeId = $composer.find('[data-fbpost-place-id]').val();
|
|
123
|
-
if (placeId)
|
|
125
|
+
if (placeId) postData.fbPlaceId = placeId;
|
|
124
126
|
}
|
|
125
|
-
return submitData;
|
|
126
127
|
});
|
|
127
128
|
}
|
|
128
129
|
|