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

send emails for ownership changes #1750

Open
wants to merge 7 commits into
base: 1722-transferOwnerShipOfProject
Choose a base branch
from
Prev Previous commit
Next Next commit
call notify project ownership change method in projects tab
ae2079 committed Aug 5, 2024
commit 59490d8c3aa8277484627b1245d4342f95afb746
27 changes: 25 additions & 2 deletions src/server/adminJs/tabs/projectsTab.ts
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@ import { User } from '../../../entities/user';
import { refreshProjectEstimatedMatchingView } from '../../../services/projectViewsService';
import { extractAdminJsReferrerUrlParams } from '../adminJs';
import { relateManyProjectsToQfRound } from '../../../repositories/qfRoundRepository2';
import { NotificationCenterAdapter } from '../../../adapters/notifications/NotificationCenterAdapter';

// add queries depending on which filters were selected
export const buildProjectsQuery = (
@@ -658,6 +659,22 @@ export const exportProjectsWithFiltersToCsv = async (
};
}
};

async function sendOwnershipChangeEmails(
project: Project,
previousOwnerUser: User | null,
newOwnerUser: User | null,
) {
const notificationCenter = new NotificationCenterAdapter();

const params = {
previousOwnerUser,
newOwnerUser,
projectName: project.title,
};
await notificationCenter.notifyProjectOwnershipChange(params);
}

export const projectsTab = {
resource: Project,
options: {
@@ -1082,9 +1099,10 @@ export const projectsTab = {
});
if (project) {
if (request?.record?.params?.adminChanged) {
const adminUser = await User.findOne({
const newAdminUser = await User.findOne({
where: { id: request?.record?.params?.newAdminId },
});
const previousAdminUser = project.adminUser;
const previousAdminAddress = project.adminUser?.walletAddress;
if (previousAdminAddress) {
if (project.adminAddressHistory) {
@@ -1093,8 +1111,13 @@ export const projectsTab = {
project.adminAddressHistory = [previousAdminAddress];
}
}
project.adminUser = adminUser!;
project.adminUser = newAdminUser!;
await project.save();
await sendOwnershipChangeEmails(
project,
previousAdminUser,
newAdminUser,
);
}
// Not required for now
// Project.notifySegment(project, SegmentEvents.PROJECT_EDITED);

Unchanged files with check annotations Beta

import { SocialNetworkOauth2AdapterInterface } from './oauth2/SocialNetworkOauth2AdapterInterface';

Check failure on line 1 in src/adapters/adaptersFactory.ts

GitHub Actions / test

Property 'notifyProjectOwnershipChange' is missing in type 'MockNotificationAdapter' but required in type 'NotificationAdapterInterface'.

Check failure on line 1 in src/adapters/adaptersFactory.ts

GitHub Actions / test

Type 'MockNotificationAdapter' is not assignable to type 'NotificationAdapterInterface'.
import { DiscordAdapter } from './oauth2/discordAdapter';
import { SOCIAL_NETWORKS } from '../entities/socialProfile';
import { i18n, translationErrorMessagesKeys } from '../utils/errorMessages';
import {

Check failure on line 1 in src/adapters/notifications/MockNotificationAdapter.ts

GitHub Actions / test

Class 'MockNotificationAdapter' incorrectly implements interface 'NotificationAdapterInterface'.
BroadCastNotificationInputParams,
NotificationAdapterInterface,
OrttoPerson,