Skip to content

πŸ“¨ The ultimate agentic social media scheduling tool πŸ€–

feat: fix postiz oauth

Nevo David08c314364754
diff --git a/libraries/nestjs-libraries/src/database/prisma/oauth/oauth.repository.ts b/libraries/nestjs-libraries/src/database/prisma/oauth/oauth.repository.ts
index 91caecc75..fe18a8cba 100644
--- a/libraries/nestjs-libraries/src/database/prisma/oauth/oauth.repository.ts
+++ b/libraries/nestjs-libraries/src/database/prisma/oauth/oauth.repository.ts
@@ -59,7 +59,7 @@ export class OAuthRepository {
});
}
- updateApp(
+ async updateApp(
orgId: string,
data: {
name?: string;
@@ -68,13 +68,17 @@ export class OAuthRepository {
redirectUrl?: string;
}
) {
- return this._oauthApp.model.oAuthApp.update({
+ const app = await this._oauthApp.model.oAuthApp.findFirst({
where: {
- organizationId_deletedAt: {
- organizationId: orgId,
- deletedAt: null,
- },
+ organizationId: orgId,
+ deletedAt: null,
},
+ });
+ if (!app) {
+ return null;
+ }
+ return this._oauthApp.model.oAuthApp.update({
+ where: { id: app.id },
data,
include: {
picture: true,
@@ -82,28 +86,36 @@ export class OAuthRepository {
});
}
- deleteApp(orgId: string) {
- return this._oauthApp.model.oAuthApp.update({
+ async deleteApp(orgId: string) {
+ const app = await this._oauthApp.model.oAuthApp.findFirst({
where: {
- organizationId_deletedAt: {
- organizationId: orgId,
- deletedAt: null,
- },
+ organizationId: orgId,
+ deletedAt: null,
},
+ });
+ if (!app) {
+ return null;
+ }
+ return this._oauthApp.model.oAuthApp.update({
+ where: { id: app.id },
data: {
deletedAt: new Date(),
},
});
}
- updateClientSecret(orgId: string, newSecret: string) {
- return this._oauthApp.model.oAuthApp.update({
+ async updateClientSecret(orgId: string, newSecret: string) {
+ const app = await this._oauthApp.model.oAuthApp.findFirst({
where: {
- organizationId_deletedAt: {
- organizationId: orgId,
- deletedAt: null,
- },
+ organizationId: orgId,
+ deletedAt: null,
},
+ });
+ if (!app) {
+ return null;
+ }
+ return this._oauthApp.model.oAuthApp.update({
+ where: { id: app.id },
data: {
clientSecret: newSecret,
},