annotate src/save_voice.js.luan @ 41:818697418dbe

add voice link
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 27 Feb 2025 19:05:57 -0700
parents src/save_notify.js.luan@7ea33179592a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
40
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local Http = require "luan:http/Http.luan"
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local Db = require "site:/lib/Db.luan"
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local run_in_transaction = Db.run_in_transaction or error()
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local User = require "site:/lib/User.luan"
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local current_user = User.current or error()
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 return function()
41
818697418dbe add voice link
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
11 local url = Http.request.parameters.url or error()
818697418dbe add voice link
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
12 if url == "" then
818697418dbe add voice link
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
13 url = nil
818697418dbe add voice link
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
14 end
40
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 run_in_transaction( function()
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 local user = current_user() or error()
41
818697418dbe add voice link
Franklin Schmidt <fschmidt@gmail.com>
parents: 40
diff changeset
17 user.voice_url = url
40
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 user.save()
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 end )
7ea33179592a email notification
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 end