Skip to content

Commit

Permalink
drop twitter/github/discord integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
syuilo authored and AyumuNekozuki committed Feb 13, 2023
1 parent 10261ea commit cfb3be7
Show file tree
Hide file tree
Showing 24 changed files with 6 additions and 1,426 deletions.
48 changes: 6 additions & 42 deletions packages/backend/src/core/activitypub/models/ApPersonService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { UserNotePining } from '@/models/entities/UserNotePining.js';
import { StatusError } from '@/misc/status-error.js';
import type { UtilityService } from '@/core/UtilityService.js';
import type { UserEntityService } from '@/core/entities/UserEntityService.js';
import { bindThis } from '@/decorators.js';
import { getApId, getApType, getOneApHrefNullable, isActor, isCollection, isCollectionOrOrderedCollection, isPropertyValue } from '../type.js';
import { extractApHashtags } from './tag.js';
import type { OnModuleInit } from '@nestjs/common';
Expand All @@ -43,37 +44,6 @@ import type { IActor, IObject, IApPropertyValue } from '../type.js';
const nameLength = 128;
const summaryLength = 2048;

const services: {
[x: string]: (id: string, username: string) => any
} = {
'misskey:authentication:twitter': (userId, screenName) => ({ userId, screenName }),
'misskey:authentication:github': (id, login) => ({ id, login }),
'misskey:authentication:discord': (id, name) => $discord(id, name),
};

const $discord = (id: string, name: string) => {
if (typeof name !== 'string') {
name = 'unknown#0000';
}
const [username, discriminator] = name.split('#');
return { id, username, discriminator };
};

function addService(target: { [x: string]: any }, source: IApPropertyValue) {
const service = services[source.name];

if (typeof source.value !== 'string') {
source.value = 'unknown';
}

const [id, username] = source.value.split('@');

if (service) {
target[source.name.split(':')[2]] = service(id, username);
}
}
import { bindThis } from '@/decorators.js';

@Injectable()
export class ApPersonService implements OnModuleInit {
private utilityService: UtilityService;
Expand Down Expand Up @@ -540,22 +510,16 @@ export class ApPersonService implements OnModuleInit {
name: string,
value: string
}[] = [];
const services: { [x: string]: any } = {};

if (Array.isArray(attachments)) {
for (const attachment of attachments.filter(isPropertyValue)) {
if (isPropertyValue(attachment.identifier)) {
addService(services, attachment.identifier);
} else {
fields.push({
name: attachment.name,
value: this.mfmService.fromHtml(attachment.value),
});
}
fields.push({
name: attachment.name,
value: this.mfmService.fromHtml(attachment.value),
});
}
}

return { fields, services };
return { fields };
}

@bindThis
Expand Down
1 change: 0 additions & 1 deletion packages/backend/src/core/entities/UserEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,6 @@ export class UserEntityService implements OnModuleInit {
hasUnreadMessagingMessage: this.getHasUnreadMessagingMessage(user.id),
hasUnreadNotification: this.getHasUnreadNotification(user.id),
hasPendingReceivedFollowRequest: this.getHasPendingReceivedFollowRequest(user.id),
integrations: profile!.integrations,
mutedWords: profile!.mutedWords,
mutedInstances: profile!.mutedInstances,
mutingNotificationTypes: profile!.mutingNotificationTypes,
Expand Down
51 changes: 0 additions & 51 deletions packages/backend/src/models/entities/Meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,57 +279,6 @@ export class Meta {
})
public swPrivateKey: string | null;

@Column('boolean', {
default: false,
})
public enableTwitterIntegration: boolean;

@Column('varchar', {
length: 128,
nullable: true,
})
public twitterConsumerKey: string | null;

@Column('varchar', {
length: 128,
nullable: true,
})
public twitterConsumerSecret: string | null;

@Column('boolean', {
default: false,
})
public enableGithubIntegration: boolean;

@Column('varchar', {
length: 128,
nullable: true,
})
public githubClientId: string | null;

@Column('varchar', {
length: 128,
nullable: true,
})
public githubClientSecret: string | null;

@Column('boolean', {
default: false,
})
public enableDiscordIntegration: boolean;

@Column('varchar', {
length: 128,
nullable: true,
})
public discordClientId: string | null;

@Column('varchar', {
length: 128,
nullable: true,
})
public discordClientSecret: string | null;

