Manage moderators/admins for Pleroma
This commit is contained in:
parent
3a222d88a0
commit
f2b9edb9f0
|
@ -3863,9 +3863,18 @@ public class API {
|
|||
account.setSocial("MASTODON");
|
||||
}
|
||||
try{
|
||||
if( resobj.has("pleroma") )
|
||||
if( resobj.has("pleroma") ) {
|
||||
account.setSocial("PLEROMA");
|
||||
try{
|
||||
account.setModerator(resobj.getJSONObject("pleroma").getBoolean("is_moderator"));
|
||||
account.setAdmin(resobj.getJSONObject("pleroma").getBoolean("is_admin"));
|
||||
}catch (Exception ignored){
|
||||
account.setModerator(false);
|
||||
account.setAdmin(false);
|
||||
}
|
||||
}
|
||||
}catch (Exception ignored){}
|
||||
|
||||
try {
|
||||
JSONArray fields = resobj.getJSONArray("fields");
|
||||
LinkedHashMap<String, String> fieldsMap = new LinkedHashMap<>();
|
||||
|
|
|
@ -114,6 +114,8 @@ public class Account implements Parcelable {
|
|||
private String client_id;
|
||||
private String client_secret;
|
||||
private String refresh_token;
|
||||
private boolean isModerator = false;
|
||||
private boolean isAdmin = false;
|
||||
|
||||
|
||||
|
||||
|
@ -166,6 +168,8 @@ public class Account implements Parcelable {
|
|||
dest.writeString(this.client_id);
|
||||
dest.writeString(this.client_secret);
|
||||
dest.writeString(this.refresh_token);
|
||||
dest.writeByte(this.isModerator ? (byte) 1 : (byte) 0);
|
||||
dest.writeByte(this.isAdmin ? (byte) 1 : (byte) 0);
|
||||
}
|
||||
|
||||
public Account() {
|
||||
|
@ -215,6 +219,8 @@ public class Account implements Parcelable {
|
|||
this.client_id = in.readString();
|
||||
this.client_secret = in.readString();
|
||||
this.refresh_token = in.readString();
|
||||
this.isModerator = in.readByte() != 0;
|
||||
this.isAdmin = in.readByte() != 0;
|
||||
}
|
||||
|
||||
public static final Creator<Account> CREATOR = new Creator<Account>() {
|
||||
|
@ -350,6 +356,22 @@ public class Account implements Parcelable {
|
|||
this.refresh_token = refresh_token;
|
||||
}
|
||||
|
||||
public boolean isModerator() {
|
||||
return isModerator;
|
||||
}
|
||||
|
||||
public void setModerator(boolean moderator) {
|
||||
isModerator = moderator;
|
||||
}
|
||||
|
||||
public boolean isAdmin() {
|
||||
return isAdmin;
|
||||
}
|
||||
|
||||
public void setAdmin(boolean admin) {
|
||||
isAdmin = admin;
|
||||
}
|
||||
|
||||
|
||||
public enum followAction{
|
||||
FOLLOW,
|
||||
|
|
|
@ -26,7 +26,7 @@ import android.database.sqlite.SQLiteOpenHelper;
|
|||
|
||||
public class Sqlite extends SQLiteOpenHelper {
|
||||
|
||||
public static final int DB_VERSION = 24;
|
||||
public static final int DB_VERSION = 25;
|
||||
public static final String DB_NAME = "mastodon_etalab_db";
|
||||
public static SQLiteDatabase db;
|
||||
private static Sqlite sInstance;
|
||||
|
@ -86,6 +86,8 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||
static final String COL_CLIENT_ID = "CLIENT_ID";
|
||||
static final String COL_CLIENT_SECRET = "CLIENT_SECRET";
|
||||
static final String COL_REFRESH_TOKEN = "REFRESH_TOKEN";
|
||||
static final String COL_IS_MODERATOR = "IS_MODERATOR";
|
||||
static final String COL_IS_ADMIN = "IS_ADMIN";
|
||||
|
||||
private static final String CREATE_TABLE_USER_ACCOUNT = "CREATE TABLE " + TABLE_USER_ACCOUNT + " ("
|
||||
+ COL_USER_ID + " TEXT PRIMARY KEY, " + COL_USERNAME + " TEXT NOT NULL, " + COL_ACCT + " TEXT NOT NULL, "
|
||||
|
@ -96,6 +98,8 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||
+ COL_HEADER + " TEXT NOT NULL, "+ COL_HEADER_STATIC + " TEXT NOT NULL, "
|
||||
+ COL_EMOJIS + " TEXT, "
|
||||
+ COL_SOCIAL + " TEXT, "
|
||||
+ COL_IS_MODERATOR + " INTEGER DEFAULT 0, "
|
||||
+ COL_IS_ADMIN + " INTEGER DEFAULT 0, "
|
||||
+ COL_CLIENT_ID + " TEXT, " + COL_CLIENT_SECRET + " TEXT, " + COL_REFRESH_TOKEN + " TEXT,"
|
||||
+ COL_INSTANCE + " TEXT NOT NULL, " + COL_OAUTHTOKEN + " TEXT NOT NULL, " + COL_CREATED_AT + " TEXT NOT NULL)";
|
||||
|
||||
|
@ -318,6 +322,9 @@ public class Sqlite extends SQLiteOpenHelper {
|
|||
db.execSQL("ALTER TABLE " + TABLE_USER_ACCOUNT + " ADD COLUMN " + COL_CLIENT_ID + " TEXT");
|
||||
db.execSQL("ALTER TABLE " + TABLE_USER_ACCOUNT + " ADD COLUMN " + COL_CLIENT_SECRET + " TEXT");
|
||||
db.execSQL("ALTER TABLE " + TABLE_USER_ACCOUNT + " ADD COLUMN " + COL_REFRESH_TOKEN + " TEXT");
|
||||
case 24:
|
||||
db.execSQL("ALTER TABLE " + TABLE_USER_ACCOUNT + " ADD COLUMN " + COL_IS_MODERATOR + " INTEGER DEFAULT 0");
|
||||
db.execSQL("ALTER TABLE " + TABLE_USER_ACCOUNT + " ADD COLUMN " + COL_IS_ADMIN + " INTEGER DEFAULT 0");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue