processone / ejabberd-contrib

Growing and curated ejabberd contributions repository - PR or ask to join !
http://ejabberd.im
250 stars 140 forks source link

mod_cron: ctl "function" needs argument, even if empty #308

Closed sando38 closed 2 years ago

sando38 commented 2 years ago

Refering to the changes from #307 , it may be notable, that once I run a ctl command like

mod_cron: 
    tasks:
      - time: 1
        units: days
        ctl: delete_expired_pubsub_items
        arguments:
          - ""

without the arguments section, the module fails to load/ start. The example below does not work:

mod_cron: 
    tasks:
      - time: 1
        units: days
        ctl: delete_expired_pubsub_items
#        arguments:
#         - ""
sando38 commented 2 years ago

One more thing, when I use the following config:

    # purge expired offline messages
      - time: 12
        units: hours
        ctl: delete_expired_messages
        arguments:
          - ""

I recieve the following error:

Error: the command 'delete_expired_messages' requires 1 less argument.
  Command Name: delete_expired_messages

  Arguments: 

  Returns: res::rescode

  Tags: purge

  Module: unknown

  Description: Delete expired offline messages from database

Error: the command 'delete_expired_messages' requires 1 less argument.

If I put away the argument, the module fails to start as said in the initial post.

badlop commented 2 years ago
        arguments:
          - ""

Umm, no, this should be:

        arguments: []

I've added this explanation to the README.

without the arguments section, the module fails to load/ start.

Ok, I've fixed that, now it works.

sando38 commented 2 years ago

ahh.. thanks for the hint with the brackets [] Yes. It works as said. And good idea to create a default value.

As mentioned in the other issue, it might be a good idea to include the module as a "core" module into the ejabberd package, since with the ctl commands, it can help administrators to schedule some maintenance tasks in an easy going way.