Commit Graph

50 Commits

Author SHA1 Message Date
Gabriel Grubba 57b460737c
FEATURE: add topic tags changed trigger to chat integration (#208)
* FEATURE: add topic tags changed trigger to chat integration

* FEATURE: add placeholder for reply to topic trigger

add description on how to use the placeholder

* DEV: Move slack message creation to provider

Add tests to new method

* FEATURE: add ${URL} to placeholder replacements and added tags link

If triggered when a topic tag is changed, message behavior will follow what user defined in message.

* DEV: Update tests with tags

* DEV: add post to topic for testing

* DEV: update test strings

* DEV: add early return for topic tags changed trigger

* DEV: move early return to use try/catch

* DEV: update `create_slack_message` to not send a tuple of values

* DEV: refactor method to be more readable

* FEATURE: add `${ADDED_AND_REMOVED}` for default texts

* DEV: Update typo in test

* DEV: Add tests to check when if `create_slack_message` raises an error

* DEV: Remove the `tag_added` from chat-integration filter

Added migration to handle the migration of the `tag_added` filter from the chat-integration plugin.

Only removed the logic from the plugin, data removal will happen in a future PR

* DEV: lint migration file

* DEV: update chat-integration to not show "tag_added" rules

* DEV: update added and missing tags logic

* DEV: update context variable name

* DEV: update migration to include `begin/rescue` block and added a list with available filters
2024-08-13 15:14:35 -03:00
Isaac Janzen 8b8a6ae8af
Revert "Revert "DEV: Explicitly register problem check (#191)" (#192)" (#193)
Reverts discourse/discourse-chat-integration#192

Reimplement https://github.com/discourse/discourse-chat-integration/pull/191 as the Discourse Core CI issue was unrelated.
2024-04-03 14:51:19 -06:00
Isaac Janzen 048e8d595a
Revert "DEV: Explicitly register problem check (#191)" (#192)
Reverts discourse/discourse-chat-integration#191

This is causing Discourse Core CI to fail, so reverting for now.

```
	64: from bin/rake:13:in `<main>'
	63: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:80:in `run'
	62: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:208:in `standard_exception_handling'
	61: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:83:in `block in run'
	60: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:132:in `top_level'
	59: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:147:in `run_with_threads'
	58: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:138:in `block in top_level'
	57: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:138:in `each'
	56: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:138:in `block (2 levels) in top_level'
	55: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/application.rb:182:in `invoke_task'
	54: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:188:in `invoke'
	53: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:199:in `invoke_with_call_chain'
	52: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:199:in `synchronize'
	51: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
	50: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:241:in `invoke_prerequisites'
	49: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:241:in `each'
	48: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:243:in `block in invoke_prerequisites'
	47: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:199:in `invoke_with_call_chain'
	46: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:199:in `synchronize'
	45: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
	44: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:241:in `invoke_prerequisites'
	43: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:241:in `each'
	42: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:243:in `block in invoke_prerequisites'
	41: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:199:in `invoke_with_call_chain'
	40: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:199:in `synchronize'
	39: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
	38: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:281:in `execute'
	37: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:281:in `each'
	36: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/rake-13.1.0/lib/rake/task.rb:281:in `block in execute'
	35: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/railties-7.0.8.1/lib/rails/application.rb:506:in `block in run_tasks_blocks'
	34: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/railties-7.0.8.1/lib/rails/application.rb:348:in `require_environment!'
	33: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/zeitwerk-2.6.13/lib/zeitwerk/kernel.rb:34:in `require'
	32: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/bootsnap-1.18.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
	31: from <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
	30: from <internal:/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
	29: from /__w/discourse/discourse/config/environment.rb:7:in `<main>'
	28: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/railties-7.0.8.1/lib/rails/application.rb:372:in `initialize!'
	27: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/railties-7.0.8.1/lib/rails/initializable.rb:60:in `run_initializers'
	26: from /usr/local/lib/ruby/3.2.0/tsort.rb:205:in `tsort_each'
	25: from /usr/local/lib/ruby/3.2.0/tsort.rb:226:in `tsort_each'
	24: from /usr/local/lib/ruby/3.2.0/tsort.rb:347:in `each_strongly_connected_component'
	23: from /usr/local/lib/ruby/3.2.0/tsort.rb:347:in `call'
	22: from /usr/local/lib/ruby/3.2.0/tsort.rb:347:in `each'
	21: from /usr/local/lib/ruby/3.2.0/tsort.rb:349:in `block in each_strongly_connected_component'
	20: from /usr/local/lib/ruby/3.2.0/tsort.rb:431:in `each_strongly_connected_component_from'
	19: from /usr/local/lib/ruby/3.2.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	18: from /usr/local/lib/ruby/3.2.0/tsort.rb:228:in `block in tsort_each'
	17: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/railties-7.0.8.1/lib/rails/initializable.rb:61:in `block in run_initializers'
	16: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/railties-7.0.8.1/lib/rails/initializable.rb:32:in `run'
	15: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/railties-7.0.8.1/lib/rails/initializable.rb:32:in `instance_exec'
	14: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/railties-7.0.8.1/lib/rails/application/finisher.rb:87:in `block in <module:Finisher>'
	13: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.1/lib/active_support/lazy_load_hooks.rb:75:in `run_load_hooks'
	12: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.1/lib/active_support/lazy_load_hooks.rb:75:in `each'
	11: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.1/lib/active_support/lazy_load_hooks.rb:76:in `block in run_load_hooks'
	10: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.1/lib/active_support/lazy_load_hooks.rb:90:in `execute_hook'
	9: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.1/lib/active_support/lazy_load_hooks.rb:85:in `with_execution_control'
	8: from /__w/discourse/discourse/vendor/bundle/ruby/3.2.0/gems/activesupport-7.0.8.1/lib/active_support/lazy_load_hooks.rb:92:in `block in execute_hook'
	7: from /__w/discourse/discourse/config/application.rb:239:in `block in <class:Application>'
	6: from /__w/discourse/discourse/lib/plugin.rb:6:in `initialization_guard'
	5: from /__w/discourse/discourse/config/application.rb:239:in `block (2 levels) in <class:Application>'
	4: from /__w/discourse/discourse/config/application.rb:239:in `each'
	3: from /__w/discourse/discourse/lib/plugin/instance.rb:555:in `notify_after_initialize'
	2: from /__w/discourse/discourse/lib/plugin/instance.rb:555:in `each'
	1: from /__w/discourse/discourse/lib/plugin/instance.rb:557:in `block in notify_after_initialize'
/__w/discourse/discourse/plugins/discourse-chat-integration/plugin.rb:25:in `block in activate!': undefined method `register_problem_check' for #<Plugin::Instance:0x00007f1a7c7491e8 @metadata=#<Plugin::Metadata:0x00007f1a80b4de98 @name="discourse-chat-integration", @about="Allows integration with several external chat system providers", @meta_topic_id=66522, @version="0.1", @url="https://github.com/discourse/discourse-chat-integration">, @path="/__w/discourse/discourse/plugins/discourse-chat-integration/plugin.rb", @idx=0, @enabled_site_setting=:chat_integration_enabled, @assets=[["/__w/discourse/discourse/plugins/discourse-chat-integration/assets/stylesheets/chat-integration.scss", nil, "discourse-chat-integration"]], @directory_name="discourse-chat-integration", @initializers=[#<Proc:0x00007f1a7aea3058 /__w/discourse/discourse/plugins/discourse-chat-integration/plugin.rb:20>], @styles=[], @javascripts=[], @locales=[], @service_workers=[], @seed_data={}, @extra_js_file_path="/__w/discourse/discourse/app/assets/javascripts/plugins/discourse-chat-integration_extra.js", @asset_filters=[], @color_schemes=[]> (NoMethodError)

** INCOMPATIBLE PLUGIN **

You are unable to start Discourse due to errors in the plugin at
/__w/discourse/discourse/plugins/discourse-chat-integration
```
2024-04-03 13:37:52 -06:00
Ted Johansson 05a0a32a47
DEV: Explicitly register problem check (#191) 2024-04-03 14:17:10 +08:00
Ted Johansson f0275f1591
DEV: Promote channel error check to ProblemCheck (#190)
We're promoting problem checks to first class citizens in core. This migrates the problem check to the new API.

In the process of adding tests for this check, I discovered what seems like a mistake that likely means this check never worked until now. (See inline comment.)
2024-03-15 13:21:11 +08:00
Loïc Guitaut 0badc2bc22 DEV: Fix linting 2024-03-05 15:57:30 +01:00
Loïc Guitaut 4f737df97e
DEV: Fix new Rubocop offenses (#188)
* DEV: Fix new Rubocop offenses

---------

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2024-03-04 16:01:07 +01:00
Jarek Radosz 30ac835e1d
FIX: Form validation bugs, new modal api, glimmer (#182) 2023-12-11 20:00:34 +01:00
Jarek Radosz bc81d30dc8
DEV: Update linting (#181) 2023-11-29 23:01:31 +01:00
David Taylor 3860d82625
FIX: Update transcript handling following core updates (#179) 2023-11-27 12:04:54 +00:00
Martin Brennan a6dfc289a4
DEV: Metadata update for plugin.rb (#178)
* Adding Meta Topic ID

* Updating about metadata

---------

Co-authored-by: AlexDev <104522507+alexdevlaeminck@users.noreply.github.com>
2023-11-08 11:27:54 -08:00
David Taylor 49956bf829
DEV: Introduce syntax_tree for ruby formatting (#149) 2022-12-29 13:31:05 +01:00
David Taylor 3900586557
FIX: Correct error in AdminDashboardData problem check (#119)
This would cause admin checks to fail when the plugin is disabled.

Unfortunately plugin-contributed AdminDashboardData checks are not currently testable, but I hope to fix that in a future core commit.

Follow-up to 8de3e498b2
2022-03-31 12:14:40 +01:00
David Taylor 8de3e498b2
FIX: Only show admin dashboard errors when plugin/provider enabled (#117) 2022-03-25 15:53:49 +00:00
Jarek Radosz 46cdce24bd
DEV: Lose the es6 suffix (#110) 2022-03-04 19:27:42 +01:00
Blake Erickson 0eebd9f3ed
DEV: Adds post_to_slack scriptable for automation (#108)
This allows for the discourse automation plugin to have a "Send Slack
Message" script.

The script fields are a message, url, and slack channel. This will allow
for a custom slack message to be posted but can link back to an
arbitrary url (hopefully a discourse url) like a list of unanswered
topics instead of strictly only allowing a slack message that links back
to a Discourse Post object.
2022-02-25 12:17:20 -07:00
Mark VanLandingham a8b7e9631b
DEV: Move admin namespace (#87) 2021-08-26 08:52:53 -05:00
Mark VanLandingham a73f5da114
Rename DiscourseChat to DiscourseChatIntegration (#82) 2021-07-13 14:36:16 -05:00
Michael K Johnson da9106127a
FEATURE: Enable optional support for threading slack posts (#38)
When creating a new Discourse post from slack with the `post` feature, record the
slack `ts` thread ID for the resulting topic post using an HTML comment to pass
the `ts` through.

When notifying slack of new Discourse posts, record the slack `ts` thread ID in
the post's topic if it has not yet been recorded. (Normally, this will be done
for the topic post, except where notifications are being posted for old topics
before this feature was created.)

Add a new rule filter `thread` which posts threaded responses to slack if there
is a `ts` recorded for the post topic.

Modify the `trigger_notifications` interface to enable other integrations to
implement similar functionality.

Present the `thread` rule in the help text and admin UI only for the slack
providers.

https://meta.discourse.org/t/optionally-threading-posts-to-parent-topic-in-slack-integration/150759
2020-06-15 16:45:25 +01:00
Guo Xiang Tan ac288b9300 Add frozen string literal comment to files. 2019-05-13 10:37:49 +08:00
David Taylor 790f1bb8b5
DEV: Remove unnecessary semicolon 2018-12-04 11:45:17 +00:00
Gerhard Schlager c9ff8d8cb6 FIX: Relative links in translations should work with subfolder 2018-11-07 23:26:36 +01:00
Penar Musaraj 762300ab22 Avoid targetting "fa-" icon in test, prepare for FA5 in Discourse core 2018-11-01 18:03:39 -04:00
David Taylor fc721a1768 FEATURE: Improve channel error visibility in the admin panel, stop adding chat integration errors to logs 2018-08-20 12:06:10 +01:00
Guo Xiang Tan efddfe1d9b Minor refactor. 2017-10-10 10:08:26 +08:00
David Taylor 4f9ad4efef Correct rubocop offenses 2017-08-01 20:53:39 +01:00
David Taylor 964fb07c50 Move require_relative lines into the initializer 2017-07-20 15:37:45 +01:00
David Taylor bdb81191d7 New admin interface for improved channel definitions 2017-07-18 16:17:03 +01:00
David Taylor bfb499d4cf Refactor into /app directory, move everything out of plugin.rb 2017-07-13 13:32:11 +01:00
David Taylor 56da3639ab Use real ActiveRecord for the “Rule” model by extending the PluginStoreRow class.
This gives us all the activerecord awesomeness for free, like validations, safe form params etc.
2017-07-12 18:28:45 +01:00
David Taylor e4ff1997c8 Add a helper class for common provider functionality
Initially implemented a ‘status_for_channel’ function, based on the existing slack plugin
2017-07-05 23:00:58 +01:00
David Taylor 95344c348f Allow filtering of rules by channel 2017-07-05 22:38:53 +01:00
David Taylor 2f6d6f0d54 Automatically mount provider’s engines at /chat-integration/{provider_name}
Provider controllers are automatically disabled when the provider is disabled (works the same way as plugin controllers)
2017-07-05 15:03:02 +01:00
David Taylor aaaffdf371 Add ‘send test message’ functionality to the admin interface 2017-07-04 23:35:45 +01:00
David Taylor d97d35fd0d Handle errors on trigger_notification
Providers can define their own errors, and these are presented in the user interface. e.g. Slack can define an error that says “That channel doesn’t exist”.
Errors in the UI disappear once a message has been sent successfully, or the rule is edited.
2017-07-04 19:37:56 +01:00
David Taylor 4be010fd07 Allow providers to specify a regex that the channel identifier is checked against during validation 2017-07-04 00:14:01 +01:00
David Taylor 444e380ca1 Tidy up admin user interface 2017-07-03 22:11:17 +01:00
David Taylor 0547543a1d Add server-side validation to rules 2017-07-03 17:38:13 +01:00
David Taylor f40f602a4f Add validation to slack settings (adapted from old slack plugin) 2017-07-03 16:28:26 +01:00
David Taylor 1c416d5a81 Allow providers to be disabled, and tidy up translations 2017-07-03 15:53:26 +01:00
David Taylor 4643ad255c Rename plugin to discourse-chat-integration 2017-07-03 11:08:14 +01:00
David Taylor 4ad9ad6a7a Move lib files inside a discourse_chat directory, and make the notifications run on a delay after post creation 2017-06-30 11:10:11 +01:00
David Taylor 8d70b4ad46 Allow add, edit & delete in the admin UI 2017-06-29 20:19:40 +01:00
David Taylor 61caca3c5b Use new DiscourseChat::Rule model throughout the backend code 2017-06-29 17:50:54 +01:00
David Taylor cd3bd8d807 Add a “Rule” class, borrowing and extending the ActiveRecord-like design from data-explorer plugin 2017-06-29 17:01:04 +01:00
David Taylor 8e0bec6e6f Use RestModel and buildPluginAdapter to deal with communication of data models between client and server 2017-06-28 22:32:02 +01:00
David Taylor d8e5494d4c Add (currently read-only) UI to the admin panel, displaying all existing rules. Dynamic routes created for each registered provider. 2017-06-28 15:12:37 +01:00
David Taylor 02692cf100 Added filtering logic for multiple providers, along with many RSpec tests.
General structure of the filter rules is taken from discourse-slack-official, but re-written to be more robust and easier to understand.
2017-06-27 19:43:29 +01:00
David Taylor 3967e2cd91 Created basic system to allow multiple integrations to register themselves, creating a separate tab in the admin interface for each one. 2017-06-26 19:19:50 +01:00
David Taylor 3e3a309c44 Initial commit 2017-06-26 15:08:06 +01:00