Skip to content

Commit

Permalink
Remove firebase dynamic links
Browse files Browse the repository at this point in the history
  • Loading branch information
duncte123 committed Aug 24, 2023
1 parent e88d8b1 commit 0938012
Showing 1 changed file with 0 additions and 49 deletions.
49 changes: 0 additions & 49 deletions bot/src/main/java/ml/duncte123/skybot/utils/AirUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package ml.duncte123.skybot.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.github.natanbc.reliqua.limiter.RateLimiter;
Expand Down Expand Up @@ -370,52 +369,4 @@ public static PendingRequest<String> shortenUrl(String url, Variables variables,
return new FakePendingRequest<>("JSON PARSING FAILED: " + e.getMessage());
}
}

// TODO: find replacement for firebase
@Deprecated
public static PendingRequest<String> shortenUrl(String url, String googleKey, ObjectMapper mapper) {
return shortenUrl(url, googleKey, mapper, "duncte.bot");
}

@Deprecated
@Nonnull
public static PendingRequest<String> shortenUrl(String url, String googleKey, ObjectMapper mapper, String prefix) {
final ObjectNode json = mapper.createObjectNode();

json.set("dynamicLinkInfo",
mapper.createObjectNode()
.put("domainUriPrefix", prefix)
.put("link", url)
);
json.set("suffix",
mapper.createObjectNode()
.put("option", "SHORT") // SHORT or UNGUESSABLE
);

try {
return WebUtils.ins.postRequest(
"https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=" + googleKey,
JSONRequestBody.fromJackson(json)
)
.setRateLimiter(RateLimiter.directLimiter())
.build(
(r) -> {
final ObjectNode response = toJSONObject(r, mapper);

if (response == null) {
return "Google did a fucky wucky and send invalid json";
}

return response.get("shortLink").asText();
},
WebParserUtils::handleError
);
}
catch (JsonProcessingException e) {
e.printStackTrace();

// Return a fake pending request to make sure that things don't break
return new FakePendingRequest<>("JSON PARSING FAILED: " + e.getMessage());
}
}
}

0 comments on commit 0938012

Please sign in to comment.