mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 22:43:30 +03:00
🐛 Fixed disqus comment id when exporting/importing 1.x content
no issue - while i was testing random failures, i discovered an edge case for disqus - you start a new 1.0 blog, you add disqus, the unique identifer is the post id (object id) - now you export your content and import it on a new instance - the importer detects that the amp field is null and imports the old object id as comment id - but the post model is not prepared for this case - see next commit for tests **NOTE**: The comment id had two different data types (Number or String). Disqus expects a string. So this should not change any behaviour, now that the comment_id is always a string.
This commit is contained in:
parent
4a1f1f5a9f
commit
c99557d9a3
@ -3,6 +3,7 @@ var _ = require('lodash'),
|
||||
uuid = require('uuid'),
|
||||
moment = require('moment'),
|
||||
Promise = require('bluebird'),
|
||||
ObjectId = require('bson-objectid'),
|
||||
sequence = require('../utils/sequence'),
|
||||
errors = require('../errors'),
|
||||
htmlToText = require('html-to-text'),
|
||||
@ -518,12 +519,19 @@ Post = ghostBookshelf.Model.extend({
|
||||
}
|
||||
|
||||
if (oldPostId) {
|
||||
oldPostId = Number(oldPostId);
|
||||
|
||||
if (isNaN(oldPostId)) {
|
||||
commentId = attrs.id;
|
||||
} else {
|
||||
// CASE: You create a new post on 1.X, you enable disqus. You export your content, you import your content on a different instance.
|
||||
// This time, the importer remembers your old post id in the amp field as ObjectId.
|
||||
if (ObjectId.isValid(oldPostId)) {
|
||||
commentId = oldPostId;
|
||||
} else {
|
||||
oldPostId = Number(oldPostId);
|
||||
|
||||
// CASE: You import an old post id from your LTS blog. Stored in the amp field.
|
||||
if (!isNaN(oldPostId)) {
|
||||
commentId = oldPostId.toString();
|
||||
} else {
|
||||
commentId = attrs.id;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
commentId = attrs.id;
|
||||
|
Loading…
Reference in New Issue
Block a user