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();
|
||||
|
||||
connection = await connection.$query().patchAndFetch({
|
||||
formattedData: connection?.formattedData?.screenName
|
||||
? { screenName: connection.formattedData.screenName }
|
||||
: null,
|
||||
});
|
||||
connection = await connection.reset();
|
||||
|
||||
renderObject(response, connection);
|
||||
};
|
||||
|
@@ -1,6 +1,5 @@
|
||||
import createUser from './mutations/create-user.ee.js';
|
||||
import duplicateFlow from './mutations/duplicate-flow.js';
|
||||
import resetConnection from './mutations/reset-connection.js';
|
||||
import updateConnection from './mutations/update-connection.js';
|
||||
import updateFlowStatus from './mutations/update-flow-status.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 createConnection from './mutations/create-connection.js';
|
||||
import deleteFlow from './mutations/delete-flow.js';
|
||||
import resetConnection from './mutations/reset-connection.js';
|
||||
|
||||
const mutationResolvers = {
|
||||
createConnection,
|
||||
|
@@ -249,6 +249,18 @@ class Connection extends Base {
|
||||
|
||||
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;
|
||||
|
Reference in New Issue
Block a user