Giter Club home page Giter Club logo

moodle-webhooks's People

Contributors

valentineus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

moodle-webhooks's Issues

Docs

Hello dear,
can it be supported by docs and examples to understand
how it works?

thanks in advance ๐Ÿ‘

Improve response logging

The relevant part of locallib.php which sets the string to be logged in the response_answer event is:

$status = 'Error sending request';
if (!empty($response['HTTP/1.1'])) {
$status = $response['HTTP/1.1'];
}

This leads, for instance, when response is 'HTTP/2' that the log gets written "Error sending request" and nothing else.

I'd suggest something like:

$status = json_encode($response);

to get more information logged, or at least also check for the HTTP/2 field of the response.

New version

Is this webhooks plugin still supported?

Can you update it for the Moodle 3.9 and 4.x branches.

Thanks

Setting to enable/disable handling events with (disabled value by default)

When installing the plugin in the old-school way ๐Ÿ™‚ , I mean, by placing the plugin in the local dir on the server first and then accessing the site, you start observing an error with accessing the plugin's database table. This is because the plugin isn't installed yet, the table isn't created as well, but the plugin has already started listening to Moodle's events, even without having been installed.

The solution would be to introduce a plugin's setting to enable/disable listening to events, and set it as 'disabled' by default. This would in general allow to control the plugin's listening to Moodle's events. Sometimes you may want to disable it even after installing the pluign for some reason.

Cheers!

"token" Column doesn't allow JWT: JSON Web Tokens

We are using the webhooks plugin to integrate with our SIS and it seems that the "tokens" DB column doesn't allow values bigger than 255 characters.

We've gone ahead and adjusted this to text via a DB script to fix the issue.

We are also in the process of adjusting the install and adding an upgrade to the plugin to fix this issue for all our clients.

Use 'Authorization' header in requests

It would be really handy if this plugin could populate the Authorization header with Bearer $token in the HTTP requests that are sent to a configured webhook.

In my scenario, I'm hosting the webhooks as Lambda functions behind AWS API Gateway, and API Gateway's custom authorizers don't support reading from the request's POST body. If this plugin sent the token in the request's Authorization header, I'd be able to create a custom authorizer that could validate the provided function, and decouple my authentication logic from each individual function that sits behind API Gateway.

I'm not too familiar with PHP or Moodle plugin development, but if it's as simple as modifying lib.php's local_webhooks_send_request() function to set the header, I'm happy to open a PR.

checked events list not saved

Hello,

i'm running a fresh install of Moodle 3.5.2 (Build: 20180910) with WebHook 3.0.1 (Build: 2018061900) and the list of checked events is never saved.

After some debugging, it showed up that after calling $mform->get_data() (editservice.php:59) the resulting $data object either has an empty events property or no events at all, while inspecting $_POST shows that events checkboxes array are actually there.

It looks like there's a problem with the backslashes used as the keys for the events array.
As a quick and dirty fix, I tried replacing the backslashes with an arbitrary char sequence and got everything saved as expected.

Here's what I did (note that my code refers the the v3.0.0-stable branch)
file classes/service_form.php, changed

/* Formation of the list of elements */
foreach ($eventlist as $event) {
    $events[$event["component"]][] =& $mform->createElement("checkbox", $event["eventname"], $event["eventname"]);
}

to

/* Formation of the list of elements */
foreach ($eventlist as $event) php
    // replace backslashes with 'XXX'
    $events[$event["component"]][] =& $mform->createElement("checkbox", str_replace("\\","XXX",$event["eventname"]), $event["eventname"]);
}

file classes/handler.php in the events method, changed

foreach ($callbacks as $callback) {
    self::handler_callback($data, $callback);
}

to

foreach ($callbacks as $callback) {
    // replace 'XXX' with the backslash
    foreach ($callback->events as $k=>$v) {
        $callback->events[str_replace("XXX","\\",$k)] = $v;
        unset($callback->events[$k]);
    }
    self::handler_callback($data, $callback);
}

Are you experiencing a similar issue? Shall we think of a more reliable way to fix it?

Cheers!

Install.xml Path Incorrect

When I copied the files to the folder /local/webhooks I got an error at install saying that the path in install.xml was incorrect. In the original the value is blocks/local_webhooks/db.

I changed this to local/webhooks/db it still complained, but did create the table and completed the install.

is the value blocks/local_webhooks/db correct or had you created this folder seperately?

Directory where to install this plugin

Hi, I'm trying to install it into my server but I'm not sure where should I uncompress or clone the code here. I tried doing it under {root}/repository but it failed to install. Any idea? Thanks

Error: The event name or namespace is invalid.

After successfully installing the plugin, I tried to "Add service".

An error appears:

"Coding error detected, it must be fixed by a programmer: The event name or namespace is invalid."

Any idea? We can not debug it. On a local basic Moodle installation on a virtual machine it works.

Plugin Version:

WebHookslocal_webhooks 3.0.5 (Build: 2020051600)2020051600

Moodle Version:
Moodle 3.9.6+ (Build: 20210330)

Call API endpoints asynchronously

At some point API end points could be slow. This will slow down Moodle operations related to the configured events.
The solution could be to have a configuration option to run web hooks asynchronously via adhoc tasks or cron task.

[Issue] Undefined error with moodle 3.8.5

Hi,
I have recently downloaded moodle 3.8.5 and moodle-webhooks 3.0.5 ( Build: 2020051600) and after setting webhook up, it wasn't working. I have checked moodle logs and haven't found help there, except information that there was an error sending request. Webhook has been tested, that part is working. So, I assume the issue is within plugin for handling webhooks.

Let me know if you need any more informations.

Performance: is it worth gzcompress the events list?

I can imagine the list of events is typically quite short as the external system is interested in particular events only. I am wondering if the constant decompressing is actually needed as it happens for every record in the table, on every page request. On bigger sites, this might have negative impact on the performance.

Disabled Events From WebApi

I need webhooks not to be triggered by WebAPI rest calls as it'll cause a never ending loop of events with my remote system.
I put this in the handler as a short term fix:
if($_POST['ignorewebhooks']=='true')
{
return;
}
I use the MoodleRest PHP SDK so it's easy for me to add addition data to the API post, but it might be worth enabling other methods of the webhooks not being triggered?
client IP address?
bool value on the chosen event

Good work thanks

Expand response

Hi, is it possibile to expand the json response from webhook? For example course_created has only name and id, is it possibile to have start date and end date too?

Plugin notification saying new version is available, but installation fails

When attempting to upgrade the plugin via the install on the Moodle plugin web to our Moodle instance, I see a message saying the plugin is already installed, then you are redirected to upload the ZIP. Uploading the zip result in the following error:

Debugging output enabled
ZIP /opt/bitnami/apps/moodle/moodledata/temp/tool_installaddon/9d368625-eba7-437d-8ac2-47fce87ff93d/plugin.zip
Validating local_webhooks ... Error
  [OK] Name of the plugin to be installed [webhooks]  
  [OK] Plugin version [2018061920] 
  [OK] Required Moodle version [2016112900] 
  [OK] Full component name [local_webhooks] 
  [OK] Declared maturity level [MATURITY_STABLE]  
  [OK] Plugin release [3.0.3 (Build: 2019021700)] 
  [Debug] Found language file [local_webhooks] 
  [OK] Write access check [/opt/bitnami/apps/moodle/htdocs/local] 
  [Warning] Target location already exists and will be removed [/opt/bitnami/apps/moodle/htdocs/local/webhooks]  
  [Error] Write access check [/opt/bitnami/apps/moodle/htdocs/local/webhooks] 
Installation aborted due to validation failure

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.