reapit / foundations

Foundations platform mono repo
57 stars 21 forks source link

Webhooks firing hundreds of times a day/week more than expected #11121

Open Sandy-Galbraith opened 5 months ago

Sandy-Galbraith commented 5 months ago

Our webhooks are firing seemingly for data we aren't actually consuming on our website. Is there a way to control what changes actually fire the webhooks? e.g. notes updates shouldn't, attrbute changes should

Website: www.galbraithgroup.com

This is since the start of May: image

Any guidance on what I may be doing wrong in our webhook handler is appreciated

namespace ****.Webhooks.Handlers
{
    [ReapitWebhookTopic("properties.modified")]
    public class PropertiesModifiedHandler : PropertiesHandler, IHandler
    {
        public PropertiesModifiedHandler(JObject data, IPropertyContentManager contentManager, IReapitService reapitService, UmbracoHelper Umbraco)
            : base(data, contentManager, reapitService, Umbraco) { }

        public async Task Execute()
        {
            if (!Validate())
            {
                contentManager.DeletePropertyPage(property.Old.Id);
                return;
            }

            //Get the full Property object so that the extra fields can be populated
            var fullProperty = (await reapitService.GetProperties(propIds: new List<string> { property.New.Id })).Properties.FirstOrDefault();

            if (fullProperty != null)
            {
                //Update page
                await contentManager.CreateOrUpdatePropertyPage(fullProperty, false, true);
            }
        }
    }
}
plittlewood-rpt commented 5 months ago

HI @Sandy-Galbraith we have a feature still in beta that allows you to build up your own event filters which I think is what you are wanting to do. The documentation can be found at https://foundations-documentation.reapit.cloud/api/webhooks#building-event-filters. If this is something you want to have a play with, please can you drop a note over to sinfo@reapitfoundations.zendesk.com and I can get the relevant Swagger documentation over to you?

Sandy-Galbraith commented 5 months ago

Hi @plittlewood-rpt, thanks for this! I'd had a look over the filter info once before but I didn't really get it at the time. I'll ping an email over and see if I can make something in the future that might work for us.