Merge branch 'develop' into pixelfed_oauth
This commit is contained in:
commit
a85ca83386
|
@ -7,8 +7,8 @@ android {
|
|||
applicationId "fr.gouv.etalab.mastodon"
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 28
|
||||
versionCode 251
|
||||
versionName "1.78.0"
|
||||
versionCode 252
|
||||
versionName "1.79.0-beta-1"
|
||||
multiDexEnabled true
|
||||
}
|
||||
dexOptions {
|
||||
|
|
|
@ -2007,6 +2007,9 @@ public class TootActivity extends BaseActivity implements OnPostActionInterface,
|
|||
if(restored != -1){
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusStoredDAO(getApplicationContext(), db).remove(restored);
|
||||
}else if(currentToId != -1){
|
||||
SQLiteDatabase db = Sqlite.getInstance(getApplicationContext(), Sqlite.DB_NAME, null, Sqlite.DB_VERSION).open();
|
||||
new StatusStoredDAO(getApplicationContext(), db).remove(currentToId);
|
||||
}
|
||||
//Clear the toot
|
||||
toot_content.setText("");
|
||||
|
|
|
@ -318,9 +318,7 @@ public class Status implements Parcelable{
|
|||
|
||||
public void setContent(String content) {
|
||||
//Remove UTM by default
|
||||
this.content = content.replaceAll("&utm_\\w+=[0-9a-zA-Z._-]*", "");
|
||||
this.content = this.content.replaceAll("&utm_\\w+=[0-9a-zA-Z._-]*", "");
|
||||
this.content = this.content.replaceAll("\\?utm_\\w+=[0-9a-zA-Z._-]*", "?");
|
||||
this.content = Helper.remove_tracking_param(content);
|
||||
}
|
||||
|
||||
public Status getReblog() {
|
||||
|
|
|
@ -19,6 +19,10 @@ public class Version implements Comparable<Version> {
|
|||
public Version(String version) {
|
||||
if(version == null)
|
||||
version = "2.1";
|
||||
if( version.contains("+")){
|
||||
String[] versionA = version.split("\\+");
|
||||
version = versionA[0];
|
||||
}
|
||||
if( version.endsWith("."))
|
||||
version = version.substring(0, version.length() - 1);
|
||||
version = version.replaceAll("[^\\d.]", "");
|
||||
|
|
|
@ -453,6 +453,8 @@ public class Helper {
|
|||
TOOT
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Converts emojis in input to unicode
|
||||
* @param input String
|
||||
|
@ -3759,6 +3761,47 @@ public class Helper {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* List from ClearUrls
|
||||
* https://gitlab.com/KevinRoebert/ClearUrls/blob/master/data/data.min.json#L106
|
||||
*/
|
||||
private static final String[] UTM_PARAMS = {
|
||||
"utm_\\w+",
|
||||
"ga_source",
|
||||
"ga_medium",
|
||||
"ga_term",
|
||||
"ga_content",
|
||||
"ga_campaign",
|
||||
"ga_place",
|
||||
"yclid",
|
||||
"_openstat",
|
||||
"fb_action_ids",
|
||||
"fb_action_types",
|
||||
"fb_source",
|
||||
"fb_ref",
|
||||
"fbclid",
|
||||
"action_object_map",
|
||||
"action_type_map",
|
||||
"action_ref_map",
|
||||
"gs_l",
|
||||
"mkt_tok",
|
||||
"hmb_campaign",
|
||||
"hmb_medium",
|
||||
"hmb_source",
|
||||
"[\\?|&]ref[\\_]?"
|
||||
|
||||
};
|
||||
|
||||
public static String remove_tracking_param(String original_content){
|
||||
if( original_content == null)
|
||||
return original_content;
|
||||
String cleaned_content = original_content;
|
||||
for(String utm: UTM_PARAMS){
|
||||
cleaned_content = cleaned_content.replaceAll("&"+utm+"=[0-9a-zA-Z._-]*", "");
|
||||
cleaned_content = cleaned_content.replaceAll("&"+utm+"=[0-9a-zA-Z._-]*", "");
|
||||
cleaned_content = cleaned_content.replaceAll("\\?"+utm+"=[0-9a-zA-Z._-]*", "?");
|
||||
}
|
||||
return cleaned_content;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ import android.preference.PreferenceManager;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.LocalBroadcastManager;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.DataSource;
|
||||
import com.bumptech.glide.load.engine.GlideException;
|
||||
|
@ -61,6 +60,7 @@ import java.util.HashMap;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
|
@ -129,7 +129,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
List<Account> accountStreams = new AccountDAO(getApplicationContext(), db).getAllAccountCrossAction();
|
||||
if (accountStreams != null) {
|
||||
for (final Account accountStream : accountStreams) {
|
||||
if( accountStream.getSocial() == null || accountStream.getSocial().equals("MASTODON")) {
|
||||
if( accountStream.getSocial() == null || accountStream.getSocial().equals("MASTODON") || accountStream.getSocial().equals("PLEROMA")) {
|
||||
thread = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -145,15 +145,15 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
}else {
|
||||
String key = account.getAcct() + "@" + account.getInstance();
|
||||
if(webSocketFutures.containsKey(key)){
|
||||
if (webSocketFutures.get(key) != null && webSocketFutures.get(key).isOpen()) {
|
||||
if (webSocketFutures.get(key) != null && Objects.requireNonNull(webSocketFutures.get(key)).isOpen()) {
|
||||
try {
|
||||
webSocketFutures.get(key).close();
|
||||
Objects.requireNonNull(webSocketFutures.get(key)).close();
|
||||
}catch (Exception ignored){}
|
||||
}
|
||||
}
|
||||
if(threads.containsKey(key)){
|
||||
if (threads.get(key) != null && !threads.get(key).isAlive()) {
|
||||
threads.get(key).interrupt();
|
||||
if (threads.get(key) != null && !Objects.requireNonNull(threads.get(key)).isAlive()) {
|
||||
Objects.requireNonNull(threads.get(key)).interrupt();
|
||||
}
|
||||
}
|
||||
Thread thread = new Thread() {
|
||||
|
@ -220,13 +220,16 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
headers.add("Connection", "Keep-Alive");
|
||||
headers.add("method", "GET");
|
||||
headers.add("scheme", "https");
|
||||
String urlKey = "wss://" + account.getInstance() + "/api/v1/streaming/?stream=user:notification&access_token=" + account.getToken();
|
||||
String notif_url = "user:notification";
|
||||
if( account.getSocial().toUpperCase().equals("PLEROMA"))
|
||||
notif_url = "user";
|
||||
String urlKey = "wss://" + account.getInstance() + "/api/v1/streaming/?stream="+notif_url+"&access_token=" + account.getToken();
|
||||
Uri url = Uri.parse(urlKey);
|
||||
AsyncHttpRequest.setDefaultHeaders(headers, url);
|
||||
if( webSocketFutures.containsKey(urlKey) ){
|
||||
try {
|
||||
if( webSocketFutures.get(urlKey) != null && webSocketFutures.get(urlKey).isOpen())
|
||||
webSocketFutures.get(urlKey).close();
|
||||
Objects.requireNonNull(webSocketFutures.get(urlKey)).close();
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
if( Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT ) {
|
||||
|
@ -239,7 +242,7 @@ public class LiveNotificationService extends Service implements NetworkStateRece
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
AsyncHttpClient.getDefaultInstance().websocket("wss://" + account.getInstance() + "/api/v1/streaming/?stream=user:notification&access_token=" + account.getToken(), "wss", new AsyncHttpClient.WebSocketConnectCallback() {
|
||||
AsyncHttpClient.getDefaultInstance().websocket("wss://" + account.getInstance() + "/api/v1/streaming/?stream="+notif_url+"&access_token=" + account.getToken(), "wss", new AsyncHttpClient.WebSocketConnectCallback() {
|
||||
@Override
|
||||
public void onCompleted(Exception ex, WebSocket webSocket) {
|
||||
webSocketFutures.put(account.getAcct()+"@"+account.getInstance(), webSocket);
|
||||
|
|
Loading…
Reference in New Issue