valentineus / moodle-webhooks Goto Github PK
View Code? Open in Web Editor NEWWebhooks allow applications to subscribe to Moodle events.
Home Page: https://moodle.org/plugins/local_webhooks
License: GNU General Public License v3.0
Webhooks allow applications to subscribe to Moodle events.
Home Page: https://moodle.org/plugins/local_webhooks
License: GNU General Public License v3.0
Hello dear,
can it be supported by docs and examples to understand
how it works?
thanks in advance ๐
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.
Is this webhooks plugin still supported?
Can you update it for the Moodle 3.9 and 4.x branches.
Thanks
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!
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.
The query local_webhooks_get_list_records()
runs every time an event happens, over and over returning the same result. You may consider adding some caching: https://docs.moodle.org/dev/Cache_API
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.
Ben Girard wrote about a problem:
It looks like the latest version of this plugin is no longer triggering webhooks... I'm running Moodle 3.7.1 (supported by the plugin) but when updated webhooks are no longer sent. We restarted the entire Moodle server, and no luck.
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!
When you delete an event from the calendar, an error occurs.
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?
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
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)
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.
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.
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.
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
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?
See https://tracker.moodle.org/browse/CONTRIB-7096 for details
Moodle plugins need to implement privacy API https://docs.moodle.org/dev/Privacy_API otherwise unit tests will fail.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.