@Column('varchar', {
length: 128,
nullable: true,
Expand Down
5 changes: 0 additions & 5 deletions packages/backend/src/models/entities/UserProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,6 @@ export class UserProfile {
@JoinColumn()
public pinnedPage: Page | null;

@Column('jsonb', {
default: {},
})
public integrations: Record<string, any>;

@Index()
@Column('boolean', {
default: false, select: false,
Expand Down
4 changes: 0 additions & 4 deletions packages/backend/src/models/schema/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,6 @@ export const packedMeDetailedOnlySchema = {
type: 'boolean',
nullable: false, optional: false,
},
integrations: {
type: 'object',
nullable: true, optional: false,
},
mutedWords: {
type: 'array',
nullable: false, optional: false,
Expand Down
3 changes: 0 additions & 3 deletions packages/backend/src/server/NodeinfoServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ export class NodeinfoServerService {
enableHcaptcha: meta.enableHcaptcha,
enableRecaptcha: meta.enableRecaptcha,
maxNoteTextLength: MAX_NOTE_TEXT_LENGTH,
enableTwitterIntegration: meta.enableTwitterIntegration,
enableGithubIntegration: meta.enableGithubIntegration,
enableDiscordIntegration: meta.enableDiscordIntegration,
enableEmail: meta.enableEmail,
enableServiceWorker: meta.enableServiceWorker,
proxyAccountName: proxyAccount ? proxyAccount.username : null,
Expand Down
6 changes: 0 additions & 6 deletions packages/backend/src/server/ServerModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import { NodeinfoServerService } from './NodeinfoServerService.js';
import { ServerService } from './ServerService.js';
import { WellKnownServerService } from './WellKnownServerService.js';
import { GetterService } from './api/GetterService.js';
import { DiscordServerService } from './api/integration/DiscordServerService.js';
import { GithubServerService } from './api/integration/GithubServerService.js';
import { TwitterServerService } from './api/integration/TwitterServerService.js';
import { ChannelsService } from './api/stream/ChannelsService.js';
import { ActivityPubServerService } from './ActivityPubServerService.js';
import { ApiLoggerService } from './api/ApiLoggerService.js';
Expand Down Expand Up @@ -54,9 +51,6 @@ import { UserListChannelService } from './api/stream/channels/user-list.js';
ServerService,
WellKnownServerService,
GetterService,
DiscordServerService,
GithubServerService,
TwitterServerService,
ChannelsService,
ApiCallService,
ApiLoggerService,
Expand Down
10 changes: 0 additions & 10 deletions packages/backend/src/server/api/ApiServerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import endpoints, { IEndpoint } from './endpoints.js';
import { ApiCallService } from './ApiCallService.js';
import { SignupApiService } from './SignupApiService.js';
import { SigninApiService } from './SigninApiService.js';
import { GithubServerService } from './integration/GithubServerService.js';
import { DiscordServerService } from './integration/DiscordServerService.js';
import { TwitterServerService } from './integration/TwitterServerService.js';
import type { FastifyInstance, FastifyPluginOptions } from 'fastify';

@Injectable()
Expand All @@ -38,9 +35,6 @@ export class ApiServerService {
private apiCallService: ApiCallService,
private signupApiService: SignupApiService,
private signinApiService: SigninApiService,
private githubServerService: GithubServerService,
private discordServerService: DiscordServerService,
private twitterServerService: TwitterServerService,
) {
//this.createServer = this.createServer.bind(this);
}
Expand Down Expand Up @@ -133,10 +127,6 @@ export class ApiServerService {

fastify.post<{ Body: { code: string; } }>('/signup-pending', (request, reply) => this.signupApiService.signupPending(request, reply));

fastify.register(this.discordServerService.create);
fastify.register(this.githubServerService.create);
fastify.register(this.twitterServerService.create);

fastify.get('/v1/instance/peers', async (request, reply) => {
const instances = await this.instancesRepository.find({
select: ['host'],
Expand Down
45 changes: 0 additions & 45 deletions packages/backend/src/server/api/endpoints/admin/meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,6 @@ export const meta = {
type: 'boolean',
optional: false, nullable: false,
},
enableTwitterIntegration: {
type: 'boolean',
optional: false, nullable: false,
},
enableGithubIntegration: {
type: 'boolean',
optional: false, nullable: false,
},
enableDiscordIntegration: {
type: 'boolean',
optional: false, nullable: false,
},
enableServiceWorker: {
type: 'boolean',
optional: false, nullable: false,
Expand Down Expand Up @@ -223,30 +211,6 @@ export const meta = {
optional: true, nullable: true,
format: 'id',
},
twitterConsumerKey: {
type: 'string',
optional: true, nullable: true,
},
twitterConsumerSecret: {
type: 'string',
optional: true, nullable: true,
},
githubClientId: {
type: 'string',
optional: true, nullable: true,
},
githubClientSecret: {
type: 'string',
optional: true, nullable: true,
},
discordClientId: {
type: 'string',
optional: true, nullable: true,
},
discordClientSecret: {
type: 'string',
optional: true, nullable: true,
},
summaryProxy: {
type: 'string',
optional: true, nullable: true,
Expand Down Expand Up @@ -389,9 +353,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
defaultLightTheme: instance.defaultLightTheme,
defaultDarkTheme: instance.defaultDarkTheme,
enableEmail: instance.enableEmail,
enableTwitterIntegration: instance.enableTwitterIntegration,
enableGithubIntegration: instance.enableGithubIntegration,
enableDiscordIntegration: instance.enableDiscordIntegration,
enableServiceWorker: instance.enableServiceWorker,
translatorAvailable: instance.deeplAuthKey != null,
pinnedPages: instance.pinnedPages,
Expand All @@ -409,12 +370,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
setSensitiveFlagAutomatically: instance.setSensitiveFlagAutomatically,
enableSensitiveMediaDetectionForVideos: instance.enableSensitiveMediaDetectionForVideos,
proxyAccountId: instance.proxyAccountId,
twitterConsumerKey: instance.twitterConsumerKey,
twitterConsumerSecret: instance.twitterConsumerSecret,
githubClientId: instance.githubClientId,
githubClientSecret: instance.githubClientSecret,
discordClientId: instance.discordClientId,
discordClientSecret: instance.discordClientSecret,
summalyProxy: instance.summalyProxy,
email: instance.email,
smtpSecure: instance.smtpSecure,
Expand Down
6 changes: 0 additions & 6 deletions packages/backend/src/server/api/endpoints/admin/show-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
};
}

const maskedKeys = ['accessToken', 'accessTokenSecret', 'refreshToken'];
Object.keys(profile.integrations).forEach(integration => {
maskedKeys.forEach(key => profile.integrations[integration][key] = '<MASKED>');
});

const signins = await this.signinsRepository.findBy({ userId: user.id });

const roles = await this.roleService.getUserRoles(user.id);
Expand All @@ -84,7 +79,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
carefulBot: profile.carefulBot,
injectFeaturedNote: profile.injectFeaturedNote,
receiveAnnouncementEmail: profile.receiveAnnouncementEmail,
integrations: profile.integrations,
mutedWords: profile.mutedWords,
mutedInstances: profile.mutedInstances,
mutingNotificationTypes: profile.mutingNotificationTypes,
Expand Down
45 changes: 0 additions & 45 deletions packages/backend/src/server/api/endpoints/admin/update-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@ export const paramDef = {
summalyProxy: { type: 'string', nullable: true },
deeplAuthKey: { type: 'string', nullable: true },
deeplIsPro: { type: 'boolean' },
enableTwitterIntegration: { type: 'boolean' },
twitterConsumerKey: { type: 'string', nullable: true },
twitterConsumerSecret: { type: 'string', nullable: true },
enableGithubIntegration: { type: 'boolean' },
githubClientId: { type: 'string', nullable: true },
githubClientSecret: { type: 'string', nullable: true },
enableDiscordIntegration: { type: 'boolean' },
discordClientId: { type: 'string', nullable: true },
discordClientSecret: { type: 'string', nullable: true },
enableEmail: { type: 'boolean' },
email: { type: 'string', nullable: true },
smtpSecure: { type: 'boolean' },
Expand Down Expand Up @@ -270,42 +261,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
set.summalyProxy = ps.summalyProxy;
}

if (ps.enableTwitterIntegration !== undefined) {
set.enableTwitterIntegration = ps.enableTwitterIntegration;
}

if (ps.twitterConsumerKey !== undefined) {
set.twitterConsumerKey = ps.twitterConsumerKey;
}

if (ps.twitterConsumerSecret !== undefined) {
set.twitterConsumerSecret = ps.twitterConsumerSecret;
}

if (ps.enableGithubIntegration !== undefined) {
set.enableGithubIntegration = ps.enableGithubIntegration;
}

if (ps.githubClientId !== undefined) {
set.githubClientId = ps.githubClientId;
}

if (ps.githubClientSecret !== undefined) {
set.githubClientSecret = ps.githubClientSecret;
}

if (ps.enableDiscordIntegration !== undefined) {
set.enableDiscordIntegration = ps.enableDiscordIntegration;
}

if (ps.discordClientId !== undefined) {
set.discordClientId = ps.discordClientId;
}

if (ps.discordClientSecret !== undefined) {
set.discordClientSecret = ps.discordClientSecret;
}

if (ps.enableEmail !== undefined) {
set.enableEmail = ps.enableEmail;
}
Expand Down
Loading

0 comments on commit cfb3be7

Please sign in to comment.