Minor improvements

- WebFinger:  detect when to use http or https, better function naming
- RequestPool: add user agent
This commit is contained in:
2024-02-21 15:39:41 -03:00
parent 166f428cd1
commit 7fbdd031ff
5 changed files with 76 additions and 20 deletions

View File

@@ -11,24 +11,61 @@ import singletons;
import db.db;
import net.request_pool;
import webfinger;
import ap.actor;
import ap.util;
import std.math.remainder;
import util;
void commonInit() {
auto provider = new DefaultProvider(true, Levels.DEBUG);
configureLoggingProvider(provider);
RP = new RequestPool();
RP.startBackground();
Config cfg = loadConfig();
initRequestPool(cfg);
initDatabase(cfg);
}
Config loadConfig() {
Config cfg = new Config();
cfg.load();
return cfg;
}
void initRequestPool(Config cfg) {
Rp = new RequestPool();
Rp.startBackground();
}
void initDatabase(Config cfg) {
Db = new DB(DBSettings.fromJson(cfg.v["db"]));
Db.connect();
}
void main() {
commonInit();
scope (exit)
RP.stop();
scope (exit) {
Db.close();
Rp.stop();
}
JSONValue js = requestAcct("localhost:8080", "admin");
generateRSA();
return;
infoF!"Response body: %s"(js.toJSON(true));
Actor marisa = apResolveRemoteUsername("@admin@localhost:8080");
infoF!"Actor type: %s"(marisa.type);
infoF!"Actor preferredUsername: %s"(marisa.preferredUsername);
infoF!"Actor sharedInbox: %s"(marisa.endpoints.sharedInbox);
PRequest followers = PRequest();
with (followers) {
url = marisa.followers;
headers["Accept"] = "application/activity+json";
}
Response rs = Rp.request(followers, true);
infoF!"followers: %s"(rs.responseBody);
}
//int main() {