Kim Alvefur
81d747b6a4
util.smqueue: Add missing method to Teal record spec
2021-12-16 12:16:08 +01:00
Kim Alvefur
93a9ed2620
util.smqueue: Abstract queue with acknowledgements and overflow
...
Meant to be used in mod_smacks for XEP-0198
Meant to have a larger virtual size than actual number of items stored,
on the theory that in most cases, the excess will be acked before needed
for a resumption event.
2021-12-14 19:58:53 +01:00
Kim Alvefur
8aa16eaec0
mod_cron: Add a 'weekly' job frequency
2021-12-03 09:05:41 +01:00
Kim Alvefur
d6070eea1f
mod_cron: Initialize timestamp of new tasks to start of period
...
Makes it more generic so new periods (e.g. weekly etc) can be added
easily.
2021-12-03 09:01:09 +01:00
Kim Alvefur
914d3acbd5
mod_cron: Follow convention of imports at the top
2021-12-03 08:57:40 +01:00
Kim Alvefur
6f3409f3f2
mod_cron: Initialize daily tasks so they run around midnight UTC
...
Eventually the goal is to have daily tasks run while there is little
activity, but that will vary with the server and the usage patterns of
its users. This is a start anyway.
2021-12-03 00:11:31 +01:00
Kim Alvefur
630035a369
mod_cron: Initial commit of periodic task runner
...
A number of modules now have periodic tasks that need to run, e.g. for
cleaning out old messages or files. This has highlighted a need for
coordinating and optimizing scheduling of such tasks.
2021-11-21 15:50:36 +01:00
Kim Alvefur
e29326533e
teal: Describe the module API interface
...
Helps when writing modules in Teal
2021-03-24 20:28:25 +01:00
Kim Alvefur
b93398ce79
util.pposix: Bind isatty(3)
...
Useful for disabling certain behavior, ANSI colors etc when not
connected to a terminal.
2021-07-04 15:11:07 +02:00
Kim Alvefur
f40173b4c7
util.stanza: Export pretty printing function
2021-06-29 16:06:54 +02:00
Kim Alvefur
15d7143bb3
teal: Add type spec for util.signal
2021-05-20 23:18:29 +02:00
Kim Alvefur
d3ea964495
teal: Add type spec for util.ringbuffer
2021-05-20 23:16:01 +02:00
Kim Alvefur
24e99bf40a
teal: Describe util.net.local_addresses() return type
2021-05-20 23:13:54 +02:00
Kim Alvefur
d8b2d097f4
teal: Add new util.hashes APIs
2021-05-20 23:09:45 +02:00
Kim Alvefur
4720eea24f
util.datamapper: Don't include empty unwrapped arrays
...
Since there is no way to distinguish an empty such array from a
zero-length array. Dropping it seems like the least annoying thing to
do.
2021-03-24 00:48:02 +01:00
Kim Alvefur
13185a16ae
util.datamapper: Fix error on attempt to coerce nil to something
...
Turns falsy values into nil instead of nothing, which ensures this
function always has 1 return value, or table.insert({}) complains. Would
still happen on some unexpected input, but that's actually a good thing.
2021-03-23 23:55:33 +01:00
Kim Alvefur
2040145780
util.datamapper: Deal with locally built stanzas missing xmlns
...
So the problem is that xmlns is not inherited when building a stanza,
and then :get_child(n, ns) with an explicit namespace does not find that
such child tags.
E.g.
local t = st.stanza("foo", { xmlns = "urn:example:bar" })
:text_tag("hello", "world");
assert(t:get_child("hello", "urn:example:bar"), "This fails");
Meanwhile, during parsing (util.xmppstream or util.xml) child tags do
get the parents xmlns when not overriding them.
Thus, in the above example, if the stanza is passed trough
`t = util.xml.parse(tostring(t))` then the assert succeeds.
This change makes it so that it leaves out the namespace argument to
:get_child when it is the same as the current/parent namespace, which
behaves the same for both built and parsed stanzas.
2021-03-23 19:52:59 +01:00
Kim Alvefur
e783d99cc2
util.datamapper: Factor out conversion from any value to XML string
...
Since this was the last severely duplicated code left.
2021-03-22 22:24:39 +01:00
Kim Alvefur
6f0532b89f
util.datamapper: Handle nested arrays or objects in arrays
2021-03-22 10:05:41 +01:00
Kim Alvefur
f68d29bafd
util.datamapper: Fix to skip parsing wrapped arrays that aren't there
...
Turns out the unreachable error is reachable :D
2021-03-22 10:03:32 +01:00
Kim Alvefur
110e82bd93
util.datamapper: Clear done TODO (arrays)
...
Relevant commits:
* 6a51749af7f4
* 0e00fa518688
* d1982b7eb00d
* c098d07e6717
* 348b191cd850
2021-03-21 02:26:28 +01:00
Kim Alvefur
4f191a3239
util.datamapper: Complete array building support
2021-03-20 21:29:51 +01:00
Kim Alvefur
366edae239
util.datamapper: Factor out handling of object properties for array reuse
2021-03-20 21:25:45 +01:00
Kim Alvefur
f5962d7193
util.datamapper: Finally implement support for parsing arrays
2021-03-20 20:45:06 +01:00
Kim Alvefur
87474145e5
util.datamapper: Factor out extraction of the XML part to use
...
So extract_value() takes an XML tag and details about which part we're
interested in and returns that.
Factoring this out will help with array implementation since this will
be common behavior.
2021-03-20 19:02:18 +01:00
Kim Alvefur
a51587da48
util.datamapper: Only get element name if there's an element
...
Fixes error due to attempting to index a nil value
2021-03-19 19:07:25 +01:00
Kim Alvefur
7f04df223a
util.datamapper: Fix arrays nesting one level too deep
2021-03-19 01:17:59 +01:00
Kim Alvefur
3c3cdcd0c7
util.datamapper: Deal with type name changes in util.jsonschema
2021-03-19 00:26:04 +01:00
Kim Alvefur
c1706af956
util.jsonschema: Rename types for improved readability
2021-03-18 23:57:03 +01:00
Kim Alvefur
d18097fb67
teal: Use new integer support in Teal 0.13.0
2021-03-18 23:16:41 +01:00
Kim Alvefur
576b43151c
util.datamapper: Limited support for unparsing simple arrays of strings
2021-03-18 13:07:10 +01:00
Kim Alvefur
c62c5b307e
util.datamapper: Add initial support for parsing arrays
2021-03-18 12:57:25 +01:00
Kim Alvefur
fb7df0067c
util.datamapper: Factor out common schema unpacking
...
This code extracts the bits from the schema that determines how the data
is to be mapped to/from XML.
2021-03-14 16:50:49 +01:00
Kim Alvefur
3a62af2e0e
util.datamapper: Separate extraction of xml from coercion to target type
...
Now it gets the text, attribute or name first, then turns it into
whatever the schema wants. This should be easier to further factor out
into preparation for array support.
2021-03-14 03:06:37 +01:00
Kim Alvefur
a7b010cbc5
util.datamapper: Use enum instead of mutually exclusive booleans
...
Cleaner and rules out invalid combinations.
2021-03-14 01:57:00 +01:00
Kim Alvefur
9d25c9c9ac
util.datamapper: Enumerated elements
...
E.g. error conditions or chat states.
2021-03-12 01:33:15 +01:00
Kim Alvefur
465a8b8b1a
util.datamapper: Some TODOs
2021-03-10 00:19:45 +01:00
Kim Alvefur
a09823e81c
util.datamapper: Add references with notes
2021-03-10 00:19:38 +01:00
Kim Alvefur
832296535f
util.datamapper: Add Copyright header
2021-03-10 00:18:39 +01:00
Kim Alvefur
ee7ffc309a
util.jsonschema: Add copyright-header
2021-03-10 00:15:00 +01:00
Kim Alvefur
6db9456d88
util.jsonschema: Restructure "type" keyword handling
...
More in line with the other tests
2021-03-09 14:31:11 +01:00
Kim Alvefur
44edd47ca8
util.jsonschema: Syntax tweak to not upset syntax highlighting
...
That whole condition stanza was shown as angry red, I think it's
something with 'enum' being a key word in Teal.
2021-03-09 14:22:33 +01:00
Kim Alvefur
1317e78fbb
util.jsonschema: Implement "propertyNames"
...
This is a bit special in Lua as tables are not limited to string keys
2021-03-09 02:43:50 +01:00
Kim Alvefur
d8303be145
util.jsonschema: Restructure handling of "properties" and "additionalProperties"
...
This is a bit cleaner, I think
2021-03-09 02:41:47 +01:00
Kim Alvefur
ae40825925
util.jsonschema: Fix "uniqueItems" prematurely declaring a match
2021-03-09 02:38:51 +01:00
Kim Alvefur
da85d37bcb
util.jsonschema: Implement the "prefixItems" keyword
...
This may have been what got me confused about "items" being an array.
2021-03-09 02:36:08 +01:00
Kim Alvefur
ce4040e109
util.jsonschema: Implement the "contains" keyword
...
And apparently I had mistaken this for an array
2021-03-09 02:35:00 +01:00
Kim Alvefur
5a44c4a32b
util.jsonschema: Allow a boolean as schema
...
Apparently a schema must be either an object or a boolean. Not sure
where I got this string shortcut from, but I think I will keep it as it
is very convenient.
2021-03-09 02:33:28 +01:00
Kim Alvefur
6a7346ac8e
util.jsonschema: Correct "items" keyword
...
Upon re-reading the JSON Schema spec, I found that 'items' wasn't a
union of an array of schemas or a single schema, not sure where I got
that from.
2021-03-09 02:26:05 +01:00
Kim Alvefur
07889f274d
util.datamapper: Add support for mapping of elements where only one attribute matters
...
E.g. <feature var='foo'/> in XEP-0030 and some other simple
specifications.
2021-03-07 12:48:49 +01:00