feat(workflows): add "attribute action" action
This action lets users perform several actions on threads, such as
(un)lock, (un)set as trending, (un)pin, set as non-issue, obsolete, etc.
The action selector shows the action with the codename it has in the
Protobuf enum. We will show a friendly string when we localize the
feature.
Bug: twpowertools:74
Change-Id: I95f9f1904ffe559c92a786cbdb327613c8ca32ca
diff --git a/src/contentScripts/communityConsole/workflows/actionRunners/attribute.js b/src/contentScripts/communityConsole/workflows/actionRunners/attribute.js
new file mode 100644
index 0000000..bec2511
--- /dev/null
+++ b/src/contentScripts/communityConsole/workflows/actionRunners/attribute.js
@@ -0,0 +1,20 @@
+import {CCApi} from '../../../../common/api.js';
+import {getAuthUser} from '../../../../common/communityConsoleUtils.js';
+
+export default class AttributeRunner {
+ async execute(attributeAction, thread) {
+ if (!attributeAction) {
+ throw new Error(
+ 'The workflow is malformed. The attribute action is missing.');
+ }
+ const action = attributeAction.getAttributeAction();
+
+ return await CCApi(
+ 'SetThreadAttribute', {
+ 1: thread.forumId,
+ 2: thread.threadId,
+ 3: action,
+ },
+ /* authenticated = */ true, getAuthUser());
+ }
+}