Compare commits
2 commits
83b7b0934a
...
fb141abd05
Author | SHA1 | Date | |
---|---|---|---|
fb141abd05 | |||
141c755a37 |
3 changed files with 12 additions and 10 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,5 +1,6 @@
|
||||||
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 } from "./utils.ts";
|
import { channel, log_from } 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 };
|
||||||
|
|
||||||
|
@ -25,6 +26,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +78,11 @@ export class RuleSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async *receive_rule_update() {
|
public async *receive_rule_update() {
|
||||||
while (true) yield await this.update_channel.receive();
|
while (true) {
|
||||||
|
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 `http://${this.conf.url_prefix}`;
|
return `${this.conf.url_prefix}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private serve(request: Request): Response {
|
private serve(request: Request): Response {
|
||||||
|
@ -76,18 +76,14 @@ 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 = `http://${this.conf.url_prefix}/verify/${uid}`;
|
const link = `${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 `http://${this.conf.url_prefix}/confirm/${uid}`;
|
return `${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