mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 21:11:30 +08:00 
			
		
		
		
	Merge branch 'master' into m41
This commit is contained in:
		
						commit
						b25c1d6fa8
					
				
							
								
								
									
										1
									
								
								.idea/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.idea/.gitignore
									
									
									
										generated
									
									
										vendored
									
									
								
							| @ -3,3 +3,4 @@ | ||||
| 
 | ||||
| # Datasource local storage ignored files | ||||
| /dataSources.local.xml | ||||
| /dataSources/ | ||||
|  | ||||
| @ -110,6 +110,10 @@ class Note extends Entity { | ||||
|     async getJsonContent() { | ||||
|         const content = await this.getContent(); | ||||
| 
 | ||||
|         if (!content || !content.trim()) { | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|         return JSON.parse(content); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -29,8 +29,12 @@ async function searchFromNote(req) { | ||||
|         return [404, `Note ${req.params.noteId} has not been found.`]; | ||||
|     } | ||||
| 
 | ||||
|     if (note.isDeleted) { | ||||
|         return [400, `Note ${req.params.noteId} is deleted.`]; | ||||
|     } | ||||
| 
 | ||||
|     if (note.type !== 'search') { | ||||
|         return [400, '`Note ${req.params.noteId} is not search note.`'] | ||||
|         return [400, `Note ${req.params.noteId} is not search note.`] | ||||
|     } | ||||
| 
 | ||||
|     const json = await note.getJsonContent(); | ||||
| @ -41,18 +45,28 @@ async function searchFromNote(req) { | ||||
| 
 | ||||
|     let noteIds; | ||||
| 
 | ||||
|     try { | ||||
|         if (json.searchString.startsWith('=')) { | ||||
|             const relationName = json.searchString.substr(1).trim(); | ||||
| 
 | ||||
|             noteIds = await searchFromRelation(note, relationName); | ||||
|     } | ||||
|     else { | ||||
|         } else { | ||||
|             noteIds = await searchService.searchForNoteIds(json.searchString); | ||||
|         } | ||||
|     } | ||||
|     catch (e) { | ||||
|         log.error(`Search failed for note ${note.noteId}: ` + e.message + ": " + e.stack); | ||||
| 
 | ||||
|         throw new Error("Search failed, see logs for details."); | ||||
|     } | ||||
| 
 | ||||
|     // we won't return search note's own noteId
 | ||||
|     noteIds = noteIds.filter(noteId => noteId !== note.noteId); | ||||
| 
 | ||||
|     if (noteIds.length > 200) { | ||||
|         noteIds = noteIds.slice(0, 200); | ||||
|     } | ||||
| 
 | ||||
|     return noteIds.map(noteCacheService.getNotePath).filter(res => !!res); | ||||
| } | ||||
| 
 | ||||
|  | ||||
| @ -40,7 +40,9 @@ async function getRootCalendarNote() { | ||||
|             parentNoteId: 'root', | ||||
|             title: 'Calendar', | ||||
|             target: 'into', | ||||
|             isProtected: false | ||||
|             isProtected: false, | ||||
|             type: 'text', | ||||
|             content: '' | ||||
|         })).note; | ||||
| 
 | ||||
|         await attributeService.createLabel(rootNote.noteId, CALENDAR_ROOT_LABEL); | ||||
|  | ||||
| @ -71,22 +71,36 @@ function sendMessageToAllClients(message) { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| async function fillInAdditionalProperties(sync) { | ||||
|     // fill in some extra data needed by the frontend
 | ||||
|     if (sync.entityName === 'attributes') { | ||||
|         sync.noteId = await sql.getValue(`SELECT noteId
 | ||||
|                                           FROM attributes | ||||
|                                           WHERE attributeId = ?`, [sync.entityId]);
 | ||||
|     } else if (sync.entityName === 'note_revisions') { | ||||
|         sync.noteId = await sql.getValue(`SELECT noteId
 | ||||
|                                           FROM note_revisions | ||||
|                                           WHERE noteRevisionId = ?`, [sync.entityId]);
 | ||||
|     } else if (sync.entityName === 'branches') { | ||||
|         const {noteId, parentNoteId} = await sql.getRow(`SELECT noteId, parentNoteId
 | ||||
|                                                          FROM branches | ||||
|                                                          WHERE branchId = ?`, [sync.entityId]);
 | ||||
| 
 | ||||
|         sync.noteId = noteId; | ||||
|         sync.parentNoteId = parentNoteId; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| async function sendPing(client) { | ||||
|     const syncData = require('./sync_table').getEntitySyncsNewerThan(lastAcceptedSyncIds[client.id]); | ||||
| 
 | ||||
|     for (const sync of syncData) { | ||||
|         // fill in some extra data needed by the frontend
 | ||||
|         if (sync.entityName === 'attributes') { | ||||
|             sync.noteId = await sql.getValue(`SELECT noteId FROM attributes WHERE attributeId = ?`, [sync.entityId]); | ||||
|         try { | ||||
|             await fillInAdditionalProperties(sync); | ||||
|         } | ||||
|         else if (sync.entityName === 'note_revisions') { | ||||
|             sync.noteId = await sql.getValue(`SELECT noteId FROM note_revisions WHERE noteRevisionId = ?`, [sync.entityId]); | ||||
|         } | ||||
|         else if (sync.entityName === 'branches') { | ||||
|             const {noteId, parentNoteId} = await sql.getRow(`SELECT noteId, parentNoteId FROM branches WHERE branchId = ?`, [sync.entityId]); | ||||
| 
 | ||||
|             sync.noteId = noteId; | ||||
|             sync.parentNoteId = parentNoteId; | ||||
|         catch (e) { | ||||
|             log.error("Could not fill additional properties for sync " + JSON.stringify(sync) | ||||
|                 + " because of error: " + e.message + ": " + e.stack); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam