Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix heroku free plan ending #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ I will make this more convenient later.
- Inbox Name:: [[Inbox]]
- API Key:: insert key you get from Telegram's bot system
- {{[[TODO]]}} update the Telegram API key above
- Trusted Media Proxy:: https://telegram-cors-proxy.herokuapp.com
- Trusted Media Proxy:: https://telegroam-cors-proxy.herokuapp.com
- Latest Update ID::

5. Make a block with the text `{{[[roam/js]]}}`.
Expand Down
56 changes: 28 additions & 28 deletions telegroam.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,36 +548,36 @@
roamAlphaAPI.util.generateUID()

let lockPath =
`https://binary-semaphore.herokuapp.com/lock/${lockId}/${nonce}`

let acquirePath = `${lockPath}/acquire`
let releasePath = `${lockPath}/release`

for (;;) {
let result =
await fetch(acquirePath, { method: "POST" })

if (result.status === lockStatus.ok) {
currentLockPath = lockPath

try {
return await action()
} finally {
console.log("telegroam: releasing lock")
currentLockPath = null
try {
await fetch(releasePath, { method: "POST" })
} catch (e) {
console.error(e)
throw e
`https://roam-binary-semaphore.herokuapp.com/lock/${lockId}/${nonce}`

let acquirePath = `${lockPath}`
let releasePath = `${lockPath}`

for (;;) {
let result =
await fetch(acquirePath, { method: "PUT" })

if (result.status === lockStatus.ok) {
currentLockPath = lockPath

try {
return await action()
} finally {
console.log("telegroam: releasing lock")
currentLockPath = null
try {
await fetch(releasePath, { method: "DELETE" })
} catch (e) {
console.error(e)
throw e
}
}

} else if (result.status === lockStatus.busy) {
console.log(`telegroam: lock busy; waiting ${waitSeconds}s`)
await sleep(waitSeconds)
}
}

} else if (result.status === lockStatus.busy) {
console.log(`telegroam: lock busy; waiting ${waitSeconds}s`)
await sleep(waitSeconds)
}
}
}

async function updateFromTelegramContinuously() {
Expand Down