kopia lustrzana https://github.com/cloudflare/wildebeest
				
				
				
			various changes to status deletion
							rodzic
							
								
									f0a6b695a6
								
							
						
					
					
						commit
						0a16029f38
					
				|  | @ -2,6 +2,6 @@ export function cors(): object { | |||
| 	return { | ||||
| 		'Access-Control-Allow-Origin': '*', | ||||
| 		'Access-Control-Allow-Headers': 'content-type, authorization, idempotency-key', | ||||
| 		'Access-Control-Allow-Methods': 'GET, PUT, POST', | ||||
| 		'Access-Control-Allow-Methods': 'GET, PUT, POST, DELETE', | ||||
| 	} | ||||
| } | ||||
|  |  | |||
|  | @ -17,6 +17,7 @@ import { addFollowing, acceptFollowing } from 'wildebeest/backend/src/mastodon/f | |||
| import { MessageType } from 'wildebeest/backend/src/types/queue' | ||||
| import { MastodonStatus } from 'wildebeest/backend/src/types' | ||||
| import { mastodonIdSymbol, getObjectByMastodonId } from 'wildebeest/backend/src/activitypub/objects' | ||||
| import { addObjectInOutbox } from 'wildebeest/backend/src/activitypub/actors/outbox' | ||||
| 
 | ||||
| const userKEK = 'test_kek4' | ||||
| const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms)) | ||||
|  | @ -832,6 +833,7 @@ describe('Mastodon APIs', () => { | |||
| 			const db = await makeDB() | ||||
| 			const actor = await createPerson(domain, db, userKEK, 'sven@cloudflare.com') | ||||
| 			const note = await createPublicNote(domain, db, 'note from actor', actor) | ||||
| 			await addObjectInOutbox(db, actor, note) | ||||
| 
 | ||||
| 			const res = await statuses_id.handleRequestDelete(db, note[mastodonIdSymbol]!, actor, domain) | ||||
| 			assert.equal(res.status, 200) | ||||
|  |  | |||
|  | @ -38,10 +38,18 @@ export async function handleRequestGet(db: D1Database, id: UUID, domain: string) | |||
| // schema directly into D1, which D1 disallows at the moment.
 | ||||
| // Some context at: https://stackoverflow.com/questions/13150075/add-on-delete-cascade-behavior-to-an-sqlite3-table-after-it-has-been-created
 | ||||
| async function deleteNote(db: D1Database, note: Note) { | ||||
| 	const deleteOutboxObject = db.prepare('DELETE FROM outbox_objects WHERE id=?').bind(note.id.toString()) | ||||
| 	const deleteObject = db.prepare('DELETE FROM objects WHERE id=?').bind(note.id.toString()) | ||||
| 	const nodeId = note.id.toString() | ||||
| 	const batch = [ | ||||
| 		db.prepare('DELETE FROM outbox_objects WHERE object_id=?').bind(nodeId), | ||||
| 		db.prepare('DELETE FROM inbox_objects WHERE object_id=?').bind(nodeId), | ||||
| 		db.prepare('DELETE FROM actor_notifications WHERE object_id=?').bind(nodeId), | ||||
| 		db.prepare('DELETE FROM actor_favourites WHERE object_id=?').bind(nodeId), | ||||
| 		db.prepare('DELETE FROM actor_reblogs WHERE object_id=?').bind(nodeId), | ||||
| 		db.prepare('DELETE FROM actor_replies WHERE object_id=?1 OR in_reply_to_object_id=?1').bind(nodeId), | ||||
| 		db.prepare('DELETE FROM objects WHERE id=?').bind(nodeId), | ||||
| 	] | ||||
| 
 | ||||
| 	const res = await db.batch([deleteOutboxObject, deleteObject]) | ||||
| 	const res = await db.batch(batch) | ||||
| 
 | ||||
| 	for (let i = 0, len = res.length; i < len; i++) { | ||||
| 		if (!res[i].success) { | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Sven Sauleau
						Sven Sauleau