Skip to content

Commit

Permalink
fix: filter for auth user events
Browse files Browse the repository at this point in the history
  • Loading branch information
GregTCLTK committed Sep 23, 2023
1 parent d5cd062 commit 5e5d2dd
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions db.ts
Expand Up @@ -115,6 +115,7 @@ export async function lastLogin(discordid: string) {
const user = await finduser(discordid);
if (!user) return null;
const userevent = await db.collection("user-events").findOne({
type: "auth",
userId: user
}, {
sort: {
Expand All @@ -124,10 +125,10 @@ export async function lastLogin(discordid: string) {
if (!userevent) return null;
const location = await fetch(`https://ipinfo.io/${userevent.ip}/json`).then(res => res.json());
return [ {
platform: userevent.source?.platform ?? "Not found",
platformVersion: userevent.source?.platformVersion ?? "Not found",
legacyUserAgent: userevent.source?.legacyUserAgent ?? "Not found",
}, (location.country ? String.fromCodePoint(...(location.country as string).toUpperCase().split('').map(char => 127397 + char.charCodeAt(0))) : "") + " " + location.city + " (" + location.timezone + ")", location.timezone ];
platform: userevent.source.platform,
platformVersion: userevent.source.platformVersion,
legacyUserAgent: userevent.source.legacyUserAgent,
}, `${location.country ? String.fromCodePoint(...(location.country as string).toUpperCase().split('').map(char => 127397 + char.charCodeAt(0))) : ""} ${location.city} (${location.timezone})`, location.timezone ];
}

export async function saveTranscript(transcript: any) {
Expand Down Expand Up @@ -165,16 +166,16 @@ export async function removeBoosterRewards(discordid: string) {
}

export async function addPartner(member: ObjectId, cpu: number, memory: number, disk: number, slots: number, invite: string) {
db.collection("@bbn/bot/partners").insertOne({
await db.collection("@bbn/bot/partners").insertOne({
owner: member,
cpu: cpu,
memory: memory,
disk: disk,
slots: slots,
invite: invite,
cpu,
memory,
disk,
slots,
invite,
lastinvite: Date.now()
});
db.collection("@bbn/hosting/access").updateOne({
await db.collection("@bbn/hosting/access").updateOne({
owner: member
}, {
$inc: {
Expand Down

0 comments on commit 5e5d2dd

Please sign in to comment.