Skip to content
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
19 changes: 19 additions & 0 deletions data/lua.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,25 @@ Optionally you can set \`synchronous\`, which will cause "100 Continue"
header to be sent.`
},

{
name: 'set_event',
args: {
value: {
type: 'event',
text: `Event to be used as parent event.`
},
},
tags: [ 'http_request' ],
text: `Pass the parent event to be used for this request.`
},

{
name: 'get_event',
tags: [ 'http_request' ],
return: `An event object`,
text: `Returns the event used by the http_request.`
},

{
name: 'submit',
return: `An http_response object.`,
Expand Down
23 changes: 22 additions & 1 deletion docs/core/admin/lua/lib_lua.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,42 @@ When script is loaded, `script_init()` function is called, if found.
if necessary.
:::

To use an event in script_init(), use the dovecot.event() API call.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit title still has : instead of .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah fixed now.

This returns an event that uses the script event as its parent.

```lua
function script_init()
local event = dovecot.event()
event:log_debug("log message")
return 0
end
```

## De-initialization

When script is being unloaded, `script_deinit()` function is called, if found.

## C API

### `struct event *dlua_check_event(lua_State *L, int arg)`

Check the argument with index `arg` from stack and try to convert
it to an Dovecot Event. Throws an error if the argument is not a valid
Dovecot Event.

### `void dlua_dovecot_register(struct dlua_script *script)`

Register dovecot variable. This item can also be extended by context specific
tables, like authentication database adds `dovecot.auth`.

### `void dlua_push_event(struct event *event)`
### `void dlua_push_event(lua_State *L, struct event *event)`

Pushes an Dovecot Event to stack.

### `void dlua_push_timeval(lua_State *L, const struct timeval *tv)`

Pushes an timeval struct to stack as integer.

## Lua API

### Base Functions
Expand Down