(padId:string)
| 37 | * @return {String} the read only id |
| 38 | */ |
| 39 | const getReadOnlyId = async (padId:string) => { |
| 40 | // check if there is a pad2readonly entry |
| 41 | let readOnlyId = await db.get(`pad2readonly:${padId}`); |
| 42 | |
| 43 | // there is no readOnly Entry in the database, let's create one |
| 44 | if (readOnlyId == null) { |
| 45 | readOnlyId = `r.${randomString(16)}`; |
| 46 | await Promise.all([ |
| 47 | db.set(`pad2readonly:${padId}`, readOnlyId), |
| 48 | db.set(`readonly2pad:${readOnlyId}`, padId), |
| 49 | ]); |
| 50 | } |
| 51 | |
| 52 | return readOnlyId; |
| 53 | }; |
| 54 | |
| 55 | /** |
| 56 | * returns the padId for a read only id |
no test coverage detected