Removing user app sync calls from worker - no longer required.
This commit is contained in:
parent
e128642bce
commit
a2cabb01d5
|
@ -1,5 +1,4 @@
|
||||||
import env from "../../environment"
|
import env from "../../environment"
|
||||||
import * as apps from "../../utilities/appService"
|
|
||||||
import * as eventHelpers from "./events"
|
import * as eventHelpers from "./events"
|
||||||
import {
|
import {
|
||||||
accounts,
|
accounts,
|
||||||
|
@ -29,7 +28,6 @@ import {
|
||||||
PlatformUser,
|
PlatformUser,
|
||||||
PlatformUserByEmail,
|
PlatformUserByEmail,
|
||||||
RowResponse,
|
RowResponse,
|
||||||
SearchUsersRequest,
|
|
||||||
User,
|
User,
|
||||||
SaveUserOpts,
|
SaveUserOpts,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
@ -275,9 +273,6 @@ export const save = async (
|
||||||
await platform.users.addUser(tenantId, builtUser._id!, builtUser.email)
|
await platform.users.addUser(tenantId, builtUser._id!, builtUser.email)
|
||||||
await cache.user.invalidateUser(response.id)
|
await cache.user.invalidateUser(response.id)
|
||||||
|
|
||||||
// let server know to sync user
|
|
||||||
await apps.syncUserInApps(_id, dbUser)
|
|
||||||
|
|
||||||
await Promise.all(groupPromises)
|
await Promise.all(groupPromises)
|
||||||
|
|
||||||
// finally returned the saved user from the db
|
// finally returned the saved user from the db
|
||||||
|
@ -424,7 +419,6 @@ export const bulkCreate = async (
|
||||||
// instead of relying on looping tenant creation
|
// instead of relying on looping tenant creation
|
||||||
await platform.users.addUser(tenantId, user._id, user.email)
|
await platform.users.addUser(tenantId, user._id, user.email)
|
||||||
await eventHelpers.handleSaveEvents(user, undefined)
|
await eventHelpers.handleSaveEvents(user, undefined)
|
||||||
await apps.syncUserInApps(user._id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const saved = usersToBulkSave.map(user => {
|
const saved = usersToBulkSave.map(user => {
|
||||||
|
@ -563,8 +557,6 @@ export const destroy = async (id: string) => {
|
||||||
await eventHelpers.handleDeleteEvents(dbUser)
|
await eventHelpers.handleDeleteEvents(dbUser)
|
||||||
await cache.user.invalidateUser(userId)
|
await cache.user.invalidateUser(userId)
|
||||||
await sessions.invalidateSessions(userId, { reason: "deletion" })
|
await sessions.invalidateSessions(userId, { reason: "deletion" })
|
||||||
// let server know to sync user
|
|
||||||
await apps.syncUserInApps(userId, dbUser)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const bulkDeleteProcessing = async (dbUser: User) => {
|
const bulkDeleteProcessing = async (dbUser: User) => {
|
||||||
|
@ -573,8 +565,6 @@ const bulkDeleteProcessing = async (dbUser: User) => {
|
||||||
await eventHelpers.handleDeleteEvents(dbUser)
|
await eventHelpers.handleDeleteEvents(dbUser)
|
||||||
await cache.user.invalidateUser(userId)
|
await cache.user.invalidateUser(userId)
|
||||||
await sessions.invalidateSessions(userId, { reason: "bulk-deletion" })
|
await sessions.invalidateSessions(userId, { reason: "bulk-deletion" })
|
||||||
// let server know to sync user
|
|
||||||
await apps.syncUserInApps(userId, dbUser)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const invite = async (
|
export const invite = async (
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
import fetch from "node-fetch"
|
|
||||||
import {
|
|
||||||
constants,
|
|
||||||
tenancy,
|
|
||||||
logging,
|
|
||||||
env as coreEnv,
|
|
||||||
} from "@budibase/backend-core"
|
|
||||||
import { checkSlashesInUrl } from "../utilities"
|
|
||||||
import env from "../environment"
|
|
||||||
import { SyncUserRequest, User } from "@budibase/types"
|
|
||||||
|
|
||||||
async function makeAppRequest(url: string, method: string, body: any) {
|
|
||||||
if (env.isTest()) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const request: any = { headers: {} }
|
|
||||||
request.headers[constants.Header.API_KEY] = coreEnv.INTERNAL_API_KEY
|
|
||||||
if (tenancy.isTenantIdSet()) {
|
|
||||||
request.headers[constants.Header.TENANT_ID] = tenancy.getTenantId()
|
|
||||||
}
|
|
||||||
if (body) {
|
|
||||||
request.headers["Content-Type"] = "application/json"
|
|
||||||
request.body = JSON.stringify(body)
|
|
||||||
}
|
|
||||||
request.method = method
|
|
||||||
|
|
||||||
// add x-budibase-correlation-id header
|
|
||||||
logging.correlation.setHeader(request.headers)
|
|
||||||
|
|
||||||
return fetch(checkSlashesInUrl(env.APPS_URL + url), request)
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function syncUserInApps(userId: string, previousUser?: User) {
|
|
||||||
const body: SyncUserRequest = {
|
|
||||||
previousUser,
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await makeAppRequest(
|
|
||||||
`/api/users/metadata/sync/${userId}`,
|
|
||||||
"POST",
|
|
||||||
body
|
|
||||||
)
|
|
||||||
if (response && response.status !== 200) {
|
|
||||||
throw "Unable to sync user."
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue