Skip to content

Commit

Permalink
Revert "Merge branch 'master' into chore/debug-usage-endpoint"
Browse files Browse the repository at this point in the history
This reverts commit b7b29ce, reversing
changes made to a110c66.
  • Loading branch information
apsantiso committed Jul 3, 2024
1 parent b7b29ce commit 21a1301
Show file tree
Hide file tree
Showing 18 changed files with 1,126 additions and 649 deletions.
7 changes: 0 additions & 7 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,3 @@ STORJ_BRIDGE=http://network-api:6382
STRIPE_SK=sk_test_F3Ny2VGUnPga9FtyXkl7mzPc
STRIPE_SK_TEST=sk_test_R3Ny2VG7nPgeJFrtXdt8mrPc
SENDGRID_MODE_SANDBOX=false

# APN
APN_URL=https://api.sandbox.push.apple.com
APN_BUNDLE_ID=
APN_TEAM_ID=
APN_KEY_ID=
APN_SECRET=
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"multer": "^1.4.4",
"multer-s3": "^2.10.0",
"nconf": "^0.11.1",
"newrelic": "11.22.0",
"newrelic": "^11.9.0",
"node-device-detector": "^1.4.1",
"openpgp": "^5.0.0",
"passport": "^0.4.1",
Expand Down
6 changes: 0 additions & 6 deletions src/app/models/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export interface FileAttributes {
deleted: boolean;
deletedAt: Date;
userId: number;
creationTime: Date;
modificationTime: Date;
status: FileStatus;
}
Expand Down Expand Up @@ -93,13 +92,8 @@ export default (database: Sequelize): FileModel => {
userId: {
type: DataTypes.INTEGER,
},
creationTime: {
type: DataTypes.DATE,
defaultValue: Sequelize.fn('NOW'),
},
modificationTime: {
type: DataTypes.DATE,
defaultValue: Sequelize.fn('NOW'),
},
status: {
type: DataTypes.ENUM,
Expand Down
9 changes: 1 addition & 8 deletions src/app/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import initLimit, { LimitModel } from './limit';
import initTier, { TierModel } from './tier';
import initPaidPlan, { PaidPlansModel } from './paidPlans';
import initTierLimit, { TierLimitsModel } from './tierLimit';
import initUserNotificationTokens, { UserNotificationTokenModel } from './userNotificationTokens';

export type ModelType =
| AppSumoModel
Expand Down Expand Up @@ -54,8 +53,7 @@ export type ModelType =
| PaidPlansModel
| TierLimitsModel
| LimitModel
| TierModel
| UserNotificationTokenModel;
| TierModel;

export default (database: Sequelize) => {
const AppSumo = initAppSumo(database);
Expand Down Expand Up @@ -84,7 +82,6 @@ export default (database: Sequelize) => {
const Tier = initTier(database);
const PaidPlans = initPaidPlan(database);
const TierLimit = initTierLimit(database);
const UserNotificationToken = initUserNotificationTokens(database);

AppSumo.belongsTo(User);

Expand Down Expand Up @@ -135,7 +132,6 @@ export default (database: Sequelize) => {
User.hasMany(PrivateSharingFolder, { foreignKey: 'shared_with', sourceKey: 'uuid' });
User.hasMany(Sharings, { foreignKey: 'owner_id', sourceKey: 'uuid' });
User.hasMany(Sharings, { foreignKey: 'shared_with', sourceKey: 'uuid' });
User.hasMany(UserNotificationToken, { foreignKey: 'userId', sourceKey: 'uuid' });

UserReferral.belongsTo(User, { foreignKey: 'user_id' });
UserReferral.belongsTo(Referral, { foreignKey: 'referral_id' });
Expand Down Expand Up @@ -174,8 +170,6 @@ export default (database: Sequelize) => {
as: 'tiers',
});

UserNotificationToken.belongsTo(User, { foreignKey: 'userId', targetKey: 'uuid' });

return {
[AppSumo.name]: AppSumo,
[Backup.name]: Backup,
Expand Down Expand Up @@ -203,6 +197,5 @@ export default (database: Sequelize) => {
[Limit.name]: Limit,
[PaidPlans.name]: PaidPlans,
[TierLimit.name]: TierLimit,
['userNotificationToken']: UserNotificationToken,
};
};
1 change: 0 additions & 1 deletion src/app/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export interface UserAttributes {
avatar: string;
emailVerified: boolean;
lastPasswordChangedAt: Date;
updatedAt: Date;
tierId?: string;
}

Expand Down
60 changes: 0 additions & 60 deletions src/app/models/userNotificationTokens.ts

This file was deleted.

16 changes: 15 additions & 1 deletion src/app/routes/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ export class AuthController {
const keys = await this.service.KeyServer.getKeys(userData);
const rootFolder = await this.service.Folder.getById(userData.root_folder_id);

try {
const hasReferralsProgram = await this.service.UsersReferrals.hasReferralsProgram(

Check warning on line 174 in src/app/routes/auth.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

'hasReferralsProgram' is assigned a value but never used

Check warning on line 174 in src/app/routes/auth.ts

View workflow job for this annotation

GitHub Actions / run-tests (16.x)

'hasReferralsProgram' is assigned a value but never used

Check warning on line 174 in src/app/routes/auth.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

'hasReferralsProgram' is assigned a value but never used

Check warning on line 174 in src/app/routes/auth.ts

View workflow job for this annotation

GitHub Actions / run-tests (16.x)

'hasReferralsProgram' is assigned a value but never used
userData,
userData.bridgeUser,
userData.userId,
);
} catch (err) {
console.error(`[ACCESS_ERROR_PAYMENTS] - Details:`, err);

Check warning on line 180 in src/app/routes/auth.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Unexpected console statement

Check failure on line 180 in src/app/routes/auth.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Strings must use singlequote

Check warning on line 180 in src/app/routes/auth.ts

View workflow job for this annotation

GitHub Actions / run-tests (16.x)

Unexpected console statement

Check failure on line 180 in src/app/routes/auth.ts

View workflow job for this annotation

GitHub Actions / run-tests (16.x)

Strings must use singlequote

Check warning on line 180 in src/app/routes/auth.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Unexpected console statement

Check failure on line 180 in src/app/routes/auth.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Strings must use singlequote

Check warning on line 180 in src/app/routes/auth.ts

View workflow job for this annotation

GitHub Actions / run-tests (16.x)

Unexpected console statement

Check failure on line 180 in src/app/routes/auth.ts

View workflow job for this annotation

GitHub Actions / run-tests (16.x)

Strings must use singlequote
}

console.log('Request before payments');

Check warning on line 183 in src/app/routes/auth.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Unexpected console statement

Check warning on line 183 in src/app/routes/auth.ts

View workflow job for this annotation

GitHub Actions / run-tests (16.x)

Unexpected console statement

Check warning on line 183 in src/app/routes/auth.ts

View workflow job for this annotation

GitHub Actions / build (16.x)

Unexpected console statement

Check warning on line 183 in src/app/routes/auth.ts

View workflow job for this annotation

GitHub Actions / run-tests (16.x)

Unexpected console statement
const user = {
email: req.body.email,
Expand All @@ -192,7 +202,11 @@ export class AuthController {
bridgeUser: userData.bridgeUser,
sharedWorkspace: userData.sharedWorkspace,
appSumoDetails: null,
hasReferralsProgram: false,
/* hasReferralsProgram: await this.service.UsersReferrals.hasReferralsProgram(
userData,
userData.bridgeUser,
userData.userId,
), */
backupsBucket: userData.backupsBucket,
avatar: userData.avatar ? await this.service.User.getSignedAvatarUrl(userData.avatar) : null,
emailVerified: userData.emailVerified,
Expand Down
16 changes: 3 additions & 13 deletions src/app/routes/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,9 @@ class BridgeController {
}

async getLimit(req: Request, res: Response) {
const {
bridgeUser,
userId: bridgePass,
updatedAt,
uuid
} = (req as AuthorizedRequest).user;

const limit = await this.service.Limit.getLimit(
bridgeUser,
bridgePass,
uuid,
updatedAt
);
const { bridgeUser, userId: bridgePass } = (req as AuthorizedRequest).user;

const limit = await this.service.Limit.getLimit(bridgeUser, bridgePass);

res.status(200).send(limit);
}
Expand Down
31 changes: 18 additions & 13 deletions src/app/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ import * as ReCaptchaV3 from '../../lib/recaptcha';
import * as AnalyticsService from '../../lib/analytics/AnalyticsService';
import { AuthorizedUser } from './types';
import { default as Notifications } from '../../config/initializers/notifications';
import { default as Apn } from '../../config/initializers/apn';

const Logger = logger.getInstance();

export default (router: Router, service: any, App: any): Router => {
service.Analytics = AnalyticsService;
service.ReCaptcha = ReCaptchaV3;
service.Notifications = Notifications.getInstance();
service.Apn = Apn.getInstance();

AuthRoutes(router, service, App.config);
ActivationRoutes(router, service);
Expand All @@ -58,18 +56,17 @@ export default (router: Router, service: any, App: any): Router => {
const { publicKey, privateKey, revocateKey } = req.body;
const userData: any = (req as AuthorizedUser).user;

let [keys, userBucket] = await Promise.all([
service.KeyServer.getKeys(userData),
service.User.GetUserBucket(userData),
]);

const keyExists = !!keys;
const keyExists = await service.KeyServer.keysExists(userData);

if (!keyExists && publicKey) {
await service.KeyServer.addKeysLogin(userData, publicKey, privateKey, revocateKey);
keys = await service.KeyServer.getKeys(userData);
}

const [keys, userBucket] = await Promise.all([
service.KeyServer.getKeys(userData),
service.User.GetUserBucket(userData),
]);

const token = Sign(userData.email, App.config.get('secrets').JWT, true);

const user = {
Expand All @@ -92,7 +89,11 @@ export default (router: Router, service: any, App: any): Router => {
bridgeUser: userData.bridgeUser,
sharedWorkspace: userData.sharedWorkspace,
appSumoDetails: null,
hasReferralsProgram: false,
hasReferralsProgram: await service.UsersReferrals.hasReferralsProgram(
userData,
userData.bridgeUser,
userData.userId,
),
backupsBucket: userData.backupsBucket,
avatar: userData.avatar ? await service.User.getSignedAvatarUrl(userData.avatar) : null,
emailVerified: userData.emailVerified,
Expand All @@ -109,7 +110,7 @@ export default (router: Router, service: any, App: any): Router => {
if (!userData.root_folder_id) {
throw createHttpError(500, 'Account can not be initialized');
}

const user = {
email: userData.email,
bucket: userData.bucket,
Expand All @@ -123,9 +124,13 @@ export default (router: Router, service: any, App: any): Router => {
res.status(200).send({ user });
} catch (err) {
Logger.error(
`[AUTH/INITIALIZE] ERROR: ${(err as Error).message}, BODY ${JSON.stringify(req.body)}, STACK: ${
`[AUTH/INITIALIZE] ERROR: ${
(err as Error).message
}, BODY ${
JSON.stringify(req.body)
}, STACK: ${
(err as Error).stack
}`,
}`
);

return res.status(500).send({ error: 'Internal Server Error' });
Expand Down
Loading

0 comments on commit 21a1301

Please sign in to comment.