Minor improvements
- WebFinger: detect when to use http or https, better function naming - RequestPool: add user agent
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user