Allow moderator and admin to delete toots

This commit is contained in:
stom79 2019-01-27 11:10:50 +01:00
parent f2b9edb9f0
commit 5928feebe5
3 changed files with 20 additions and 1 deletions

View File

@ -104,6 +104,8 @@ public class UpdateAccountInfoAsyncTask extends AsyncTask<Void, Void, Void> {
boolean userExists = new AccountDAO(this.contextReference.get(), db).userExist(account);
SharedPreferences.Editor editor = sharedpreferences.edit();
editor.putString(Helper.PREF_KEY_ID, account.getId());
editor.putBoolean(Helper.PREF_IS_MODERATOR, account.isModerator());
editor.putBoolean(Helper.PREF_IS_ADMINISTRATOR, account.isAdmin());
editor.putString(Helper.PREF_INSTANCE, instance);
editor.apply();
if( userExists)

View File

@ -477,6 +477,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
boolean share_details = sharedpreferences.getBoolean(Helper.SET_SHARE_DETAILS, true);
boolean confirmFav = sharedpreferences.getBoolean(Helper.SET_NOTIF_VALIDATION_FAV, false);
boolean confirmBoost = sharedpreferences.getBoolean(Helper.SET_NOTIF_VALIDATION, true);
boolean isModerator = sharedpreferences.getBoolean(Helper.PREF_IS_MODERATOR, false);
boolean isAdmin = sharedpreferences.getBoolean(Helper.PREF_IS_ADMINISTRATOR, false);
int translator = sharedpreferences.getInt(Helper.SET_TRANSLATOR, Helper.TRANS_YANDEX);
int behaviorWithAttachments = sharedpreferences.getInt(Helper.SET_ATTACHMENT_ACTION, Helper.ATTACHMENT_ALWAYS);
if (type != RetrieveFeedsAsyncTask.Type.REMOTE_INSTANCE && !isCompactMode && displayBookmarkButton)
@ -1650,7 +1654,10 @@ public class StatusListAdapter extends RecyclerView.Adapter implements OnPostAct
stringArrayConf = context.getResources().getStringArray(R.array.more_action_owner_confirm);
} else {
popup.getMenu().findItem(R.id.action_redraft).setVisible(false);
popup.getMenu().findItem(R.id.action_remove).setVisible(false);
if( MainActivity.social == UpdateAccountInfoAsyncTask.SOCIAL.PLEROMA && (isAdmin || isModerator))
popup.getMenu().findItem(R.id.action_remove).setVisible(true);
else
popup.getMenu().findItem(R.id.action_remove).setVisible(false);
//Same instance
if (status.getAccount().getAcct().split("@").length < 2)
popup.getMenu().findItem(R.id.action_block_domain).setVisible(false);

View File

@ -201,6 +201,8 @@ public class Helper {
public static final String PREF_KEY_ID = "userID";
public static final String PREF_IS_MODERATOR = "is_moderator";
public static final String PREF_IS_ADMINISTRATOR = "is_administrator";
public static final String PREF_INSTANCE = "instance";
public static final String REDIRECT_CONTENT = "urn:ietf:wg:oauth:2.0:oob";
public static final String REDIRECT_CONTENT_WEB = "mastalab://backtomastalab";
@ -533,6 +535,8 @@ public class Helper {
editor.putString(Helper.CLIENT_ID, null);
editor.putString(Helper.CLIENT_SECRET, null);
editor.putString(Helper.PREF_KEY_ID, null);
editor.putBoolean(Helper.PREF_IS_MODERATOR, false);
editor.putBoolean(Helper.PREF_IS_ADMINISTRATOR, false);
editor.putString(Helper.PREF_INSTANCE, null);
editor.putString(Helper.ID, null);
editor.apply();
@ -1347,6 +1351,8 @@ public class Helper {
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, account.getToken());
editor.putString(Helper.PREF_KEY_ID, account.getId());
editor.putString(Helper.PREF_INSTANCE, account.getInstance().trim());
editor.putBoolean(Helper.PREF_IS_MODERATOR, account.isModerator());
editor.putBoolean(Helper.PREF_IS_ADMINISTRATOR, account.isAdmin());
editor.commit();
Intent changeAccount = new Intent(activity, MainActivity.class);
changeAccount.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
@ -1678,6 +1684,8 @@ public class Helper {
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, accountChoice.getToken());
editor.putString(Helper.PREF_KEY_ID, accountChoice.getId());
editor.putString(Helper.PREF_INSTANCE, accountChoice.getInstance().trim());
editor.putBoolean(Helper.PREF_IS_MODERATOR, accountChoice.isModerator());
editor.putBoolean(Helper.PREF_IS_ADMINISTRATOR, accountChoice.isAdmin());
editor.commit();
if(accountChoice.getSocial() != null && accountChoice.getSocial().equals("PEERTUBE"))
Toasty.info(activity, activity.getString(R.string.toast_account_changed, "@" + accountChoice.getAcct()), Toast.LENGTH_LONG).show();
@ -1731,6 +1739,8 @@ public class Helper {
editor.putString(Helper.PREF_KEY_OAUTH_TOKEN, accountChoice.getToken());
editor.putString(Helper.PREF_KEY_ID, accountChoice.getId());
editor.putString(Helper.PREF_INSTANCE, accountChoice.getInstance().trim());
editor.putBoolean(Helper.PREF_IS_MODERATOR, accountChoice.isModerator());
editor.putBoolean(Helper.PREF_IS_ADMINISTRATOR, accountChoice.isAdmin());
editor.commit();
Intent changeAccount = new Intent(activity, MainActivity.class);
changeAccount.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);