nodebb-plugin-facebook-post 1.0.26 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-facebook-post",
3
- "version": "1.0.26",
3
+ "version": "1.0.28",
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": {
@@ -112,17 +112,18 @@
112
112
  if ($results.children().length) $results.show();
113
113
  });
114
114
 
115
- $(window).off('filter:composer.submit.fbpost')
116
- .on('filter:composer.submit.fbpost', function (ev2, submitData) {
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
- // Inject directly into the post-data object that NodeBB sends to the socket
119
- submitData.fbPostEnabled = enabled;
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) submitData.fbPlaceId = placeId;
125
+ if (placeId) postData.fbPlaceId = placeId;
124
126
  }
125
- return submitData;
126
127
  });
127
128
  }
128
129