-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Integrate AAO /abuse endpoint * Integrate AAO * Polish * Skip abuse config * Fix migration * Fixes * Nullable columns for faster migration * polish
- Loading branch information
1 parent
0eff09d
commit 56ab786
Showing
6 changed files
with
106 additions
and
41 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
identity-service/sequelize/migrations/20220912160855-abuse-columns.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
up: (queryInterface, Sequelize) => { | ||
return queryInterface.sequelize.transaction(async (transaction) => { | ||
await queryInterface.addColumn('Users', 'isBlockedFromRelay', { | ||
type: Sequelize.BOOLEAN, | ||
allowNull: true | ||
}, { transaction }) | ||
|
||
await queryInterface.addColumn('Users', 'isBlockedFromNotifications', { | ||
type: Sequelize.BOOLEAN, | ||
allowNull: true | ||
}, { transaction }) | ||
|
||
await queryInterface.addColumn('Users', 'appliedRules', { | ||
type: Sequelize.JSONB, | ||
allowNull: true | ||
}, { transaction }) | ||
|
||
await queryInterface.sequelize.query( | ||
'UPDATE "Users" SET "isBlockedFromRelay" = true WHERE "isAbusive" = true AND "isAbusiveErrorCode" != \'9\'', | ||
{ transaction } | ||
) | ||
|
||
await queryInterface.sequelize.query( | ||
'UPDATE "Users" SET "isBlockedFromNotifications" = true WHERE "isAbusive" = true AND "isAbusiveErrorCode" = \'9\'', | ||
{ transaction } | ||
) | ||
|
||
// Safe to drop this now since we've moved users | ||
await queryInterface.removeColumn('Users', 'isAbusive', { transaction }) | ||
await queryInterface.removeColumn('Users', 'isAbusiveErrorCode', { transaction }) | ||
}) | ||
}, | ||
|
||
down: (queryInterface, Sequelize) => { | ||
return queryInterface.sequelize.transaction(async (transaction) => { | ||
await queryInterface.removeColumn('Users', 'isBlockedFromRelay', { transaction }) | ||
await queryInterface.removeColumn('Users', 'isBlockedFromNotifications', { transaction }) | ||
await queryInterface.removeColumn('Users', 'appliedRules', { transaction }) | ||
await queryInterface.addColumn( | ||
'Users', | ||
'isAbusive', { | ||
type: Sequelize.BOOLEAN, | ||
defaultValue: false | ||
} | ||
) | ||
await queryInterface.addColumn( | ||
'Users', | ||
'isAbusiveErrorCode', { | ||
type: Sequelize.STRING | ||
} | ||
) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters