nodebb-plugin-facebook-post 1.0.23 → 1.0.24

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 +7 -2
  2. package/package.json +1 -1
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) {
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.24",
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": {