117 lines
2.2 KiB
D
117 lines
2.2 KiB
D
module main;
|
|
|
|
import std.json;
|
|
|
|
import requests;
|
|
import slf4d;
|
|
import slf4d.default_provider;
|
|
|
|
import config;
|
|
import singletons;
|
|
import db.db;
|
|
import net.request_pool;
|
|
import webfinger;
|
|
import ap.actor;
|
|
|
|
// import ap.util;
|
|
import std.math.remainder;
|
|
import util;
|
|
import ap.activity_stream;
|
|
import ap.util;
|
|
|
|
void commonInit() {
|
|
auto provider = new DefaultProvider(true, Levels.DEBUG);
|
|
configureLoggingProvider(provider);
|
|
|
|
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 Database(DBSettings.fromJson(cfg.v["db"]));
|
|
DB.connect();
|
|
}
|
|
|
|
void main() {
|
|
import std.stdio;
|
|
|
|
commonInit();
|
|
|
|
scope (exit) {
|
|
DB.close();
|
|
RP.stop();
|
|
}
|
|
|
|
ASObject actor = apResolveRemoteUsername("@marisa@ak.gensokyo.shop");
|
|
// writeln(actor.raw.toJSON(true));
|
|
writeln(actor.stringRep);
|
|
|
|
// 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() {
|
|
// auto provider = new DefaultProvider(true, Levels.DEBUG);
|
|
// configureLoggingProvider(provider);
|
|
//
|
|
// Config cfg = new Config();
|
|
//
|
|
// try {
|
|
// cfg.load();
|
|
// } catch (Exception e) {
|
|
// error(e);
|
|
// return 21;
|
|
// }
|
|
//
|
|
// DBSettings dbSettings;
|
|
// auto dbCfg = cfg.v["db"];
|
|
// with (dbSettings) {
|
|
// host = dbCfg["host"].str;
|
|
// port = cast(ushort) dbCfg["port"].integer;
|
|
// username = dbCfg["username"].str;
|
|
// password = dbCfg["password"].str;
|
|
// dbname = dbCfg["dbName"].str;
|
|
//
|
|
// switch (dbCfg["connector"].str) {
|
|
// case "postgresql":
|
|
// connector = DBConnector.DB_PGSQL;
|
|
// break;
|
|
// default:
|
|
// break;
|
|
// }
|
|
// }
|
|
//
|
|
// DB = new DB(dbSettings);
|
|
// DB.connect();
|
|
//
|
|
// scope (exit)
|
|
// DB.close();
|
|
//
|
|
// return 0;
|
|
//}
|
|
//
|