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);
|
||||
};
|
||||
|
@@ -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