Mercurial Hosting > chat
comparison src/lib/User.luan @ 46:42b741a1d5c6
add username
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Fri, 28 Feb 2025 19:25:12 -0700 |
| parents | 818697418dbe |
| children | 7b339b1ccd11 |
comparison
equal
deleted
inserted
replaced
| 45:e138343b2c76 | 46:42b741a1d5c6 |
|---|---|
| 9 local sub_string = String.sub or error() | 9 local sub_string = String.sub or error() |
| 10 local Math = require "luan:Math.luan" | 10 local Math = require "luan:Math.luan" |
| 11 local random = Math.random or error() | 11 local random = Math.random or error() |
| 12 local Table = require "luan:Table.luan" | 12 local Table = require "luan:Table.luan" |
| 13 local concat = Table.concat or error() | 13 local concat = Table.concat or error() |
| 14 local Html = require "luan:Html.luan" | |
| 15 local html_encode = Html.encode or error() | |
| 14 local Lucene = require "luan:lucene/Lucene.luan" | 16 local Lucene = require "luan:lucene/Lucene.luan" |
| 15 local lucene_quote = Lucene.quote or error() | 17 local lucene_quote = Lucene.quote or error() |
| 16 local Http = require "luan:http/Http.luan" | 18 local Http = require "luan:http/Http.luan" |
| 17 local Db = require "site:/lib/Db.luan" | 19 local Db = require "site:/lib/Db.luan" |
| 18 local run_in_transaction = Db.run_in_transaction or error() | 20 local run_in_transaction = Db.run_in_transaction or error() |
| 35 password = doc.password | 37 password = doc.password |
| 36 was_notified = doc.was_notified=="true" | 38 was_notified = doc.was_notified=="true" |
| 37 notify_email = doc.notify_email | 39 notify_email = doc.notify_email |
| 38 multi_notify = doc.multi_notify=="true" | 40 multi_notify = doc.multi_notify=="true" |
| 39 voice_url = doc.voice_url | 41 voice_url = doc.voice_url |
| 42 name = doc.name | |
| 40 } | 43 } |
| 41 end | 44 end |
| 42 | 45 |
| 43 local function to_doc(user) | 46 local function to_doc(user) |
| 44 return { | 47 return { |
| 48 password = user.password | 51 password = user.password |
| 49 was_notified = user.was_notified and "true" or nil | 52 was_notified = user.was_notified and "true" or nil |
| 50 notify_email = user.notify_email | 53 notify_email = user.notify_email |
| 51 multi_notify = user.multi_notify and "true" or nil | 54 multi_notify = user.multi_notify and "true" or nil |
| 52 voice_url = user.voice_url | 55 voice_url = user.voice_url |
| 56 name = user.name | |
| 53 } | 57 } |
| 54 end | 58 end |
| 55 | 59 |
| 56 function User.new(user) | 60 function User.new(user) |
| 57 | 61 |
| 103 user_ids[user_id] = true | 107 user_ids[user_id] = true |
| 104 end | 108 end |
| 105 end | 109 end |
| 106 user_ids[my_id] = false | 110 user_ids[my_id] = false |
| 107 return set_to_list(user_ids) | 111 return set_to_list(user_ids) |
| 112 end | |
| 113 | |
| 114 function user.name_html() | |
| 115 return html_encode(user.name or user.email) | |
| 108 end | 116 end |
| 109 | 117 |
| 110 return user | 118 return user |
| 111 end | 119 end |
| 112 | 120 |
