nodebb-plugin-facebook-post 1.0.23 → 1.0.25

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
@@ -167,7 +167,7 @@ function shouldProcessPost(ctx) {
167
167
  if (!settings.enabled) return false;
168
168
  if (!settings.fbPageId || !settings.fbPageAccessToken) return false;
169
169
 
170
- const isFirstPost = (ctx.post.isMainPost === true) || (ctx.post.index === 0);
170
+ const isFirstPost = (ctx.post.isMainPost === true) || (ctx.post.index === 0) || (String(ctx.post.pid) === String(ctx.topic.mainPid));
171
171
  if (!isFirstPost) return false;
172
172
 
173
173
  if (!bool(ctx.post.fbPostEnabled)) return false;
@@ -375,7 +375,12 @@ Plugin.onPostSave = async function (hookData) {
375
375
  winston.warn('[facebook-post] onPostSave: abandon — impossible de récupérer le contexte du post (pid invalide ?)');
376
376
  return;
377
377
  }
378
- winston.info(`[facebook-post] onPostSave: contexte récupéré — pid=${ctx.post.pid} tid=${ctx.topic.tid} cid=${ctx.topic.cid} uid=${ctx.user.uid} isMainPost=${ctx.post.isMainPost} index=${ctx.post.index} reputation=${ctx.user.reputation}`);
378
+
379
+ // Restore ephemeral fields set by onPostCreate (not persisted to DB)
380
+ ctx.post.fbPostEnabled = rawPost.fbPostEnabled;
381
+ if (rawPost.fbPlaceId) ctx.post.fbPlaceId = rawPost.fbPlaceId;
382
+
383
+ winston.info(`[facebook-post] onPostSave: contexte récupéré — pid=${ctx.post.pid} tid=${ctx.topic.tid} cid=${ctx.topic.cid} uid=${ctx.user.uid} isMainPost=${ctx.post.isMainPost} index=${ctx.post.index} mainPid=${ctx.topic.mainPid} reputation=${ctx.user.reputation}`);
379
384
 
380
385
  const allowed = await userIsAllowed(ctx.post.uid);
381
386
  if (!allowed) {
@@ -387,7 +392,7 @@ Plugin.onPostSave = async function (hookData) {
387
392
 
388
393
  const process = shouldProcessPost(ctx);
389
394
  if (!process) {
390
- const isFirstPost = (ctx.post.isMainPost === true) || (ctx.post.index === 0);
395
+ const isFirstPost = (ctx.post.isMainPost === true) || (ctx.post.index === 0) || (String(ctx.post.pid) === String(ctx.topic.mainPid));
391
396
  const fbEnabled = bool(ctx.post.fbPostEnabled);
392
397
  const repOk = (ctx.user.reputation || 0) >= settings.minimumReputation;
393
398
  const whitelist = parseCsvInts(settings.categoriesWhitelist);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-facebook-post",
3
- "version": "1.0.23",
3
+ "version": "1.0.25",
4
4
  "description": "Auto-post new NodeBB topics to a fixed Facebook Page (text + NodeBB uploads + place id).",
5
5
  "main": "library.js",
6
6
  "dependencies": {
@@ -115,12 +115,12 @@
115
115
  $(window).off('filter:composer.submit.fbpost')
116
116
  .on('filter:composer.submit.fbpost', function (ev2, submitData) {
117
117
  const enabled = $enabled.is(':checked');
118
- submitData.data = submitData.data || {};
119
- submitData.data.fbPostEnabled = enabled;
118
+ submitData.postData = submitData.postData || {};
119
+ submitData.postData.fbPostEnabled = enabled;
120
120
 
121
121
  if (enabled) {
122
122
  const placeId = $composer.find('[data-fbpost-place-id]').val();
123
- if (placeId) submitData.data.fbPlaceId = placeId;
123
+ if (placeId) submitData.postData.fbPlaceId = placeId;
124
124
  }
125
125
  return submitData;
126
126
  });