core: set synced to false on removing content by note id

This commit is contained in:
Abdullah Atta
2024-05-06 15:45:40 +05:00
parent f9bfa88c83
commit 63f44d6fbc
2 changed files with 22 additions and 2 deletions

View File

@@ -90,6 +90,25 @@ test("localOnly note should get included as a deleted item in collector", () =>
expect(items[1].type).toBe("note");
}));
test("unlinked relation should get included in collector", () =>
databaseTest().then(async (db) => {
await loginFakeUser(db);
const collector = new Collector(db);
await db.relations.add(
{ id: "h", type: "note" },
{ id: "h", type: "attachment" }
);
await iteratorToArray(collector.collect(100, false));
await db.relations.from({ id: "h", type: "note" }, "attachment").unlink();
const items = await iteratorToArray(collector.collect(100, false));
expect(items).toHaveLength(1);
expect(items[0].items[0].id).toBe("cd93df7a4c64fbd5f100361d629ac5b5");
}));
async function iteratorToArray(iterator) {
let items = [];
for await (const item of iterator) {

View File

@@ -197,7 +197,7 @@ export class Content implements ICollection {
await this.db
.sql()
.replaceInto("content")
.columns(["id", "dateModified", "deleted"])
.columns(["id", "dateModified", "deleted", "synced"])
.expression((eb) =>
eb
.selectFrom("content")
@@ -205,7 +205,8 @@ export class Content implements ICollection {
.select((eb) => [
"content.id",
eb.lit(Date.now()).as("dateModified"),
eb.lit(1).as("deleted")
eb.lit(1).as("deleted"),
eb.lit(0).as("synced")
])
)
.execute();