Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -47,7 +47,7 @@ export type DeviceTokenRecord = {
|
||||
export type DeviceTokenClient = {
|
||||
deviceToken: {
|
||||
upsert(args: {
|
||||
where: { token: string };
|
||||
where: { token: string; userId: string };
|
||||
create: {
|
||||
userId: string;
|
||||
tenantId: string | null;
|
||||
@@ -57,7 +57,6 @@ export type DeviceTokenClient = {
|
||||
appVersion?: string | null;
|
||||
};
|
||||
update: {
|
||||
userId: string;
|
||||
tenantId: string | null;
|
||||
platform: DevicePlatform;
|
||||
pushProvider: PushProvider;
|
||||
@@ -67,7 +66,7 @@ export type DeviceTokenClient = {
|
||||
};
|
||||
}): Promise<DeviceTokenRecord>;
|
||||
update(args: {
|
||||
where: { token: string };
|
||||
where: { token: string; userId: string; tenantId: string | null };
|
||||
data: { revokedAt: Date };
|
||||
}): Promise<DeviceTokenRecord>;
|
||||
updateMany(args: {
|
||||
@@ -104,7 +103,10 @@ export async function registerDeviceToken(
|
||||
const provider = input.pushProvider ?? defaultPushProviderFor(input.platform);
|
||||
const now = new Date();
|
||||
return client.deviceToken.upsert({
|
||||
where: { token: input.token },
|
||||
// Keep the globally unique token bound to its authenticated owner. If the
|
||||
// same token already belongs to another user, the filtered update cannot
|
||||
// match and the create path fails closed on the unique constraint.
|
||||
where: { token: input.token, userId: input.userId },
|
||||
create: {
|
||||
userId: input.userId,
|
||||
tenantId: input.tenantId,
|
||||
@@ -114,7 +116,6 @@ export async function registerDeviceToken(
|
||||
appVersion: input.appVersion ?? null,
|
||||
},
|
||||
update: {
|
||||
userId: input.userId,
|
||||
tenantId: input.tenantId,
|
||||
platform: input.platform,
|
||||
pushProvider: provider,
|
||||
@@ -131,12 +132,16 @@ export async function registerDeviceToken(
|
||||
* skips this token.
|
||||
*/
|
||||
export async function revokeDeviceToken(
|
||||
token: string,
|
||||
input: { token: string; userId: string; tenantId: string | null },
|
||||
client: DeviceTokenClient = getDbClient() as unknown as DeviceTokenClient,
|
||||
): Promise<DeviceTokenRecord | null> {
|
||||
try {
|
||||
return await client.deviceToken.update({
|
||||
where: { token },
|
||||
where: {
|
||||
token: input.token,
|
||||
userId: input.userId,
|
||||
tenantId: input.tenantId,
|
||||
},
|
||||
data: { revokedAt: new Date() },
|
||||
});
|
||||
} catch {
|
||||
|
||||
Reference in new issue
Block a user