aboutsummaryrefslogtreecommitdiff
path: root/QSThingsPlugin/Actions/CompleteTaskAction.m
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2025-09-10 16:12:55 +0200
committerRuben Beltran del Rio <git@r.bdr.sh>2025-09-10 16:12:55 +0200
commit7cf393095282077b0bbae3046826b67f4f20a8eb (patch)
tree9aaf5704cbb8612bf78378aefa40ae40e79a7850 /QSThingsPlugin/Actions/CompleteTaskAction.m
parentc4705a0a678ac523b243c7b68ce27fbf5e44b61a (diff)
Add auth key + complete task action
Diffstat (limited to 'QSThingsPlugin/Actions/CompleteTaskAction.m')
-rw-r--r--QSThingsPlugin/Actions/CompleteTaskAction.m41
1 files changed, 41 insertions, 0 deletions
diff --git a/QSThingsPlugin/Actions/CompleteTaskAction.m b/QSThingsPlugin/Actions/CompleteTaskAction.m
new file mode 100644
index 0000000..9673840
--- /dev/null
+++ b/QSThingsPlugin/Actions/CompleteTaskAction.m
@@ -0,0 +1,41 @@
+#import "CompleteTaskAction.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@implementation CompleteTaskAction
+
+- (QSObject *)completeTask:(QSObject *)directObject
+{
+ NSSet *validTypes = [NSSet setWithObjects:kProjectType, kTaskType, nil];
+ NSString *authenticationKey = [KeychainHelper authenticationKey];
+
+ if (!authenticationKey) {
+ NSLog(@"There is no authentication key.");
+ }
+
+ if (authenticationKey && [validTypes containsObject:directObject.primaryType]) {
+ NSDictionary *contents = [directObject objectForType:directObject.primaryType];
+ NSString *path = @"update";
+ if (directObject.primaryType == kProjectType) {
+ path = @"update-project";
+ }
+ if (contents) {
+ NSString *uuid = [contents objectForKey:@"uuid"];
+ if (uuid) {
+ NSString *urlString = [NSString stringWithFormat:@"things:///%@?id=%@&auth-token=%@&completed=true", path, uuid, authenticationKey];
+ NSURL *url = [NSURL URLWithString:urlString];
+
+ [[NSWorkspace sharedWorkspace] openURL:url];
+ } else {
+ NSLog(@"Things object did not have a uuid.");
+ }
+ } else {
+ NSLog(@"Could not get the contents of the Things object.");
+ }
+ }
+ return directObject;
+}
+
+@end
+
+NS_ASSUME_NONNULL_END