Merge pull request #2077 from automatisch/rest-reset-connection
refactor: Move reset logic to connection model
This commit is contained in:
@@ -8,11 +8,7 @@ export default async (request, response) => {
|
|||||||
})
|
})
|
||||||
.throwIfNotFound();
|
.throwIfNotFound();
|
||||||
|
|
||||||
connection = await connection.$query().patchAndFetch({
|
connection = await connection.reset();
|
||||||
formattedData: connection?.formattedData?.screenName
|
|
||||||
? { screenName: connection.formattedData.screenName }
|
|
||||||
: null,
|
|
||||||
});
|
|
||||||
|
|
||||||
renderObject(response, connection);
|
renderObject(response, connection);
|
||||||
};
|
};
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import createUser from './mutations/create-user.ee.js';
|
import createUser from './mutations/create-user.ee.js';
|
||||||
import duplicateFlow from './mutations/duplicate-flow.js';
|
import duplicateFlow from './mutations/duplicate-flow.js';
|
||||||
import resetConnection from './mutations/reset-connection.js';
|
|
||||||
import updateConnection from './mutations/update-connection.js';
|
import updateConnection from './mutations/update-connection.js';
|
||||||
import updateFlowStatus from './mutations/update-flow-status.js';
|
import updateFlowStatus from './mutations/update-flow-status.js';
|
||||||
import updateStep from './mutations/update-step.js';
|
import updateStep from './mutations/update-step.js';
|
||||||
@@ -16,6 +15,7 @@ import updateCurrentUser from './mutations/update-current-user.js';
|
|||||||
import generateAuthUrl from './mutations/generate-auth-url.js';
|
import generateAuthUrl from './mutations/generate-auth-url.js';
|
||||||
import createConnection from './mutations/create-connection.js';
|
import createConnection from './mutations/create-connection.js';
|
||||||
import deleteFlow from './mutations/delete-flow.js';
|
import deleteFlow from './mutations/delete-flow.js';
|
||||||
|
import resetConnection from './mutations/reset-connection.js';
|
||||||
|
|
||||||
const mutationResolvers = {
|
const mutationResolvers = {
|
||||||
createConnection,
|
createConnection,
|
||||||
|
@@ -249,6 +249,18 @@ class Connection extends Base {
|
|||||||
|
|
||||||
return { url };
|
return { url };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async reset() {
|
||||||
|
const formattedData = this?.formattedData?.screenName
|
||||||
|
? { screenName: this.formattedData.screenName }
|
||||||
|
: null;
|
||||||
|
|
||||||
|
const updatedConnection = await this.$query().patchAndFetch({
|
||||||
|
formattedData,
|
||||||
|
});
|
||||||
|
|
||||||
|
return updatedConnection;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Connection;
|
export default Connection;
|
||||||
|
Reference in New Issue
Block a user