diff --git a/.gitignore b/.gitignore index 667a66c..4168d8b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ yarn.lock config.json npm-debug.log *.sublime-* -.DS_Store \ No newline at end of file +.DS_Store +/.idea +/wordpress-comments.xml diff --git a/package.json b/package.json index 973a430..1aef2c1 100644 --- a/package.json +++ b/package.json @@ -51,6 +51,10 @@ { "name": "g-div", "web": "https://github.com/g-div" + }, + { + "name": "Jerram Digital", + "web": "https://jerram.co.uk/" } ], "devDependencies": { diff --git a/src/db/queries.js b/src/db/queries.js index e2b772a..3a01f01 100644 --- a/src/db/queries.js +++ b/src/db/queries.js @@ -54,7 +54,7 @@ module.exports = { WHERE provider = ? AND provider_id = ?`, create_user: - `INSERT INTO user + `INSERT OR IGNORE INTO user (provider, provider_id, display_name, name, url, created_at, trusted, blocked) VALUES (?, ?, ?, ?, ?, datetime(), ?, 0)`, diff --git a/src/importer.js b/src/importer.js index 1164fdc..d1e5bd0 100644 --- a/src/importer.js +++ b/src/importer.js @@ -38,9 +38,15 @@ async function parse(file) { } function getWPAuthor(comment) { + + let provider_id = comment['wp:comment_author']; + if (comment['wp:comment_user_id'].toString().length && !isNaN(comment['wp:comment_user_id'] * 1)) { + provider_id = comment['wp:comment_user_id'] + } + return [ 'wordpress', - comment['wp:comment_author'], + provider_id, comment['wp:comment_author'], comment['wp:comment_author'], 0