annotate src/new_chat.red.luan @ 18:820136c5ee33

add new_chat.red
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 30 Jul 2025 15:11:24 -0600
parents
children 0c17c233c45a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local Http = require "luan:http/Http.luan"
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local User = require "site:/lib/User.luan"
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local current_user = User.current or error()
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local Chat = require "site:/lib/Chat.luan"
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 return function()
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local user = current_user() or error()
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 local chat = Chat.new{
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 user_id = user.id
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 name = "whatever"
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 language = "jp"
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 }
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 chat.save()
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 Http.response.send_redirect("chat.html?chat="..chat.id)
820136c5ee33 add new_chat.red
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 end