tangled
alpha
login
or
join now
yoginth.com
/
hey
1
fork
atom
Hey is a decentralized and permissionless social media app built with Lens Protocol 🌿
1
fork
atom
overview
issues
pulls
pipelines
feat: add endpoint to sync beta members to guild
yoginth.com
5 months ago
ac64480d
8bb2c305
verified
This commit was signed with the committer's
known signature
.
yoginth.com
SSH Key Fingerprint:
SHA256:SLCGp+xtY+FtXnVKtpl4bpmTttAxnxJ3DBCeikAHlG4=
+38
2 changed files
expand all
collapse all
unified
split
apps
api
src
routes
cron
guild
syncBetaMembersToGuild.ts
index.ts
+36
apps/api/src/routes/cron/guild/syncBetaMembersToGuild.ts
···
1
1
+
import { PERMISSIONS } from "@hey/data/constants";
2
2
+
import type { Context } from "hono";
3
3
+
import handleApiError from "@/utils/handleApiError";
4
4
+
import lensPg from "@/utils/lensPg";
5
5
+
import syncAddressesToGuild from "@/utils/syncAddressesToGuild";
6
6
+
7
7
+
// Sync accounts that have current beta status
8
8
+
const syncBetaMembersToGuild = async (ctx: Context) => {
9
9
+
try {
10
10
+
const accounts = (await lensPg.query(
11
11
+
`
12
12
+
SELECT DISTINCT ksw.owned_by
13
13
+
FROM account.known_smart_wallet ksw
14
14
+
INNER JOIN "group"."member" AS member ON ksw.address = member.account
15
15
+
WHERE member."group" = $1;
16
16
+
`,
17
17
+
[`\\x${PERMISSIONS.BETA.replace("0x", "").toLowerCase()}`]
18
18
+
)) as Array<{ owned_by: Buffer }>;
19
19
+
20
20
+
const addresses = accounts.map((account) =>
21
21
+
`0x${account.owned_by.toString("hex")}`.toLowerCase()
22
22
+
);
23
23
+
24
24
+
const data = await syncAddressesToGuild({
25
25
+
addresses,
26
26
+
requirementId: 479578,
27
27
+
roleId: 177898
28
28
+
});
29
29
+
30
30
+
return ctx.json(data);
31
31
+
} catch (error) {
32
32
+
return handleApiError(ctx, error);
33
33
+
}
34
34
+
};
35
35
+
36
36
+
export default syncBetaMembersToGuild;
+2
apps/api/src/routes/cron/index.ts
···
1
1
import { Hono } from "hono";
2
2
import secretMiddleware from "@/middlewares/secretMiddleware";
3
3
+
import syncBetaMembersToGuild from "./guild/syncBetaMembersToGuild";
3
4
import syncSubscribersToGuild from "./guild/syncSubscribersToGuild";
4
5
import totalSubscribers from "./guild/totalSubscribers";
5
6
import removeExpiredSubscribers from "./removeExpiredSubscribers";
6
7
7
8
const app = new Hono();
8
9
10
10
+
app.get("/syncBetaMembersToGuild", secretMiddleware, syncBetaMembersToGuild);
9
11
app.get("/syncSubscribersToGuild", secretMiddleware, syncSubscribersToGuild);
10
12
app.get("/totalSubscribers", totalSubscribers);
11
13
app.get(