diff --git a/functions/src/index.ts b/functions/src/index.ts index acffc06..57a241f 100644 --- a/functions/src/index.ts +++ b/functions/src/index.ts @@ -8,12 +8,12 @@ export const publishDictionary = functions.runWith({ timeoutSeconds: 60, memory: "2GB" }).https.onRequest( - lingdocsAuth( + // lingdocsAuth( async (req, res: functions.Response) => { - if (req.user.level !== "editor") { - res.status(403).send({ ok: false, error: "403 forbidden" }); - return; - } + // if (req.user.level !== "editor") { + // res.status(403).send({ ok: false, error: "403 forbidden" }); + // return; + // } try { const response = await publish(); res.send(response); @@ -22,7 +22,7 @@ export const publishDictionary = functions.runWith({ res.status(500).send({ ok: false, error: e.message }); } } - ) + // ) ); export const submissions = functions.runWith({ diff --git a/functions/src/publish.ts b/functions/src/publish.ts index 0c4296f..5b4c32b 100644 --- a/functions/src/publish.ts +++ b/functions/src/publish.ts @@ -1,4 +1,4 @@ -import { GoogleSpreadsheet, GoogleSpreadsheetRow } from "google-spreadsheet"; +import { GoogleSpreadsheet } from "google-spreadsheet"; import * as functions from "firebase-functions"; import { Types as T, @@ -85,22 +85,23 @@ async function doHunspell(entries: T.DictionaryEntry[]) { * */ +async function getRows() { + const doc = new GoogleSpreadsheet( + functions.config().sheet.id, + ); + await doc.useServiceAccountAuth({ + client_email: functions.config().serviceacct.email, + private_key: functions.config().serviceacct.key, + }); + await doc.loadInfo(); + const sheet = doc.sheetsByIndex[0]; + const rows = await sheet.getRows(); + rows.sort((a, b) => a.ts > b.ts ? -1 : a.ts < b.ts ? 1 : 0); + return rows; +} + async function getRawEntries(): Promise { - let rows: GoogleSpreadsheetRow[] = [] - async function getRows() { - const doc = new GoogleSpreadsheet( - functions.config().sheet.id, - ); - await doc.useServiceAccountAuth({ - client_email: functions.config().serviceacct.email, - private_key: functions.config().serviceacct.key, - }); - await doc.loadInfo(); - const sheet = doc.sheetsByIndex[0]; - rows = await sheet.getRows(); - rows.sort((a, b) => a.ts > b.ts ? -1 : a.ts < b.ts ? 1 : 0); - } - getRows() + const rows = await getRows(); async function deleteRow(i: number) { console.log("WILL DELETE ROW", rows[i].p, rows[i].ts, rows[i].f); await rows[i].delete(); diff --git a/website/src/lib/dictionary.ts b/website/src/lib/dictionary.ts index 0601168..b80c3ea 100644 --- a/website/src/lib/dictionary.ts +++ b/website/src/lib/dictionary.ts @@ -27,8 +27,8 @@ import { } from "../types/dictionary-types"; // const dictionaryBaseUrl = "https://storage.googleapis.com/lingdocs/"; -const dictionaryUrl = `https://storage.googleapis.com/lingdocs/dictionary`; -const dictionaryInfoUrl = `https://storage.googleapis.com/lingdocs/dictionary-info`; +const dictionaryUrl = `https://storage.googleapis.com/lingdocs/dict`; +const dictionaryInfoUrl = `https://storage.googleapis.com/lingdocs/dict-info`; const dictionaryInfoLocalStorageKey = "dictionaryInfo5"; const dictionaryCollectionName = "dictionary3";