Prevent to check notifications for remote accounts

This commit is contained in:
Thomas 2021-01-02 18:20:36 +01:00
parent b7855cb1a2
commit 950d99b5de
2 changed files with 19 additions and 2 deletions

View File

@ -236,6 +236,23 @@ public class AccountDAO {
}
/**
* Returns all Peertube Account only in db
*
* @return Account List<Account>
*/
public List<Account> getAllPeertubeAccount() {
try {
Cursor c = db.query(Sqlite.TABLE_USER_ACCOUNT, null, Sqlite.COL_SOFTWARE + "=? OR " + Sqlite.COL_SOFTWARE + "is null", new String[]{"PEERTUBE"}, null, null, Sqlite.COL_INSTANCE + " ASC", null);
return cursorToListUser(c);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* Returns an Account by token
*

View File

@ -79,7 +79,7 @@ public class NotificationsWorker extends Worker {
public Result doWork() {
Context applicationContext = getApplicationContext();
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
List<AccountData.Account> accounts = new AccountDAO(applicationContext, db).getAllAccount();
List<AccountData.Account> accounts = new AccountDAO(applicationContext, db).getAllPeertubeAccount();
if (accounts == null || accounts.size() == 0) {
return Result.success();
}
@ -92,7 +92,7 @@ public class NotificationsWorker extends Worker {
@SuppressWarnings({"SwitchStatementWithoutDefaultBranch", "DuplicateBranchesInSwitch"})
private void fetchNotification() {
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
List<AccountData.Account> accounts = new AccountDAO(getApplicationContext(), db).getAllAccount();
List<AccountData.Account> accounts = new AccountDAO(getApplicationContext(), db).getAllPeertubeAccount();
SharedPreferences sharedpreferences = getApplicationContext().getSharedPreferences(Helper.APP_PREFS, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedpreferences.edit();
for (AccountData.Account account : accounts) {