code4recovery / 12-step-meeting-list

WordPress plugin for managing a list of weekly recovery meetings
https://wordpress.org/plugins/12-step-meeting-list/
GNU General Public License v2.0
53 stars 51 forks source link

Notify when a meeting is deleted or unpublished #503

Closed CheriJones closed 1 year ago

CheriJones commented 3 years ago

Contact Details

cherijones@cyberservices.com

Website With Issue

https://kc-aa.org

What happened?

no notification when a meeting is closed

TSML Version

Latest (default)

Wordpress Version

Other (Identify version in text above)

What browsers are you seeing the problem on?

Firefox

Relevant log output/errors

unknown
CheriJones commented 3 years ago

testing change notifications and emails are not being sent - is there something else we should do image

joshreisner commented 3 years ago

@CheriJones this all looks correct! It's just not a feature we currently have. Does seem like an oversight. I don't recall it coming up before though.

CheriJones commented 3 years ago

we are trying to cross notify between Area 39 and the central offices in our area so that everything is up to date and identical in step 1 of solving duplicate and incorrect listings - but we can't get the plugin to send notifications even for basic changes - are there instructions anywhere - question came up about how the plugin sends the email notification - is it within the TSML or is there another plugin needed

brianw-area24 commented 3 years ago

As I think more about this, it's not a very straight forward issue within TSML. The problem I see comes around the importing of feeds and/or CSV files. When you do this, it deletes the existing meetings, then creates new ones for all of the meetings in the import. Therefore, we can't just send a message when a meeting is deleted.

I do have an idea which I think would have the desired outcome, which is know when a meeting changes on another site. This would include writing a program that you would run on your computer, which would save a copy of the feed from that site into a file on your computer. If that file is in a folder that's a git repo, then you could do a "git diff" which would show you when the file changes.

Here is a start of a program that could be used to write the feed to a file. What this program does is read a feed. Then does some reformatting of the feed so each piece of information is on a separate line. It then saves this reformatted feed into a file. There are other changes I'd probably make to this file, such as deleting certain "id" fields, because they change each time a feed is refreshed. You don't need "git diff" to show these changes.

Anyway, here's a copy of the program I started. This could be used as a starting point...

<?php

get_feed('http://local.test/wp4/wp-admin/admin-ajax.php?action=meetings&key=8c44283c1a98168a3c773ec635b3086a', 'wp4.json');
//get_feed('', '');

function get_feed($feed_url, $output_file) {
    $raw = file_get_contents($feed_url);

    $output = str_replace('",', '",' . PHP_EOL . '    ', $raw);
    $output = str_replace(',"', ',' . PHP_EOL . '    "', $output);
    $output = str_replace('},{', PHP_EOL . '  },' . PHP_EOL . '  {' . PHP_EOL . '    ', $output);
    $output = str_replace('}]', PHP_EOL . '  }' . PHP_EOL . ']' . PHP_EOL, $output);
    $output = str_replace('[{', PHP_EOL . '[' . PHP_EOL . '  {' . PHP_EOL . '    ', $output);

    file_put_contents($output_file, $output);
}

If you want me to, I can do additional work to clean up this process...

kiyote33 commented 3 years ago

The Data Source Change Detection feature plugin that I'm working on does something similar to what Brian is suggesting. It came about from my first attempts to resolve issue #42 (data source automation). The new plugin will notify web admins when there is a difference between their data source feed and the contents loaded on their website. It compares live feeds to the website meeting list and sends an email when a difference is detected. The clone version has been running successfully in test for the last 3 months simulating the Area 78 website which maintains non Calgary or Edmonton meeting records, and simply pulls records from the Calgary & Edmonton central offices who maintain the records for their regions.

joshreisner commented 1 year ago

great to note that the simple way of doing this will not catch the case when a meeting is omitted from a CSV or JSON import. i think it's ok though to move forward with this request and just consider that gap a disadvantage of maintaining your list externally