amitsingh-007 / bypass-links

đź”— A web extension to bypass links along with custom redirections, private bookmarks panel & person tagging panel.
https://bypass-links.vercel.app
MIT License
40 stars 5 forks source link

Migration for person and bm mismatch #3158

Closed amitsingh-007 closed 1 month ago

amitsingh-007 commented 1 month ago
  1. Run bun init in a new folder
  2. Export person data from firebase console and copy that file to this folder with name data.json
  3. Run bun index.ts
  4. This will output out.json
import jsonFile from "./data.json";
const path = "./out.json";

const jsonCopy = JSON.parse(JSON.stringify(jsonFile));

/**
 * This will check if bookmakr's taggedPersons are in the persons' taggedUrls
 */
Object.entries<any>(jsonCopy.bookmarks.urlList).forEach(([bmId, bmData]) => {
  if (!bmData.taggedPersons) {
    return;
  }
  bmData.taggedPersons.forEach((personId) => {
    const person = jsonCopy.persons[personId];

    if (!person.taggedUrls?.includes(bmId)) {
      /**
       * First run with this being commented to just know what changes will be made.
       * Then once knowing the ouput, uncomment this and run.
       */
      // person.taggedUrls = person.taggedUrls || [];
      // person.taggedUrls.push(bmId);
      console.log(
        "Person not tagged",
        bmId,
        decodeURIComponent(atob(bmData.title)),
        personId
      );
    }
  });
});

/**
 * This will just output persons with no bookmarks
 */
Object.entries<any>(jsonCopy.persons).forEach(([personId, personData]) => {
  if (!personData.taggedUrls?.length) {
    console.log(
      "Person not tagged",
      personId,
      decodeURIComponent(atob(personData.name))
    );
  }
});

await Bun.write(path, JSON.stringify(jsonCopy));
amitsingh-007 commented 1 month ago

person and bookmark tagged person mismatch