mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Merge pull request #3505 from eoussama/master
Added optional website ID for creation
This commit is contained in:
commit
b2a6e3f842
6 changed files with 43 additions and 6 deletions
|
|
@ -26,6 +26,7 @@ export async function POST(request: Request) {
|
|||
domain: z.string().max(500),
|
||||
shareId: z.string().max(50).nullable().optional(),
|
||||
teamId: z.string().nullable().optional(),
|
||||
id: z.string().uuid().nullable().optional(),
|
||||
});
|
||||
|
||||
const { auth, body, error } = await parseRequest(request, schema);
|
||||
|
|
@ -34,14 +35,14 @@ export async function POST(request: Request) {
|
|||
return error();
|
||||
}
|
||||
|
||||
const { name, domain, shareId, teamId } = body;
|
||||
const { id, name, domain, shareId, teamId } = body;
|
||||
|
||||
if ((teamId && !(await canCreateTeamWebsite(auth, teamId))) || !(await canCreateWebsite(auth))) {
|
||||
return unauthorized();
|
||||
}
|
||||
|
||||
const data: any = {
|
||||
id: uuid(),
|
||||
id: id ?? uuid(),
|
||||
createdBy: auth.user.id,
|
||||
name,
|
||||
domain,
|
||||
|
|
|
|||
|
|
@ -130,7 +130,9 @@ export async function getLocation(ip: string = '', headers: Headers, hasPayloadI
|
|||
);
|
||||
}
|
||||
|
||||
const result = global[MAXMIND].get(ip);
|
||||
// When the client IP is extracted from headers, sometimes the value includes a port
|
||||
const cleanIp = ip?.split(':')[0];
|
||||
const result = global[MAXMIND].get(cleanIp);
|
||||
|
||||
if (result) {
|
||||
const country = result.country?.iso_code ?? result?.registered_country?.iso_code;
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@
|
|||
|
||||
try {
|
||||
const res = await fetch(endpoint, {
|
||||
keepalive: true,
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ type, payload }),
|
||||
headers: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue