Skip to content

Commit

Permalink
Fix #1320
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenlagus committed Jul 7, 2024
1 parent 0d19e55 commit 91f7ae2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -572,14 +572,20 @@ private <T extends Serializable, Method extends SendMediaBotMethod<T>> Completab
}

private HttpUrl buildUrl(String methodPath) {
return new HttpUrl
HttpUrl.Builder builder = new HttpUrl
.Builder()
.scheme(telegramUrl.getSchema())
.host(telegramUrl.getHost())
.port(telegramUrl.getPort())
.addPathSegment("bot" + botToken)
.addPathSegment(methodPath)
.build();
.addPathSegment("bot" + botToken);

if (telegramUrl.isTestServer()) {
builder.addPathSegment("test");
}

builder.addPathSegment(methodPath);

return builder.build();
}

private void addInputData(TelegramMultipartBuilder builder, String mediaField, InputMedia media, boolean addField) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,19 @@ private Request createRequest(TelegramUrl telegramUrl, BotApiMethod<?> apiMethod

@NonNull
private HttpUrl buildUrl(TelegramUrl telegramUrl, String methodPath) {
return new HttpUrl
HttpUrl.Builder builder = new HttpUrl
.Builder()
.scheme(telegramUrl.getSchema())
.host(telegramUrl.getHost())
.port(telegramUrl.getPort())
.addPathSegment("bot" + botToken)
.addPathSegment(methodPath)
.build();
.addPathSegment("bot" + botToken);

if (telegramUrl.isTestServer()) {
builder.addPathSegment("test");
}

builder.addPathSegment(methodPath);

return builder.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class TelegramUrl {
private String schema;
private String host;
private int port;
private boolean testServer;

public static final TelegramUrl DEFAULT_URL = new TelegramUrl("https", "api.telegram.org", 443);
public static final TelegramUrl DEFAULT_URL = new TelegramUrl("https", "api.telegram.org", 443, false);
}

0 comments on commit 91f7ae2

Please sign in to comment.