mirror of
https://github.com/antebudimir/tempus.git
synced 2026-04-15 08:17:26 +00:00
fix: local url used in share link instead of server url (#431)
fix: use explicitly Server Public URl in link sharing
This commit is contained in:
parent
fb568d1d74
commit
3958cbcc1c
2 changed files with 44 additions and 2 deletions
|
|
@ -55,6 +55,48 @@ public class App extends Application {
|
|||
}
|
||||
return subsonic;
|
||||
}
|
||||
|
||||
public static Subsonic getSubsonicPublicClientInstance(boolean override) {
|
||||
|
||||
/*
|
||||
If I do the shortcut that the IDE suggests:
|
||||
SubsonicPreferences preferences = getSubsonicPreferences1();
|
||||
During the chain of calls it will run the following:
|
||||
String server = Preferences.getInUseServerAddress();
|
||||
Which could return Local URL, causing issues like generating public shares with Local URL
|
||||
|
||||
To prevent this I just replicated the entire chain of functions here,
|
||||
if you need a call to Subsonic using the Server (Public) URL use this function.
|
||||
*/
|
||||
|
||||
String server = Preferences.getServer();
|
||||
String username = Preferences.getUser();
|
||||
String password = Preferences.getPassword();
|
||||
String token = Preferences.getToken();
|
||||
String salt = Preferences.getSalt();
|
||||
boolean isLowSecurity = Preferences.isLowScurity();
|
||||
|
||||
SubsonicPreferences preferences = new SubsonicPreferences();
|
||||
preferences.setServerUrl(server);
|
||||
preferences.setUsername(username);
|
||||
preferences.setAuthentication(password, token, salt, isLowSecurity);
|
||||
|
||||
if (subsonic == null || override) {
|
||||
|
||||
if (preferences.getAuthentication() != null) {
|
||||
if (preferences.getAuthentication().getPassword() != null)
|
||||
Preferences.setPassword(preferences.getAuthentication().getPassword());
|
||||
if (preferences.getAuthentication().getToken() != null)
|
||||
Preferences.setToken(preferences.getAuthentication().getToken());
|
||||
if (preferences.getAuthentication().getSalt() != null)
|
||||
Preferences.setSalt(preferences.getAuthentication().getSalt());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return new Subsonic(preferences);
|
||||
}
|
||||
|
||||
public static Github getGithubClientInstance() {
|
||||
if (github == null) {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class SharingRepository {
|
|||
public MutableLiveData<Share> createShare(String id, String description, Long expires) {
|
||||
MutableLiveData<Share> share = new MutableLiveData<>();
|
||||
|
||||
App.getSubsonicClientInstance(false)
|
||||
App.getSubsonicPublicClientInstance(false)
|
||||
.getSharingClient()
|
||||
.createShare(id, description, expires)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
@ -64,7 +64,7 @@ public class SharingRepository {
|
|||
}
|
||||
|
||||
public void updateShare(String id, String description, Long expires) {
|
||||
App.getSubsonicClientInstance(false)
|
||||
App.getSubsonicPublicClientInstance(false)
|
||||
.getSharingClient()
|
||||
.updateShare(id, description, expires)
|
||||
.enqueue(new Callback<ApiResponse>() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue