mirror of
				https://codeberg.org/yeentown/barkey.git
				synced 2025-11-03 23:14:13 +00:00 
			
		
		
		
	
							parent
							
								
									878cd18144
								
							
						
					
					
						commit
						ee5720df2c
					
				
					 3 changed files with 31 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -247,7 +247,7 @@ export async function resolveNote(value: string | IObject, resolver?: Resolver):
 | 
			
		|||
	// リモートサーバーからフェッチしてきて登録
 | 
			
		||||
	// ここでuriの代わりに添付されてきたNote Objectが指定されていると、サーバーフェッチを経ずにノートが生成されるが
 | 
			
		||||
	// 添付されてきたNote Objectは偽装されている可能性があるため、常にuriを指定してサーバーフェッチを行う。
 | 
			
		||||
	return await createNote(uri, resolver).catch(e => {
 | 
			
		||||
	return await createNote(uri, resolver, true).catch(e => {
 | 
			
		||||
		if (e.name === 'duplicated') {
 | 
			
		||||
			return fetchNote(uri).then(note => {
 | 
			
		||||
				if (note == null) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -101,6 +101,32 @@ async function fetchAny(uri: string) {
 | 
			
		|||
	// /@user のような正規id以外で取得できるURIが指定されていた場合、ここで初めて正規URIが確定する
 | 
			
		||||
	// これはDBに存在する可能性があるため再度DB検索
 | 
			
		||||
	if (uri !== object.id) {
 | 
			
		||||
		if (object.id.startsWith(config.url + '/')) {
 | 
			
		||||
			const parts = object.id.split('/');
 | 
			
		||||
			const id = parts.pop();
 | 
			
		||||
			const type = parts.pop();
 | 
			
		||||
 | 
			
		||||
			if (type === 'notes') {
 | 
			
		||||
				const note = await Notes.findOne(id);
 | 
			
		||||
 | 
			
		||||
				if (note) {
 | 
			
		||||
					return {
 | 
			
		||||
						type: 'Note',
 | 
			
		||||
						object: await Notes.pack(note, null, { detail: true })
 | 
			
		||||
					};
 | 
			
		||||
				}
 | 
			
		||||
			} else if (type === 'users') {
 | 
			
		||||
				const user = await Users.findOne(id);
 | 
			
		||||
 | 
			
		||||
				if (user) {
 | 
			
		||||
					return {
 | 
			
		||||
						type: 'User',
 | 
			
		||||
						object: await Users.pack(user, null, { detail: true })
 | 
			
		||||
					};
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		const [user, note] = await Promise.all([
 | 
			
		||||
			Users.findOne({ uri: object.id }),
 | 
			
		||||
			Notes.findOne({ uri: object.id })
 | 
			
		||||
| 
						 | 
				
			
			@ -120,7 +146,7 @@ async function fetchAny(uri: string) {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	if (['Note', 'Question', 'Article'].includes(object.type)) {
 | 
			
		||||
		const note = await createNote(object.id);
 | 
			
		||||
		const note = await createNote(object.id, undefined, true);
 | 
			
		||||
		return {
 | 
			
		||||
			type: 'Note',
 | 
			
		||||
			object: await Notes.pack(note!, null, { detail: true })
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -240,7 +240,9 @@ export default async (user: User, data: Option, silent = false) => new Promise<N
 | 
			
		|||
		(noteObj as any).isFirstNote = true;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	publishNotesStream(noteObj);
 | 
			
		||||
	if (!silent) {
 | 
			
		||||
		publishNotesStream(noteObj);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	const nm = new NotificationManager(user, note);
 | 
			
		||||
	const nmRelatedPromises = [];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue