Skip to content

Commit 80859f6

Browse files
committed
feat: remove very old history migration method (since 0.2.8)
Signed-off-by: BoHong Li <raccoon@hackmd.io>
1 parent 412317a commit 80859f6

File tree

4 files changed

+26
-119
lines changed

4 files changed

+26
-119
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
'use strict'
2+
3+
module.exports = {
4+
up: (queryInterface, Sequelize) => {
5+
return queryInterface.dropTable('Temp')
6+
/*
7+
Add altering commands here.
8+
Return a promise to correctly handle asynchronicity.
9+
10+
Example:
11+
return queryInterface.createTable('users', { id: Sequelize.INTEGER });
12+
*/
13+
},
14+
15+
down: (queryInterface, Sequelize) => {
16+
return queryInterface.createTable('Temp', {
17+
id: {
18+
type: Sequelize.STRING,
19+
primaryKey: true
20+
},
21+
date: Sequelize.TEXT,
22+
createdAt: Sequelize.DATE,
23+
updatedAt: Sequelize.DATE
24+
})
25+
}
26+
}

lib/models/temp.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

lib/web/statusRouter.js

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -23,73 +23,6 @@ statusRouter.get('/status', function (req, res, next) {
2323
res.send(data)
2424
})
2525
})
26-
// get status
27-
statusRouter.get('/temp', function (req, res) {
28-
var host = req.get('host')
29-
if (config.allowOrigin.indexOf(host) === -1) {
30-
response.errorForbidden(res)
31-
} else {
32-
var tempid = req.query.tempid
33-
if (!tempid) {
34-
response.errorForbidden(res)
35-
} else {
36-
models.Temp.findOne({
37-
where: {
38-
id: tempid
39-
}
40-
}).then(function (temp) {
41-
if (!temp) {
42-
response.errorNotFound(res)
43-
} else {
44-
res.header('Access-Control-Allow-Origin', '*')
45-
res.send({
46-
temp: temp.data
47-
})
48-
temp.destroy().catch(function (err) {
49-
if (err) {
50-
logger.error('remove temp failed: ' + err)
51-
}
52-
})
53-
}
54-
}).catch(function (err) {
55-
logger.error(err)
56-
return response.errorInternalError(res)
57-
})
58-
}
59-
}
60-
})
61-
// post status
62-
statusRouter.post('/temp', urlencodedParser, function (req, res) {
63-
var host = req.get('host')
64-
if (config.allowOrigin.indexOf(host) === -1) {
65-
response.errorForbidden(res)
66-
} else {
67-
var data = req.body.data
68-
if (!data) {
69-
response.errorForbidden(res)
70-
} else {
71-
if (config.debug) {
72-
logger.info('SERVER received temp from [' + host + ']: ' + req.body.data)
73-
}
74-
models.Temp.create({
75-
data: data
76-
}).then(function (temp) {
77-
if (temp) {
78-
res.header('Access-Control-Allow-Origin', '*')
79-
res.send({
80-
status: 'ok',
81-
id: temp.id
82-
})
83-
} else {
84-
response.errorInternalError(res)
85-
}
86-
}).catch(function (err) {
87-
logger.error(err)
88-
return response.errorInternalError(res)
89-
})
90-
}
91-
}
92-
})
9326

9427
statusRouter.get('/config', function (req, res) {
9528
var data = {

public/js/history.js

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import LZString from '@hackmd/lz-string'
66

77
import escapeHTML from 'lodash/escape'
88

9-
import wurl from 'wurl'
10-
119
import {
1210
checkNoteIdValid,
1311
encodeNoteId
@@ -19,38 +17,6 @@ import { urlpath } from './lib/config'
1917

2018
window.migrateHistoryFromTempCallback = null
2119

22-
migrateHistoryFromTemp()
23-
24-
function migrateHistoryFromTemp () {
25-
if (wurl('#tempid')) {
26-
$.get(`${serverurl}/temp`, {
27-
tempid: wurl('#tempid')
28-
})
29-
.done(data => {
30-
if (data && data.temp) {
31-
getStorageHistory(olddata => {
32-
if (!olddata || olddata.length === 0) {
33-
saveHistoryToStorage(JSON.parse(data.temp))
34-
}
35-
})
36-
}
37-
})
38-
.always(() => {
39-
let hash = location.hash.split('#')[1]
40-
hash = hash.split('&')
41-
for (let i = 0; i < hash.length; i++) {
42-
if (hash[i].indexOf('tempid') === 0) {
43-
hash.splice(i, 1)
44-
i--
45-
}
46-
}
47-
hash = hash.join('&')
48-
location.hash = hash
49-
if (window.migrateHistoryFromTempCallback) { window.migrateHistoryFromTempCallback() }
50-
})
51-
}
52-
}
53-
5420
export function saveHistory (notehistory) {
5521
checkIfAuth(
5622
() => {

0 commit comments

Comments
 (0)