}
int pakfire_job_handle_message(struct pakfire_job* self, struct json_object* message) {
+ const char* command = NULL;
+ int r;
+
DEBUG(self->ctx, "Message received for job %s\n", self->id);
- return 0; // XXX TODO
+ // Fetch the command
+ r = pakfire_json_get_string(message, "command", &command);
+ if (r < 0) {
+ ERROR(self->ctx, "Malformed job message does not contain a command\n");
+ return r;
+ }
+
+ // Abort job
+ if (pakfire_string_equals(command, "abort"))
+ return pakfire_job_terminate(self, SIGTERM);
+
+ // Log an error if we have received an unknown command
+ ERROR(self->ctx, "Unhandled command for job %s: %s\n", self->id, command);
+
+ return 0;
}
#endif /* CURL_HAS_WEBSOCKETS */