{"action":"created","comment":{"url":"https://api.github.com/repos/pilight/pilight/pulls/comments/26892257","id":26892257,"diff_hunk":"@@ -0,0 +1,224 @@\n+/*\n+\tCopyright (C) 2015 CurlyMo & Niek\n+\n+\tThis file is part of pilight.\n+\n+\tpilight is free software: you can redistribute it and/or modify it under the\n+\tterms of the GNU General Public License as published by the Free Software\n+\tFoundation, either version 3 of the License, or (at your option) any later\n+\tversion.\n+\n+\tpilight is distributed in the hope that it will be useful, but WITHOUT ANY\n+\tWARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR\n+\tA PARTICULAR PURPOSE.  See the GNU General Public License for more details.\n+\n+\tYou should have received a copy of the GNU General Public License\n+\talong with pilight. If not, see\t<http://www.gnu.org/licenses/>\n+*/\n+\n+#include <stdio.h>\n+#include <stdlib.h>\n+#include <string.h>\n+#include <unistd.h>\n+\n+#include \"action.h\"\n+#include \"options.h\"\n+#include \"log.h\"\n+#include \"devices.h\"\n+#include \"dso.h\"\n+#include \"common.h\"\n+#include \"config.h\"\n+#include \"pilight.h\"\n+#include \"mail.h\"\n+#include \"sendmail.h\"\n+#include \"settings.h\"\n+\n+\n+//check arguments and settings\n+static int actionSendmailArguments(struct JsonNode *arguments) {\n+\tstruct JsonNode *jsubject = NULL;\n+\tstruct JsonNode *jmessage = NULL;\n+\tstruct JsonNode *jto = NULL;\n+\tstruct JsonNode *jvalues = NULL;\n+\tstruct JsonNode *jchild = NULL;\n+\tchar *stmp = NULL;\n+\tint nrvalues = 0, itmp = 0;\n+\t\n+\tjsubject = json_find_member(arguments, \"SUBJECT\");\n+\tjmessage = json_find_member(arguments, \"MESSAGE\");\n+\tjto = json_find_member(arguments, \"TO\");\n+\t\n+\tif(jsubject == NULL) {\n+\t\tlogprintf(LOG_ERR, \"sendmail action is missing a \\\"SUBJECT\\\"\");\n+\t\treturn -1;\n+\t}\n+\tif(jmessage == NULL) {\n+\t\tlogprintf(LOG_ERR, \"sendmail action is missing a \\\"MESSAGE\\\"\");\n+\t\treturn -1;\n+\t}\n+\tif(jto == NULL) {\n+\t\tlogprintf(LOG_ERR, \"sendmail action is missing a \\\"TO\\\"\");\n+\t\treturn -1;\n+\t}\n+\tnrvalues = 0;\n+\tif((jvalues = json_find_member(jsubject, \"value\")) != NULL) {\n+\t\tjchild = json_first_child(jvalues);\n+\t\twhile(jchild) {\n+\t\t\tnrvalues++;\n+\t\t\tjchild = jchild->next;\n+\t\t}\n+\t}\n+\tif(nrvalues > 1) {\n+\t\tlogprintf(LOG_ERR, \"sendmail action \\\"SUBJECT\\\" only takes one argument\");\n+\t\treturn -1;\n+\t}\n+\tnrvalues = 0;\n+\tif((jvalues = json_find_member(jmessage, \"value\")) != NULL) {\n+\t\tjchild = json_first_child(jvalues);\n+\t\twhile(jchild) {\n+\t\t\tnrvalues++;\n+\t\t\tjchild = jchild->next;\n+\t\t}\n+\t}\n+\tif(nrvalues != 1) {\n+\t\tlogprintf(LOG_ERR, \"sendmail action \\\"MESSAGE\\\" only takes one argument\");\n+\t\treturn -1;\n+\t}\n+\tnrvalues = 0;\n+\tif((jto = json_find_member(jmessage, \"value\")) != NULL) {","path":"libs/actions/sendmail.c","position":88,"original_position":88,"commit_id":"22cba75bb869eeb968a0a5184918936c4f37b5ed","original_commit_id":"22cba75bb869eeb968a0a5184918936c4f37b5ed","user":{"login":"CurlyMoo","id":2429105,"avatar_url":"https://avatars.githubusercontent.com/u/2429105?v=3","gravatar_id":"","url":"https://api.github.com/users/CurlyMoo","html_url":"https://github.com/CurlyMoo","followers_url":"https://api.github.com/users/CurlyMoo/followers","following_url":"https://api.github.com/users/CurlyMoo/following{/other_user}","gists_url":"https://api.github.com/users/CurlyMoo/gists{/gist_id}","starred_url":"https://api.github.com/users/CurlyMoo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CurlyMoo/subscriptions","organizations_url":"https://api.github.com/users/CurlyMoo/orgs","repos_url":"https://api.github.com/users/CurlyMoo/repos","events_url":"https://api.github.com/users/CurlyMoo/events{/privacy}","received_events_url":"https://api.github.com/users/CurlyMoo/received_events","type":"User","site_admin":false},"body":"This line is incorrect.","created_at":"2015-03-21T14:29:01Z","updated_at":"2015-03-21T14:29:01Z","html_url":"https://github.com/pilight/pilight/pull/159#discussion_r26892257","pull_request_url":"https://api.github.com/repos/pilight/pilight/pulls/159","_links":{"self":{"href":"https://api.github.com/repos/pilight/pilight/pulls/comments/26892257"},"html":{"href":"https://github.com/pilight/pilight/pull/159#discussion_r26892257"},"pull_request":{"href":"https://api.github.com/repos/pilight/pilight/pulls/159"}}},"pull_request":{"url":"https://api.github.com/repos/pilight/pilight/pulls/159","id":31671567,"html_url":"https://github.com/pilight/pilight/pull/159","diff_url":"https://github.com/pilight/pilight/pull/159.diff","patch_url":"https://github.com/pilight/pilight/pull/159.patch","issue_url":"https://api.github.com/repos/pilight/pilight/issues/159","number":159,"state":"open","locked":false,"title":"improved sendmail action","user":{"login":"NiekD","id":10514104,"avatar_url":"https://avatars.githubusercontent.com/u/10514104?v=3","gravatar_id":"","url":"https://api.github.com/users/NiekD","html_url":"https://github.com/NiekD","followers_url":"https://api.github.com/users/NiekD/followers","following_url":"https://api.github.com/users/NiekD/following{/other_user}","gists_url":"https://api.github.com/users/NiekD/gists{/gist_id}","starred_url":"https://api.github.com/users/NiekD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NiekD/subscriptions","organizations_url":"https://api.github.com/users/NiekD/orgs","repos_url":"https://api.github.com/users/NiekD/repos","events_url":"https://api.github.com/users/NiekD/events{/privacy}","received_events_url":"https://api.github.com/users/NiekD/received_events","type":"User","site_admin":false},"body":"All arguments mandatory\r\nRemoved unwanted settings\r\nAdded conditionals for EVENTS and WINDOWS\r\nApplied threading\r\nSeveral small fixes","created_at":"2015-03-21T13:54:43Z","updated_at":"2015-03-21T14:29:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"57627af0b9e4b980eb7cdccc656687d17e078254","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pilight/pilight/pulls/159/commits","review_comments_url":"https://api.github.com/repos/pilight/pilight/pulls/159/comments","review_comment_url":"https://api.github.com/repos/pilight/pilight/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pilight/pilight/issues/159/comments","statuses_url":"https://api.github.com/repos/pilight/pilight/statuses/22cba75bb869eeb968a0a5184918936c4f37b5ed","head":{"label":"NiekD:sendmail","ref":"sendmail","sha":"22cba75bb869eeb968a0a5184918936c4f37b5ed","user":{"login":"NiekD","id":10514104,"avatar_url":"https://avatars.githubusercontent.com/u/10514104?v=3","gravatar_id":"","url":"https://api.github.com/users/NiekD","html_url":"https://github.com/NiekD","followers_url":"https://api.github.com/users/NiekD/followers","following_url":"https://api.github.com/users/NiekD/following{/other_user}","gists_url":"https://api.github.com/users/NiekD/gists{/gist_id}","starred_url":"https://api.github.com/users/NiekD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NiekD/subscriptions","organizations_url":"https://api.github.com/users/NiekD/orgs","repos_url":"https://api.github.com/users/NiekD/repos","events_url":"https://api.github.com/users/NiekD/events{/privacy}","received_events_url":"https://api.github.com/users/NiekD/received_events","type":"User","site_admin":false},"repo":{"id":32548870,"name":"pilight","full_name":"NiekD/pilight","owner":{"login":"NiekD","id":10514104,"avatar_url":"https://avatars.githubusercontent.com/u/10514104?v=3","gravatar_id":"","url":"https://api.github.com/users/NiekD","html_url":"https://github.com/NiekD","followers_url":"https://api.github.com/users/NiekD/followers","following_url":"https://api.github.com/users/NiekD/following{/other_user}","gists_url":"https://api.github.com/users/NiekD/gists{/gist_id}","starred_url":"https://api.github.com/users/NiekD/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NiekD/subscriptions","organizations_url":"https://api.github.com/users/NiekD/orgs","repos_url":"https://api.github.com/users/NiekD/repos","events_url":"https://api.github.com/users/NiekD/events{/privacy}","received_events_url":"https://api.github.com/users/NiekD/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/NiekD/pilight","description":"open source domotica solution","fork":true,"url":"https://api.github.com/repos/NiekD/pilight","forks_url":"https://api.github.com/repos/NiekD/pilight/forks","keys_url":"https://api.github.com/repos/NiekD/pilight/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NiekD/pilight/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NiekD/pilight/teams","hooks_url":"https://api.github.com/repos/NiekD/pilight/hooks","issue_events_url":"https://api.github.com/repos/NiekD/pilight/issues/events{/number}","events_url":"https://api.github.com/repos/NiekD/pilight/events","assignees_url":"https://api.github.com/repos/NiekD/pilight/assignees{/user}","branches_url":"https://api.github.com/repos/NiekD/pilight/branches{/branch}","tags_url":"https://api.github.com/repos/NiekD/pilight/tags","blobs_url":"https://api.github.com/repos/NiekD/pilight/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NiekD/pilight/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NiekD/pilight/git/refs{/sha}","trees_url":"https://api.github.com/repos/NiekD/pilight/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NiekD/pilight/statuses/{sha}","languages_url":"https://api.github.com/repos/NiekD/pilight/languages","stargazers_url":"https://api.github.com/repos/NiekD/pilight/stargazers","contributors_url":"https://api.github.com/repos/NiekD/pilight/contributors","subscribers_url":"https://api.github.com/repos/NiekD/pilight/subscribers","subscription_url":"https://api.github.com/repos/NiekD/pilight/subscription","commits_url":"https://api.github.com/repos/NiekD/pilight/commits{/sha}","git_commits_url":"https://api.github.com/repos/NiekD/pilight/git/commits{/sha}","comments_url":"https://api.github.com/repos/NiekD/pilight/comments{/number}","issue_comment_url":"https://api.github.com/repos/NiekD/pilight/issues/comments{/number}","contents_url":"https://api.github.com/repos/NiekD/pilight/contents/{+path}","compare_url":"https://api.github.com/repos/NiekD/pilight/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NiekD/pilight/merges","archive_url":"https://api.github.com/repos/NiekD/pilight/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NiekD/pilight/downloads","issues_url":"https://api.github.com/repos/NiekD/pilight/issues{/number}","pulls_url":"https://api.github.com/repos/NiekD/pilight/pulls{/number}","milestones_url":"https://api.github.com/repos/NiekD/pilight/milestones{/number}","notifications_url":"https://api.github.com/repos/NiekD/pilight/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NiekD/pilight/labels{/name}","releases_url":"https://api.github.com/repos/NiekD/pilight/releases{/id}","created_at":"2015-03-19T22:10:15Z","updated_at":"2015-03-19T22:10:17Z","pushed_at":"2015-03-21T13:50:47Z","git_url":"git://github.com/NiekD/pilight.git","ssh_url":"git@github.com:NiekD/pilight.git","clone_url":"https://github.com/NiekD/pilight.git","svn_url":"https://github.com/NiekD/pilight","homepage":"www.pilight.org","size":12519,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"pilight:development","ref":"development","sha":"abf01a23ac479e5a7b623ff545f520673a743afc","user":{"login":"pilight","id":5197912,"avatar_url":"https://avatars.githubusercontent.com/u/5197912?v=3","gravatar_id":"","url":"https://api.github.com/users/pilight","html_url":"https://github.com/pilight","followers_url":"https://api.github.com/users/pilight/followers","following_url":"https://api.github.com/users/pilight/following{/other_user}","gists_url":"https://api.github.com/users/pilight/gists{/gist_id}","starred_url":"https://api.github.com/users/pilight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pilight/subscriptions","organizations_url":"https://api.github.com/users/pilight/orgs","repos_url":"https://api.github.com/users/pilight/repos","events_url":"https://api.github.com/users/pilight/events{/privacy}","received_events_url":"https://api.github.com/users/pilight/received_events","type":"Organization","site_admin":false},"repo":{"id":5966572,"name":"pilight","full_name":"pilight/pilight","owner":{"login":"pilight","id":5197912,"avatar_url":"https://avatars.githubusercontent.com/u/5197912?v=3","gravatar_id":"","url":"https://api.github.com/users/pilight","html_url":"https://github.com/pilight","followers_url":"https://api.github.com/users/pilight/followers","following_url":"https://api.github.com/users/pilight/following{/other_user}","gists_url":"https://api.github.com/users/pilight/gists{/gist_id}","starred_url":"https://api.github.com/users/pilight/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pilight/subscriptions","organizations_url":"https://api.github.com/users/pilight/orgs","repos_url":"https://api.github.com/users/pilight/repos","events_url":"https://api.github.com/users/pilight/events{/privacy}","received_events_url":"https://api.github.com/users/pilight/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pilight/pilight","description":"open source domotica solution","fork":false,"url":"https://api.github.com/repos/pilight/pilight","forks_url":"https://api.github.com/repos/pilight/pilight/forks","keys_url":"https://api.github.com/repos/pilight/pilight/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pilight/pilight/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pilight/pilight/teams","hooks_url":"https://api.github.com/repos/pilight/pilight/hooks","issue_events_url":"https://api.github.com/repos/pilight/pilight/issues/events{/number}","events_url":"https://api.github.com/repos/pilight/pilight/events","assignees_url":"https://api.github.com/repos/pilight/pilight/assignees{/user}","branches_url":"https://api.github.com/repos/pilight/pilight/branches{/branch}","tags_url":"https://api.github.com/repos/pilight/pilight/tags","blobs_url":"https://api.github.com/repos/pilight/pilight/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pilight/pilight/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pilight/pilight/git/refs{/sha}","trees_url":"https://api.github.com/repos/pilight/pilight/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pilight/pilight/statuses/{sha}","languages_url":"https://api.github.com/repos/pilight/pilight/languages","stargazers_url":"https://api.github.com/repos/pilight/pilight/stargazers","contributors_url":"https://api.github.com/repos/pilight/pilight/contributors","subscribers_url":"https://api.github.com/repos/pilight/pilight/subscribers","subscription_url":"https://api.github.com/repos/pilight/pilight/subscription","commits_url":"https://api.github.com/repos/pilight/pilight/commits{/sha}","git_commits_url":"https://api.github.com/repos/pilight/pilight/git/commits{/sha}","comments_url":"https://api.github.com/repos/pilight/pilight/comments{/number}","issue_comment_url":"https://api.github.com/repos/pilight/pilight/issues/comments{/number}","contents_url":"https://api.github.com/repos/pilight/pilight/contents/{+path}","compare_url":"https://api.github.com/repos/pilight/pilight/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pilight/pilight/merges","archive_url":"https://api.github.com/repos/pilight/pilight/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pilight/pilight/downloads","issues_url":"https://api.github.com/repos/pilight/pilight/issues{/number}","pulls_url":"https://api.github.com/repos/pilight/pilight/pulls{/number}","milestones_url":"https://api.github.com/repos/pilight/pilight/milestones{/number}","notifications_url":"https://api.github.com/repos/pilight/pilight/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pilight/pilight/labels{/name}","releases_url":"https://api.github.com/repos/pilight/pilight/releases{/id}","created_at":"2012-09-26T13:56:20Z","updated_at":"2015-03-19T22:56:17Z","pushed_at":"2015-03-21T13:56:37Z","git_url":"git://github.com/pilight/pilight.git","ssh_url":"git@github.com:pilight/pilight.git","clone_url":"https://github.com/pilight/pilight.git","svn_url":"https://github.com/pilight/pilight","homepage":"www.pilight.org","size":12519,"stargazers_count":118,"watchers_count":118,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":82,"mirror_url":null,"open_issues_count":7,"forks":82,"open_issues":7,"watchers":118,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pilight/pilight/pulls/159"},"html":{"href":"https://github.com/pilight/pilight/pull/159"},"issue":{"href":"https://api.github.com/repos/pilight/pilight/issues/159"},"comments":{"href":"https://api.github.com/repos/pilight/pilight/issues/159/comments"},"review_comments":{"href":"https://api.github.com/repos/pilight/pilight/pulls/159/comments"},"review_comment":{"href":"https://api.github.com/repos/pilight/pilight/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pilight/pilight/pulls/159/commits"},"statuses":{"href":"https://api.github.com/repos/pilight/pilight/statuses/22cba75bb869eeb968a0a5184918936c4f37b5ed"}}}}