Skip to content

Commit

Permalink
fix(AccountSession): load custom emoji with auth from GTS
Browse files Browse the repository at this point in the history
GoToSocial requires authentication for requesting the emoji list.

Closes sk22#989
  • Loading branch information
FineFindus committed Aug 31, 2024
1 parent 01225b0 commit 94cca7f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ public void onError(ErrorResponse errorResponse) {
}

private void updateInstanceEmojis(Instance instance, String domain){
new GetCustomEmojis()
GetCustomEmojis req=(GetCustomEmojis) new GetCustomEmojis()
.setCallback(new Callback<>(){
@Override
public void onSuccess(List<Emoji> result){
Expand All @@ -419,8 +419,14 @@ public void onError(ErrorResponse error){
wrapper.instance = instance;
MastodonAPIController.runInBackground(()->writeInstanceInfoFile(wrapper, domain));
}
})
.execNoAuth(domain);
});
if(instance.isGoToSocial()) {
// GTS requires auth for emojis
// https://github.com/superseriousbusiness/gotosocial/issues/2794
req.exec(lastActiveAccountID);
return;
}
req.execNoAuth(domain);
}

private File getInstanceInfoFile(String domain){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.joinmastodon.android.model;

import android.text.Html;
import android.text.TextUtils;
import android.util.Log;

import org.joinmastodon.android.api.ObjectValidationException;
Expand Down Expand Up @@ -91,6 +92,13 @@ public class Instance extends BaseModel{

public PleromaPollLimits pollLimits;

/**
* Url to the source code of the instance.
*
* Only found on GoToSocial instances
*/
public String sourceUrl;

/** like uri, but always without scheme and trailing slash */
public transient String normalizedUri;

Expand Down Expand Up @@ -154,6 +162,13 @@ public boolean isPixelfed() {
return version.contains("compatible; Pixelfed");
}

/**
* @return `true` if the instance is a GoToSocial instance
*/
public boolean isGoToSocial() {
return TextUtils.equals(sourceUrl, "https://github.com/superseriousbusiness/gotosocial");
}

public boolean hasFeature(Feature feature) {
Optional<List<String>> pleromaFeatures = Optional.ofNullable(pleroma)
.map(p -> p.metadata)
Expand Down

0 comments on commit 94cca7f

Please sign in to comment.