Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[_]: refactor/remove-dead-code #440

Merged
merged 2 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions src/app/middleware/teams.js

This file was deleted.

12 changes: 0 additions & 12 deletions src/app/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import initMailLimit, { MailLimitModel } from './mailLimit';
import initPlan, { PlanModel } from './plan';
import initReferral, { ReferralModel } from './referral';
import initShare, { ShareModel } from './share';
import initTeam, { TeamModel } from './team';
import initTeamInvitation, { TeamInvitationModel } from './teaminvitation';
import initTeamMember, { TeamMemberModel } from './teammember';
import initThumbnail, { ThumbnailModel } from './thumbnail';
import initUser, { UserModel } from './user';
import initUserReferral, { UserReferralModel } from './userReferral';
Expand Down Expand Up @@ -43,9 +40,6 @@ export type ModelType =
| PlanModel
| ReferralModel
| ShareModel
| TeamModel
| TeamInvitationModel
| TeamMemberModel
| UserModel
| UserReferralModel
| FriendInvitationModel
Expand Down Expand Up @@ -74,9 +68,6 @@ export default (database: Sequelize) => {
const Plan = initPlan(database);
const Referral = initReferral(database);
const Share = initShare(database);
const Team = initTeam(database);
const TeamMember = initTeamMember(database);
const TeamInvitation = initTeamInvitation(database);
const User = initUser(database);
const UserReferral = initUserReferral(database);
const FriendInvitation = initFriendInvitation(database);
Expand Down Expand Up @@ -192,9 +183,6 @@ export default (database: Sequelize) => {
[Plan.name]: Plan,
[Referral.name]: Referral,
[Share.name]: Share,
[Team.name]: Team,
[TeamMember.name]: TeamMember,
[TeamInvitation.name]: TeamInvitation,
[User.name]: User,
[UserReferral.name]: UserReferral,
[FriendInvitation.name]: FriendInvitation,
Expand Down
39 changes: 0 additions & 39 deletions src/app/models/team.ts

This file was deleted.

37 changes: 0 additions & 37 deletions src/app/models/teaminvitation.ts

This file was deleted.

48 changes: 0 additions & 48 deletions src/app/models/teammember.ts

This file was deleted.

4 changes: 1 addition & 3 deletions src/app/routes/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ interface Services {
ReCaptcha: any;
Crypt: any;
KeyServer: any;
Team: any;
AppSumo: any;
UsersReferrals: any;
Newsletter: any;
Expand Down Expand Up @@ -169,7 +168,6 @@ export class AuthController {
}

const keys = await this.service.KeyServer.getKeys(userData);
const hasTeams = !!(await this.service.Team.getTeamByMember(req.body.email));
const rootFolder = await this.service.Folder.getById(userData.root_folder_id);

const user = {
Expand All @@ -188,7 +186,7 @@ export class AuthController {
revocateKey: keys ? keys.revocation_key : null,
bucket: userBucket,
registerCompleted: userData.registerCompleted,
teams: hasTeams,
teams: false,
username: userData.username,
bridgeUser: userData.bridgeUser,
sharedWorkspace: userData.sharedWorkspace,
Expand Down
25 changes: 0 additions & 25 deletions src/app/routes/plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,29 +37,4 @@ module.exports = (Router, Service) => {
return res.status(500).send({ error: errorMessage });
}
});

Router.get('/plan/team', passportAuth, async (req, res) => {
try {
const team = await Service.Team.getTeamByMember(req.user.email);

if (!team) {
throw createHttpError(404, `Team not found by member email: ${req.user.email}`);
}

const teamAdminUser = await Service.User.FindUserByEmail(team.admin);
const plan = await Service.Plan.getTeamPlan(teamAdminUser.email, teamAdminUser.userId);

if (!plan) {
throw createHttpError(404, 'Team plan not found');
}

return res.status(200).json(plan);
} catch (error) {
const statusCode = error.statusCode || 500;
const errorMessage = error.message || '';

Logger.error(`Error getting stripe team plan ${req.user.email}: ${error.message}`);
return res.status(statusCode).send({ error: errorMessage });
}
});
};
2 changes: 0 additions & 2 deletions src/app/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import NewsletterRoutes from './newsletter';
import UserRoutes from './user';
import AnalyticsRoutes from './analytics';
import { Sign, passportAuth } from '../middleware/passport';
import TeamsRoutes from './teams';
import logger from '../../lib/logger';
import * as ReCaptchaV3 from '../../lib/recaptcha';
import * as AnalyticsService from '../../lib/analytics/AnalyticsService';
Expand All @@ -42,7 +41,6 @@ export default (router: Router, service: any, App: any): Router => {
DesktopRoutes(router, service);
MobileRoutes(router, service, App);
TwoFactorRoutes(router, service, App);
TeamsRoutes(router, service, App);
AppSumoRoutes(router, service, App);
PlanRoutes(router, service);
ShareRoutes(router, service);
Expand Down
3 changes: 0 additions & 3 deletions src/app/routes/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Logger } from 'winston';
import { default as logger } from '../../lib/logger';
import createHttpError, { HttpError } from 'http-errors';
import { FolderAttributes } from '../models/folder';
import teamsMiddlewareBuilder from '../middleware/teams';
import Validator from '../../lib/Validator';
import { FileAttributes } from '../models/file';
import CONSTANTS from '../constants';
Expand Down Expand Up @@ -809,7 +808,6 @@ export default (router: Router, service: any) => {
const Logger = logger.getInstance();
const { passportAuth } = passport;
const sharedAdapter = sharedMiddlewareBuilder.build(service);
const teamsAdapter = teamsMiddlewareBuilder.build(service);
const resourceSharingAdapter = resourceSharingMiddlewareBuilder.build(service);
const controller = new StorageController(service, Logger);

Expand Down Expand Up @@ -841,7 +839,6 @@ export default (router: Router, service: any) => {
'/storage/v2/folder/:id/:idTeam?',
passportAuth,
sharedAdapter,
teamsAdapter,
controller.getFolderContents.bind(controller),
);
router.post('/storage/move/file', passportAuth, sharedAdapter, controller.moveFile.bind(controller));
Expand Down
81 changes: 0 additions & 81 deletions src/app/routes/stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,61 +121,6 @@ module.exports = (Router, Service) => {
);
});

/**
* Should create a new Stripe Session token.
* Stripe Session is neccesary to perform a new payment
*/
Router.post('/stripe/teams/session', passportAuth, async (req, res) => {
const test = req.body.test || false;
const stripe = test ? StripeTest : StripeProduction;
const { mode, successUrl, canceledUrl, priceId, quantity } = req.body;

let bridgeUser = await Service.Team.getTeamByEmail(req.user.email);

if (!bridgeUser) {
const newRandomTeam = Service.Team.randomEmailBridgeUserTeam();
bridgeUser = await Service.Team.create({
name: 'My team',
admin: req.user.email,
bridge_user: newRandomTeam.bridge_user,
bridge_password: newRandomTeam.password,
bridge_mnemonic: req.body.mnemonicTeam,
});
}

const sessionParams = {
payment_method_types: ['card'],
success_url: successUrl || `${process.env.HOST_DRIVE_WEB}/team/success/{CHECKOUT_SESSION_ID}`,
cancel_url: canceledUrl || `${process.env.HOST_DRIVE_WEB}/account?tab=plans`,
mode,
line_items: [
{
price: priceId,
quantity,
},
],
metadata: {
is_teams: true,
total_members: quantity,
team_email: bridgeUser.bridge_user,
admin_email: req.user.email,
},
customer_email: req.user.email,
allow_promotion_codes: true,
billing_address_collection: 'required',
};

if (sessionParams.customer) {
delete sessionParams.customer_email;
} else {
delete sessionParams.customer;
}

const result = await stripe.checkout.sessions.create(sessionParams);

res.status(200).send(result);
});

/**
* Should create a new Stripe Session token.
* Stripe Session is neccesary to perform a new payment
Expand Down Expand Up @@ -308,30 +253,4 @@ module.exports = (Router, Service) => {
res.status(500).send({ error: err.message });
});
});

Router.get('/stripe/teams/products', passportAuth, (req, res) => {
const test = req.query.test || false;

Service.Stripe.getTeamProducts(test)
.then((products) => {
res.status(200).send(products);
})
.catch((err) => {
res.status(500).send({ error: err });
});
});

Router.post('/stripe/teams/plans', passportAuth, (req, res) => {
const stripeProduct = req.body.product;
const test = req.body.test || false;

Service.Stripe.getTeamPlans(stripeProduct, test)
.then((plans) => {
res.status(200).send(plans);
})
.catch((err) => {
res.status(500).send({ error: err.message });
});
});

};
Loading
Loading