Merge remote-tracking branch 'misskey-mattyatea/emoji-request' into develop
# Conflicts: # locales/index.d.ts # locales/ja-JP.yml # packages/backend/src/core/UserFollowingService.ts # packages/frontend/src/components/MkEmojiPicker.vue # packages/frontend/src/pages/custom-emojis-manager.vue
This commit is contained in:
commit
c7c70c1c30
36 changed files with 1089 additions and 421 deletions
|
|
@ -16,10 +16,8 @@ import type { EmojisRepository, MiRole, MiUser } from '@/models/_.js';
|
|||
import { bindThis } from '@/decorators.js';
|
||||
import { MemoryKVCache, RedisSingleCache } from '@/misc/cache.js';
|
||||
import { UtilityService } from '@/core/UtilityService.js';
|
||||
import { query } from '@/misc/prelude/url.js';
|
||||
import type { Serialized } from '@/types.js';
|
||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||
|
||||
const parseEmojiStrRegexp = /^(\w+)(?:@([\w.-]+))?$/;
|
||||
|
||||
@Injectable()
|
||||
|
|
@ -66,6 +64,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
|
|||
license: string | null;
|
||||
isSensitive: boolean;
|
||||
localOnly: boolean;
|
||||
draft: boolean;
|
||||
roleIdsThatCanBeUsedThisEmojiAsReaction: MiRole['id'][];
|
||||
}, moderator?: MiUser): Promise<MiEmoji> {
|
||||
const emoji = await this.emojisRepository.insert({
|
||||
|
|
@ -82,6 +81,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
|
|||
isSensitive: data.isSensitive,
|
||||
localOnly: data.localOnly,
|
||||
roleIdsThatCanBeUsedThisEmojiAsReaction: data.roleIdsThatCanBeUsedThisEmojiAsReaction,
|
||||
draft: data.draft,
|
||||
}).then(x => this.emojisRepository.findOneByOrFail(x.identifiers[0]));
|
||||
|
||||
if (data.host == null) {
|
||||
|
|
@ -111,6 +111,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
|
|||
license?: string | null;
|
||||
isSensitive?: boolean;
|
||||
localOnly?: boolean;
|
||||
draft: boolean;
|
||||
roleIdsThatCanBeUsedThisEmojiAsReaction?: MiRole['id'][];
|
||||
}, moderator?: MiUser): Promise<void> {
|
||||
const emoji = await this.emojisRepository.findOneByOrFail({ id: id });
|
||||
|
|
@ -125,6 +126,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
|
|||
license: data.license,
|
||||
isSensitive: data.isSensitive,
|
||||
localOnly: data.localOnly,
|
||||
draft: data.draft,
|
||||
originalUrl: data.driveFile != null ? data.driveFile.url : undefined,
|
||||
publicUrl: data.driveFile != null ? (data.driveFile.webpublicUrl ?? data.driveFile.url) : undefined,
|
||||
type: data.driveFile != null ? (data.driveFile.webpublicType ?? data.driveFile.type) : undefined,
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ export type RolePolicies = {
|
|||
inviteLimitCycle: number;
|
||||
inviteExpirationTime: number;
|
||||
canManageCustomEmojis: boolean;
|
||||
canRequestCustomEmojis: boolean;
|
||||
canSearchNotes: boolean;
|
||||
canUseTranslator: boolean;
|
||||
canHideAds: boolean;
|
||||
|
|
@ -59,6 +60,7 @@ export const DEFAULT_POLICIES: RolePolicies = {
|
|||
inviteLimitCycle: 60 * 24 * 7,
|
||||
inviteExpirationTime: 0,
|
||||
canManageCustomEmojis: false,
|
||||
canRequestCustomEmojis: false,
|
||||
canSearchNotes: false,
|
||||
canUseTranslator: true,
|
||||
canHideAds: false,
|
||||
|
|
@ -303,6 +305,7 @@ export class RoleService implements OnApplicationShutdown {
|
|||
inviteLimitCycle: calc('inviteLimitCycle', vs => Math.max(...vs)),
|
||||
inviteExpirationTime: calc('inviteExpirationTime', vs => Math.max(...vs)),
|
||||
canManageCustomEmojis: calc('canManageCustomEmojis', vs => vs.some(v => v === true)),
|
||||
canRequestCustomEmojis: calc('canRequestCustomEmojis', vs => vs.some(v => v === true)),
|
||||
canSearchNotes: calc('canSearchNotes', vs => vs.some(v => v === true)),
|
||||
canUseTranslator: calc('canUseTranslator', vs => vs.some(v => v === true)),
|
||||
canHideAds: calc('canHideAds', vs => vs.some(v => v === true)),
|
||||
|
|
|
|||
|
|
@ -19,7 +19,13 @@ import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
|||
import { WebhookService } from '@/core/WebhookService.js';
|
||||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { FollowingsRepository, FollowRequestsRepository, InstancesRepository, UserProfilesRepository, UsersRepository } from '@/models/_.js';
|
||||
import type {
|
||||
FollowingsRepository,
|
||||
FollowRequestsRepository,
|
||||
InstancesRepository,
|
||||
UserProfilesRepository,
|
||||
UsersRepository,
|
||||
} from '@/models/_.js';
|
||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
|
|
@ -53,25 +59,18 @@ export class UserFollowingService implements OnModuleInit {
|
|||
|
||||
constructor(
|
||||
private moduleRef: ModuleRef,
|
||||
|
||||
@Inject(DI.config)
|
||||
private config: Config,
|
||||
|
||||
@Inject(DI.usersRepository)
|
||||
private usersRepository: UsersRepository,
|
||||
|
||||
@Inject(DI.userProfilesRepository)
|
||||
private userProfilesRepository: UserProfilesRepository,
|
||||
|
||||
@Inject(DI.followingsRepository)
|
||||
private followingsRepository: FollowingsRepository,
|
||||
|
||||
@Inject(DI.followRequestsRepository)
|
||||
private followRequestsRepository: FollowRequestsRepository,
|
||||
|
||||
@Inject(DI.instancesRepository)
|
||||
private instancesRepository: InstancesRepository,
|
||||
|
||||
private cacheService: CacheService,
|
||||
private utilityService: UtilityService,
|
||||
private userEntityService: UserEntityService,
|
||||
|
|
@ -197,10 +196,18 @@ export class UserFollowingService implements OnModuleInit {
|
|||
@bindThis
|
||||
private async insertFollowingDoc(
|
||||
followee: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox']
|
||||
id: MiUser['id'];
|
||||
host: MiUser['host'];
|
||||
uri: MiUser['host'];
|
||||
inbox: MiUser['inbox'];
|
||||
sharedInbox: MiUser['sharedInbox']
|
||||
},
|
||||
follower: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox']
|
||||
id: MiUser['id'];
|
||||
host: MiUser['host'];
|
||||
uri: MiUser['host'];
|
||||
inbox: MiUser['inbox'];
|
||||
sharedInbox: MiUser['sharedInbox']
|
||||
},
|
||||
silent = false,
|
||||
withReplies?: boolean,
|
||||
|
|
@ -247,8 +254,7 @@ export class UserFollowingService implements OnModuleInit {
|
|||
});
|
||||
|
||||
// 通知を作成
|
||||
this.notificationService.createNotification(follower.id, 'followRequestAccepted', {
|
||||
}, followee.id);
|
||||
this.notificationService.createNotification(follower.id, 'followRequestAccepted', {}, followee.id);
|
||||
}
|
||||
|
||||
if (alreadyFollowed) return;
|
||||
|
|
@ -322,18 +328,25 @@ export class UserFollowingService implements OnModuleInit {
|
|||
});
|
||||
|
||||
// 通知を作成
|
||||
this.notificationService.createNotification(followee.id, 'follow', {
|
||||
}, follower.id);
|
||||
this.notificationService.createNotification(followee.id, 'follow', {}, follower.id);
|
||||
}
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async unfollow(
|
||||
follower: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
||||
id: MiUser['id'];
|
||||
host: MiUser['host'];
|
||||
uri: MiUser['host'];
|
||||
inbox: MiUser['inbox'];
|
||||
sharedInbox: MiUser['sharedInbox'];
|
||||
},
|
||||
followee: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
||||
id: MiUser['id'];
|
||||
host: MiUser['host'];
|
||||
uri: MiUser['host'];
|
||||
inbox: MiUser['inbox'];
|
||||
sharedInbox: MiUser['sharedInbox'];
|
||||
},
|
||||
silent = false,
|
||||
): Promise<void> {
|
||||
|
|
@ -464,10 +477,18 @@ export class UserFollowingService implements OnModuleInit {
|
|||
@bindThis
|
||||
public async createFollowRequest(
|
||||
follower: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
||||
id: MiUser['id'];
|
||||
host: MiUser['host'];
|
||||
uri: MiUser['host'];
|
||||
inbox: MiUser['inbox'];
|
||||
sharedInbox: MiUser['sharedInbox'];
|
||||
},
|
||||
followee: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
||||
id: MiUser['id'];
|
||||
host: MiUser['host'];
|
||||
uri: MiUser['host'];
|
||||
inbox: MiUser['inbox'];
|
||||
sharedInbox: MiUser['sharedInbox'];
|
||||
},
|
||||
requestId?: string,
|
||||
withReplies?: boolean,
|
||||
|
|
@ -560,7 +581,11 @@ export class UserFollowingService implements OnModuleInit {
|
|||
@bindThis
|
||||
public async acceptFollowRequest(
|
||||
followee: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
||||
id: MiUser['id'];
|
||||
host: MiUser['host'];
|
||||
uri: MiUser['host'];
|
||||
inbox: MiUser['inbox'];
|
||||
sharedInbox: MiUser['sharedInbox'];
|
||||
},
|
||||
follower: MiUser,
|
||||
): Promise<void> {
|
||||
|
|
@ -588,7 +613,11 @@ export class UserFollowingService implements OnModuleInit {
|
|||
@bindThis
|
||||
public async acceptAllFollowRequests(
|
||||
user: {
|
||||
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
||||
id: MiUser['id'];
|
||||
host: MiUser['host'];
|
||||
uri: MiUser['host'];
|
||||
inbox: MiUser['inbox'];
|
||||
sharedInbox: MiUser['sharedInbox'];
|
||||
},
|
||||
): Promise<void> {
|
||||
const requests = await this.followRequestsRepository.findBy({
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ export class EmojiEntityService {
|
|||
url: emoji.publicUrl || emoji.originalUrl,
|
||||
isSensitive: emoji.isSensitive ? true : undefined,
|
||||
roleIdsThatCanBeUsedThisEmojiAsReaction: emoji.roleIdsThatCanBeUsedThisEmojiAsReaction.length > 0 ? emoji.roleIdsThatCanBeUsedThisEmojiAsReaction : undefined,
|
||||
draft: emoji.draft,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -61,6 +62,7 @@ export class EmojiEntityService {
|
|||
isSensitive: emoji.isSensitive,
|
||||
localOnly: emoji.localOnly,
|
||||
roleIdsThatCanBeUsedThisEmojiAsReaction: emoji.roleIdsThatCanBeUsedThisEmojiAsReaction,
|
||||
draft: emoji.draft,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue