clickLinkInLatestEmail method
Implementation
Future<String> clickLinkInLatestEmail(
String emailAddr, {
bool replaceWithHomeserver = true,
bool asPost = false,
String? contains,
}) async {
var link = await getLinkInLatestEmail(emailAddr, contains: contains);
if (replaceWithHomeserver) {
final homeserver = Uri.parse(Env.defaultHomeserverUrl);
print('updating with $homeserver');
link = link.replace(
scheme: homeserver.scheme,
host: homeserver.host,
port: homeserver.port,
);
}
print('Fetching $link');
late http.Response resp;
if (asPost) {
resp = await http.post(link);
} else {
resp = await http.get(link);
}
assert(
resp.statusCode == 200,
'Error fetching $link [${resp.statusCode}]: ${resp.body}',
);
return resp.body;
}