Tons of fixes to prepare for staged releases.
This commit is contained in:
1 parent
9f37d3faf1
commit
5bebe072b2
24 files changed
+1110
-474
No files matched your search
+34
-8
@@ -199,7 +199,7 @@ Note.create = (userId, noteTitle = '', noteText = '', masterKey) => {
|
||||
.then((rows, fields) => {
|
||||
|
||||
if(typeof SocketIo != 'undefined'){
|
||||
SocketIo.to(userId).emit('new_note_created', rows[0].insertId)
|
||||
SocketIo.to(`user:${userId}`).emit('new_note_created', rows[0].insertId)
|
||||
}
|
||||
|
||||
// Indexing is done on save
|
||||
@@ -490,7 +490,7 @@ Note.update = (userId, noteId, noteText, noteTitle, color, pinned, archived, has
|
||||
}
|
||||
db.promise().query('UPDATE note SET snippet = ? WHERE id = ?', [updatedSnippet, otherNote.id])
|
||||
.then((rows, fields) => {
|
||||
SocketIo.to(otherNote['user_id']).emit('new_note_text_saved', {'noteId':otherNote.id, hash})
|
||||
SocketIo.to(`user:${otherNote['user_id']}`).emit('new_note_text_saved', {'noteId':otherNote.id, hash})
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -514,7 +514,7 @@ Note.update = (userId, noteId, noteText, noteTitle, color, pinned, archived, has
|
||||
.then((rows, fields) => {
|
||||
|
||||
if(typeof SocketIo != 'undefined'){
|
||||
SocketIo.to(userId).emit('new_note_text_saved', {noteId, hash})
|
||||
SocketIo.to(`user:${userId}`).emit('new_note_text_saved', {noteId, hash})
|
||||
|
||||
//Async attachment reindex
|
||||
Attachment.scanTextForWebsites(SocketIo, userId, noteId, noteText)
|
||||
@@ -538,7 +538,7 @@ Note.setPinned = (userId, noteId, pinnedBoolean) => {
|
||||
.query('UPDATE note JOIN note_raw_text ON note_raw_text_id = note_raw_text.id SET pinned = ?, updated = ? WHERE note.id = ? AND user_id = ?',
|
||||
[pinned, now, noteId, userId])
|
||||
.then((rows, fields) => {
|
||||
SocketIo.to(userId).emit('note_attribute_modified', noteId)
|
||||
SocketIo.to(`user:${userId}`).emit('note_attribute_modified', noteId)
|
||||
resolve(true)
|
||||
})
|
||||
})
|
||||
@@ -555,7 +555,7 @@ Note.setArchived = (userId, noteId, archivedBoolead) => {
|
||||
.query('UPDATE note JOIN note_raw_text ON note_raw_text_id = note_raw_text.id SET archived = ?, updated = ? WHERE note.id = ? AND user_id = ?',
|
||||
[archived, now, noteId, userId])
|
||||
.then((rows, fields) => {
|
||||
SocketIo.to(userId).emit('note_attribute_modified', noteId)
|
||||
SocketIo.to(`user:${userId}`).emit('note_attribute_modified', noteId)
|
||||
resolve(true)
|
||||
})
|
||||
})
|
||||
@@ -581,7 +581,7 @@ Note.setTrashed = (userId, noteId, trashedBoolean, masterKey) => {
|
||||
Note.reindex(userId, masterKey, removeFromIndex)
|
||||
|
||||
|
||||
SocketIo.to(userId).emit('note_attribute_modified', noteId)
|
||||
SocketIo.to(`user:${userId}`).emit('note_attribute_modified', noteId)
|
||||
resolve(true)
|
||||
})
|
||||
})
|
||||
@@ -653,7 +653,7 @@ Note.delete = (userId, noteId, masterKey = null) => {
|
||||
}
|
||||
})
|
||||
|
||||
SocketIo.to(userId).emit('update_counts')
|
||||
SocketIo.to(`user:${userId}`).emit('update_counts')
|
||||
|
||||
if(masterKey){
|
||||
//Remove note ID from index
|
||||
@@ -1190,4 +1190,30 @@ Note.search = (userId, searchQuery, searchTags, fastFilters, masterKey) => {
|
||||
.catch(console.log)
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Resolve a note's raw-text id for a given user.
|
||||
// Doubles as the access check: a user with no claim on this note gets null,
|
||||
// so authorisation and room derivation are the same lookup.
|
||||
//
|
||||
Note.getRawTextIdForUser = (noteId, userId) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
const id = parseInt(noteId, 10)
|
||||
if(!Number.isInteger(id) || id < 1){ return resolve(null) }
|
||||
|
||||
db.promise()
|
||||
.query('SELECT note_raw_text_id FROM note WHERE id = ? AND user_id = ? LIMIT 1', [id, userId])
|
||||
.then((rows) => {
|
||||
|
||||
if(!rows[0] || rows[0].length == 0){ return resolve(null) }
|
||||
|
||||
return resolve( rows[0][0]['note_raw_text_id'] )
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error)
|
||||
return resolve(null)
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user