Compare commits
No commits in common. "fb141abd0506944dbb5c1f6ffb3135e1dabcd6aa" and "83b7b0934a1932676c480383aa2505177f788bde" have entirely different histories.
fb141abd05
...
83b7b0934a
3 changed files with 10 additions and 12 deletions
|
@ -79,7 +79,7 @@ class Service {
|
||||||
for await (const _ of this.rules.receive_rule_update()) {
|
for await (const _ of this.rules.receive_rule_update()) {
|
||||||
await this.update_all_users_roles();
|
await this.update_all_users_roles();
|
||||||
}
|
}
|
||||||
})();
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async update_all_users_roles() {
|
async update_all_users_roles() {
|
||||||
|
|
10
src/rules.ts
10
src/rules.ts
|
@ -1,6 +1,5 @@
|
||||||
import { z } from "https://deno.land/x/zod@v3.22.4/mod.ts";
|
import { z } from "https://deno.land/x/zod@v3.22.4/mod.ts";
|
||||||
import { channel, log_from } from "./utils.ts";
|
import { channel } from "./utils.ts";
|
||||||
const log = log_from(import.meta.url);
|
|
||||||
|
|
||||||
export type TargetRole = { guild_id: string; role_id: string };
|
export type TargetRole = { guild_id: string; role_id: string };
|
||||||
|
|
||||||
|
@ -26,7 +25,6 @@ export class RuleSet {
|
||||||
const file_content = await Deno.readTextFile(path);
|
const file_content = await Deno.readTextFile(path);
|
||||||
const parsed = parse_rules(file_content);
|
const parsed = parse_rules(file_content);
|
||||||
for (const { group_id, target_role } of parsed) await result.append_rule(group_id, target_role);
|
for (const { group_id, target_role } of parsed) await result.append_rule(group_id, target_role);
|
||||||
result.update_channel = channel();
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,11 +76,7 @@ export class RuleSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async *receive_rule_update() {
|
public async *receive_rule_update() {
|
||||||
while (true) {
|
while (true) yield await this.update_channel.receive();
|
||||||
const update = await this.update_channel.receive();
|
|
||||||
log(`Received an update for roles`, update);
|
|
||||||
yield update;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async save() {
|
private async save() {
|
||||||
|
|
|
@ -48,7 +48,7 @@ export class WebVerifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
public url() {
|
public url() {
|
||||||
return `${this.conf.url_prefix}`;
|
return `http://${this.conf.url_prefix}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private serve(request: Request): Response {
|
private serve(request: Request): Response {
|
||||||
|
@ -76,14 +76,18 @@ export class WebVerifier {
|
||||||
return response_success();
|
return response_success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async serve_result_page() {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
private create_verif_link() {
|
private create_verif_link() {
|
||||||
const uid = uuid.generate() as string;
|
const uid = uuid.generate() as string;
|
||||||
const link = `${this.conf.url_prefix}/verify/${uid}`;
|
const link = `http://${this.conf.url_prefix}/verify/${uid}`;
|
||||||
return { uid, link };
|
return { uid, link };
|
||||||
}
|
}
|
||||||
|
|
||||||
private create_confirm_link(uid: string) {
|
private create_confirm_link(uid: string) {
|
||||||
return `${this.conf.url_prefix}/confirm/${uid}`;
|
return `http://${this.conf.url_prefix}/confirm/${uid}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async start_peremption(uid: string) {
|
private async start_peremption(uid: string) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue