{"action":"created","comment":{"url":"https://api.github.com/repos/k9mail/k-9/pulls/comments/237722582","pull_request_review_id":180094355,"id":237722582,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNzcyMjU4Mg==","diff_hunk":"@@ -0,0 +1,82 @@\n+package com.fsck.k9.job\n+\n+import com.evernote.android.job.JobManager\n+import com.fsck.k9.Preferences\n+import timber.log.Timber\n+\n+class K9JobManager(\n+        private val jobManager: JobManager,\n+        private val jobCreator: K9JobCreator,\n+        private val preferences: Preferences\n+) {\n+\n+    init {\n+        jobManager.addJobCreator(jobCreator)\n+    }\n+\n+    fun scheduleAllMailJobs() {\n+        Timber.v(TAG, \"scheduling all jobs\")\n+        scheduleMailSync()\n+        schedulePusherRefresh()\n+    }\n+\n+    fun scheduleMailSync() {\n+        cancelAllMailSyncJobs()\n+\n+        getMailSyncIntervalIfEnabled()?.takeUnless {\n+            preferences.availableAccounts.isEmpty()\n+        }?.let { syncInterval ->\n+            Timber.v(TAG, \"scheduling mail sync job\")\n+            jobCreator.mailSyncJob.scheduleJob(syncInterval)\n+        }\n+    }\n+\n+    fun schedulePusherRefresh() {\n+        cancelAllPusherRefreshJobs()\n+\n+        getMailSyncIntervalIfEnabled()?.takeUnless {\n+            preferences.availableAccounts.isEmpty()\n+        }?.let { syncInterval ->\n+            Timber.v(TAG, \"scheduling pusher refresh job\")\n+            jobCreator.pusherRefreshJob.scheduleJob(syncInterval)\n+        }\n+    }\n+\n+    fun cancellAllJobs() {\n+        cancelAllMailSyncJobs()\n+        cancelAllPusherRefreshJobs()\n+    }\n+\n+    fun cancelAllMailSyncJobs() {\n+        Timber.v(TAG, \"canceling mail sync job\")\n+        jobManager.cancelAllForTag(MailSyncJob.TAG)\n+    }\n+\n+    fun cancelAllPusherRefreshJobs() {\n+        Timber.v(TAG, \"canceling pusher refresh job\")\n+        jobManager.cancelAllForTag(PusherRefreshJob.TAG)\n+    }\n+\n+    /**\n+     * Set the mail sync interval used to schedule mail related jobs\n+     *\n+     * @param syncInterval Time interval in milliseconds. Must be at least 15 minutes\n+     * @see K9SyncInterval class for pre-defined for values e.g. K9SyncInterval.INTERVAL_15_MINS\n+     */\n+    fun setMailSyncInterval(syncInterval: Long) {\n+        preferences.storage.edit().putLong(MAIL_SYNC_INTERVAL_KEY, syncInterval).commit()\n+    }\n+\n+    private fun getMailSyncIntervalIfEnabled(): Long? {","path":"app/core/src/main/java/com/fsck/k9/job/K9JobManager.kt","position":70,"original_position":70,"commit_id":"5ac7f5a16c02fa5f087836fb65a1aa40390bcee0","original_commit_id":"fc90ffeb6c2df5c607f786960a0c25e366adfda4","user":{"login":"ojiofong","id":10760543,"node_id":"MDQ6VXNlcjEwNzYwNTQz","avatar_url":"https://avatars1.githubusercontent.com/u/10760543?v=4","gravatar_id":"","url":"https://api.github.com/users/ojiofong","html_url":"https://github.com/ojiofong","followers_url":"https://api.github.com/users/ojiofong/followers","following_url":"https://api.github.com/users/ojiofong/following{/other_user}","gists_url":"https://api.github.com/users/ojiofong/gists{/gist_id}","starred_url":"https://api.github.com/users/ojiofong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ojiofong/subscriptions","organizations_url":"https://api.github.com/users/ojiofong/orgs","repos_url":"https://api.github.com/users/ojiofong/repos","events_url":"https://api.github.com/users/ojiofong/events{/privacy}","received_events_url":"https://api.github.com/users/ojiofong/received_events","type":"User","site_admin":false},"body":"Didn't know we have that. Will take a look. Thanks","created_at":"2018-11-30T01:48:29Z","updated_at":"2018-11-30T01:48:30Z","html_url":"https://github.com/k9mail/k-9/pull/3763#discussion_r237722582","pull_request_url":"https://api.github.com/repos/k9mail/k-9/pulls/3763","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/k9mail/k-9/pulls/comments/237722582"},"html":{"href":"https://github.com/k9mail/k-9/pull/3763#discussion_r237722582"},"pull_request":{"href":"https://api.github.com/repos/k9mail/k-9/pulls/3763"}},"in_reply_to_id":237610298},"pull_request":{"url":"https://api.github.com/repos/k9mail/k-9/pulls/3763","id":234375593,"node_id":"MDExOlB1bGxSZXF1ZXN0MjM0Mzc1NTkz","html_url":"https://github.com/k9mail/k-9/pull/3763","diff_url":"https://github.com/k9mail/k-9/pull/3763.diff","patch_url":"https://github.com/k9mail/k-9/pull/3763.patch","issue_url":"https://api.github.com/repos/k9mail/k-9/issues/3763","number":3763,"state":"open","locked":false,"title":"WIP: Change mail sync to work with background execution limits","user":{"login":"ojiofong","id":10760543,"node_id":"MDQ6VXNlcjEwNzYwNTQz","avatar_url":"https://avatars1.githubusercontent.com/u/10760543?v=4","gravatar_id":"","url":"https://api.github.com/users/ojiofong","html_url":"https://github.com/ojiofong","followers_url":"https://api.github.com/users/ojiofong/followers","following_url":"https://api.github.com/users/ojiofong/following{/other_user}","gists_url":"https://api.github.com/users/ojiofong/gists{/gist_id}","starred_url":"https://api.github.com/users/ojiofong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ojiofong/subscriptions","organizations_url":"https://api.github.com/users/ojiofong/orgs","repos_url":"https://api.github.com/users/ojiofong/repos","events_url":"https://api.github.com/users/ojiofong/events{/privacy}","received_events_url":"https://api.github.com/users/ojiofong/received_events","type":"User","site_admin":false},"body":"\r\n\r\n\r\n","created_at":"2018-11-28T18:11:11Z","updated_at":"2018-11-30T01:48:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"fd01b42f144d1fd2c9f60fd687faffcbb4c1ded8","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/k9mail/k-9/pulls/3763/commits","review_comments_url":"https://api.github.com/repos/k9mail/k-9/pulls/3763/comments","review_comment_url":"https://api.github.com/repos/k9mail/k-9/pulls/comments{/number}","comments_url":"https://api.github.com/repos/k9mail/k-9/issues/3763/comments","statuses_url":"https://api.github.com/repos/k9mail/k-9/statuses/5ac7f5a16c02fa5f087836fb65a1aa40390bcee0","head":{"label":"ojiofong:oji_mail_sync","ref":"oji_mail_sync","sha":"5ac7f5a16c02fa5f087836fb65a1aa40390bcee0","user":{"login":"ojiofong","id":10760543,"node_id":"MDQ6VXNlcjEwNzYwNTQz","avatar_url":"https://avatars1.githubusercontent.com/u/10760543?v=4","gravatar_id":"","url":"https://api.github.com/users/ojiofong","html_url":"https://github.com/ojiofong","followers_url":"https://api.github.com/users/ojiofong/followers","following_url":"https://api.github.com/users/ojiofong/following{/other_user}","gists_url":"https://api.github.com/users/ojiofong/gists{/gist_id}","starred_url":"https://api.github.com/users/ojiofong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ojiofong/subscriptions","organizations_url":"https://api.github.com/users/ojiofong/orgs","repos_url":"https://api.github.com/users/ojiofong/repos","events_url":"https://api.github.com/users/ojiofong/events{/privacy}","received_events_url":"https://api.github.com/users/ojiofong/received_events","type":"User","site_admin":false},"repo":{"id":157802462,"node_id":"MDEwOlJlcG9zaXRvcnkxNTc4MDI0NjI=","name":"k-9","full_name":"ojiofong/k-9","private":false,"owner":{"login":"ojiofong","id":10760543,"node_id":"MDQ6VXNlcjEwNzYwNTQz","avatar_url":"https://avatars1.githubusercontent.com/u/10760543?v=4","gravatar_id":"","url":"https://api.github.com/users/ojiofong","html_url":"https://github.com/ojiofong","followers_url":"https://api.github.com/users/ojiofong/followers","following_url":"https://api.github.com/users/ojiofong/following{/other_user}","gists_url":"https://api.github.com/users/ojiofong/gists{/gist_id}","starred_url":"https://api.github.com/users/ojiofong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ojiofong/subscriptions","organizations_url":"https://api.github.com/users/ojiofong/orgs","repos_url":"https://api.github.com/users/ojiofong/repos","events_url":"https://api.github.com/users/ojiofong/events{/privacy}","received_events_url":"https://api.github.com/users/ojiofong/received_events","type":"User","site_admin":false},"html_url":"https://github.com/ojiofong/k-9","description":"K-9 Mail – Advanced Email for Android 📧","fork":true,"url":"https://api.github.com/repos/ojiofong/k-9","forks_url":"https://api.github.com/repos/ojiofong/k-9/forks","keys_url":"https://api.github.com/repos/ojiofong/k-9/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ojiofong/k-9/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ojiofong/k-9/teams","hooks_url":"https://api.github.com/repos/ojiofong/k-9/hooks","issue_events_url":"https://api.github.com/repos/ojiofong/k-9/issues/events{/number}","events_url":"https://api.github.com/repos/ojiofong/k-9/events","assignees_url":"https://api.github.com/repos/ojiofong/k-9/assignees{/user}","branches_url":"https://api.github.com/repos/ojiofong/k-9/branches{/branch}","tags_url":"https://api.github.com/repos/ojiofong/k-9/tags","blobs_url":"https://api.github.com/repos/ojiofong/k-9/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ojiofong/k-9/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ojiofong/k-9/git/refs{/sha}","trees_url":"https://api.github.com/repos/ojiofong/k-9/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ojiofong/k-9/statuses/{sha}","languages_url":"https://api.github.com/repos/ojiofong/k-9/languages","stargazers_url":"https://api.github.com/repos/ojiofong/k-9/stargazers","contributors_url":"https://api.github.com/repos/ojiofong/k-9/contributors","subscribers_url":"https://api.github.com/repos/ojiofong/k-9/subscribers","subscription_url":"https://api.github.com/repos/ojiofong/k-9/subscription","commits_url":"https://api.github.com/repos/ojiofong/k-9/commits{/sha}","git_commits_url":"https://api.github.com/repos/ojiofong/k-9/git/commits{/sha}","comments_url":"https://api.github.com/repos/ojiofong/k-9/comments{/number}","issue_comment_url":"https://api.github.com/repos/ojiofong/k-9/issues/comments{/number}","contents_url":"https://api.github.com/repos/ojiofong/k-9/contents/{+path}","compare_url":"https://api.github.com/repos/ojiofong/k-9/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ojiofong/k-9/merges","archive_url":"https://api.github.com/repos/ojiofong/k-9/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ojiofong/k-9/downloads","issues_url":"https://api.github.com/repos/ojiofong/k-9/issues{/number}","pulls_url":"https://api.github.com/repos/ojiofong/k-9/pulls{/number}","milestones_url":"https://api.github.com/repos/ojiofong/k-9/milestones{/number}","notifications_url":"https://api.github.com/repos/ojiofong/k-9/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ojiofong/k-9/labels{/name}","releases_url":"https://api.github.com/repos/ojiofong/k-9/releases{/id}","deployments_url":"https://api.github.com/repos/ojiofong/k-9/deployments","created_at":"2018-11-16T02:39:53Z","updated_at":"2018-11-28T17:57:10Z","pushed_at":"2018-11-29T21:23:22Z","git_url":"git://github.com/ojiofong/k-9.git","ssh_url":"git@github.com:ojiofong/k-9.git","clone_url":"https://github.com/ojiofong/k-9.git","svn_url":"https://github.com/ojiofong/k-9","homepage":"https://k9mail.github.io","size":58097,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"k9mail:master","ref":"master","sha":"0f33a43a8cc4ffeff9ead653c50dcebe760c373c","user":{"login":"k9mail","id":567044,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU2NzA0NA==","avatar_url":"https://avatars2.githubusercontent.com/u/567044?v=4","gravatar_id":"","url":"https://api.github.com/users/k9mail","html_url":"https://github.com/k9mail","followers_url":"https://api.github.com/users/k9mail/followers","following_url":"https://api.github.com/users/k9mail/following{/other_user}","gists_url":"https://api.github.com/users/k9mail/gists{/gist_id}","starred_url":"https://api.github.com/users/k9mail/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/k9mail/subscriptions","organizations_url":"https://api.github.com/users/k9mail/orgs","repos_url":"https://api.github.com/users/k9mail/repos","events_url":"https://api.github.com/users/k9mail/events{/privacy}","received_events_url":"https://api.github.com/users/k9mail/received_events","type":"Organization","site_admin":false},"repo":{"id":1326671,"node_id":"MDEwOlJlcG9zaXRvcnkxMzI2Njcx","name":"k-9","full_name":"k9mail/k-9","private":false,"owner":{"login":"k9mail","id":567044,"node_id":"MDEyOk9yZ2FuaXphdGlvbjU2NzA0NA==","avatar_url":"https://avatars2.githubusercontent.com/u/567044?v=4","gravatar_id":"","url":"https://api.github.com/users/k9mail","html_url":"https://github.com/k9mail","followers_url":"https://api.github.com/users/k9mail/followers","following_url":"https://api.github.com/users/k9mail/following{/other_user}","gists_url":"https://api.github.com/users/k9mail/gists{/gist_id}","starred_url":"https://api.github.com/users/k9mail/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/k9mail/subscriptions","organizations_url":"https://api.github.com/users/k9mail/orgs","repos_url":"https://api.github.com/users/k9mail/repos","events_url":"https://api.github.com/users/k9mail/events{/privacy}","received_events_url":"https://api.github.com/users/k9mail/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/k9mail/k-9","description":"K-9 Mail – Advanced Email for Android 📧","fork":false,"url":"https://api.github.com/repos/k9mail/k-9","forks_url":"https://api.github.com/repos/k9mail/k-9/forks","keys_url":"https://api.github.com/repos/k9mail/k-9/keys{/key_id}","collaborators_url":"https://api.github.com/repos/k9mail/k-9/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/k9mail/k-9/teams","hooks_url":"https://api.github.com/repos/k9mail/k-9/hooks","issue_events_url":"https://api.github.com/repos/k9mail/k-9/issues/events{/number}","events_url":"https://api.github.com/repos/k9mail/k-9/events","assignees_url":"https://api.github.com/repos/k9mail/k-9/assignees{/user}","branches_url":"https://api.github.com/repos/k9mail/k-9/branches{/branch}","tags_url":"https://api.github.com/repos/k9mail/k-9/tags","blobs_url":"https://api.github.com/repos/k9mail/k-9/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/k9mail/k-9/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/k9mail/k-9/git/refs{/sha}","trees_url":"https://api.github.com/repos/k9mail/k-9/git/trees{/sha}","statuses_url":"https://api.github.com/repos/k9mail/k-9/statuses/{sha}","languages_url":"https://api.github.com/repos/k9mail/k-9/languages","stargazers_url":"https://api.github.com/repos/k9mail/k-9/stargazers","contributors_url":"https://api.github.com/repos/k9mail/k-9/contributors","subscribers_url":"https://api.github.com/repos/k9mail/k-9/subscribers","subscription_url":"https://api.github.com/repos/k9mail/k-9/subscription","commits_url":"https://api.github.com/repos/k9mail/k-9/commits{/sha}","git_commits_url":"https://api.github.com/repos/k9mail/k-9/git/commits{/sha}","comments_url":"https://api.github.com/repos/k9mail/k-9/comments{/number}","issue_comment_url":"https://api.github.com/repos/k9mail/k-9/issues/comments{/number}","contents_url":"https://api.github.com/repos/k9mail/k-9/contents/{+path}","compare_url":"https://api.github.com/repos/k9mail/k-9/compare/{base}...{head}","merges_url":"https://api.github.com/repos/k9mail/k-9/merges","archive_url":"https://api.github.com/repos/k9mail/k-9/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/k9mail/k-9/downloads","issues_url":"https://api.github.com/repos/k9mail/k-9/issues{/number}","pulls_url":"https://api.github.com/repos/k9mail/k-9/pulls{/number}","milestones_url":"https://api.github.com/repos/k9mail/k-9/milestones{/number}","notifications_url":"https://api.github.com/repos/k9mail/k-9/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/k9mail/k-9/labels{/name}","releases_url":"https://api.github.com/repos/k9mail/k-9/releases{/id}","deployments_url":"https://api.github.com/repos/k9mail/k-9/deployments","created_at":"2011-02-04T02:40:00Z","updated_at":"2018-11-30T00:46:05Z","pushed_at":"2018-11-30T00:45:58Z","git_url":"git://github.com/k9mail/k-9.git","ssh_url":"git@github.com:k9mail/k-9.git","clone_url":"https://github.com/k9mail/k-9.git","svn_url":"https://github.com/k9mail/k-9","homepage":"https://k9mail.github.io","size":59373,"stargazers_count":4107,"watchers_count":4107,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":1961,"mirror_url":null,"archived":false,"open_issues_count":881,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":1961,"open_issues":881,"watchers":4107,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/k9mail/k-9/pulls/3763"},"html":{"href":"https://github.com/k9mail/k-9/pull/3763"},"issue":{"href":"https://api.github.com/repos/k9mail/k-9/issues/3763"},"comments":{"href":"https://api.github.com/repos/k9mail/k-9/issues/3763/comments"},"review_comments":{"href":"https://api.github.com/repos/k9mail/k-9/pulls/3763/comments"},"review_comment":{"href":"https://api.github.com/repos/k9mail/k-9/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/k9mail/k-9/pulls/3763/commits"},"statuses":{"href":"https://api.github.com/repos/k9mail/k-9/statuses/5ac7f5a16c02fa5f087836fb65a1aa40390bcee0"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ojiofong"}}