chore: bug fix cleanup (#4)
This commit is contained in:
@@ -462,6 +462,14 @@ export class MessageSendService {
|
||||
return {attachmentsToProcess, favoriteMemeAttachment};
|
||||
}
|
||||
|
||||
private getMessageTypeForRequest(data: MessageRequest): number {
|
||||
if (!data.message_reference) {
|
||||
return MessageTypes.DEFAULT;
|
||||
}
|
||||
const referenceType = data.message_reference.type ?? MessageReferenceTypes.DEFAULT;
|
||||
return referenceType === MessageReferenceTypes.FORWARD ? MessageTypes.DEFAULT : MessageTypes.REPLY;
|
||||
}
|
||||
|
||||
private buildMessageReferencePayload({
|
||||
data,
|
||||
referencedMessage,
|
||||
@@ -672,7 +680,7 @@ export class MessageSendService {
|
||||
messageId,
|
||||
channelId,
|
||||
user,
|
||||
type: referencedMessage ? MessageTypes.REPLY : MessageTypes.DEFAULT,
|
||||
type: this.getMessageTypeForRequest(data),
|
||||
content: data.content,
|
||||
flags: this.deps.validationService.calculateMessageFlags(data),
|
||||
embeds: data.embeds,
|
||||
|
||||
@@ -336,6 +336,7 @@ export class GuildMemberOperationsService {
|
||||
bio: updateData.bio !== undefined ? updateData.bio : targetMember.bio,
|
||||
pronouns: updateData.pronouns !== undefined ? updateData.pronouns : targetMember.pronouns,
|
||||
accent_color: updateData.accent_color !== undefined ? updateData.accent_color : targetMember.accentColor,
|
||||
profile_flags: updateData.profile_flags !== undefined ? updateData.profile_flags : targetMember.profileFlags,
|
||||
mute: updateData.mute !== undefined ? updateData.mute : targetMember.isMute,
|
||||
deaf: updateData.deaf !== undefined ? updateData.deaf : targetMember.isDeaf,
|
||||
communication_disabled_until:
|
||||
|
||||
@@ -173,6 +173,46 @@ export class UserChannelService {
|
||||
return await this.userChannelRepository.findExistingDmState(userId, recipientId);
|
||||
}
|
||||
|
||||
async ensureDmOpenForBothUsers({
|
||||
userId,
|
||||
recipientId,
|
||||
userCacheService,
|
||||
requestCache,
|
||||
}: {
|
||||
userId: UserID;
|
||||
recipientId: UserID;
|
||||
userCacheService: UserCacheService;
|
||||
requestCache: RequestCache;
|
||||
}): Promise<Channel> {
|
||||
const existingChannel = await this.userChannelRepository.findExistingDmState(userId, recipientId);
|
||||
|
||||
if (existingChannel) {
|
||||
const [isUserOpen, isRecipientOpen] = await Promise.all([
|
||||
this.userChannelRepository.isDmChannelOpen(userId, existingChannel.id),
|
||||
this.userChannelRepository.isDmChannelOpen(recipientId, existingChannel.id),
|
||||
]);
|
||||
|
||||
if (!isUserOpen) {
|
||||
await this.userChannelRepository.openDmForUser(userId, existingChannel.id);
|
||||
await this.dispatchChannelCreate({userId, channel: existingChannel, userCacheService, requestCache});
|
||||
}
|
||||
|
||||
if (!isRecipientOpen) {
|
||||
await this.userChannelRepository.openDmForUser(recipientId, existingChannel.id);
|
||||
await this.dispatchChannelCreate({
|
||||
userId: recipientId,
|
||||
channel: existingChannel,
|
||||
userCacheService,
|
||||
requestCache,
|
||||
});
|
||||
}
|
||||
|
||||
return existingChannel;
|
||||
}
|
||||
|
||||
return await this.createNewDmForBothUsers({userId, recipientId, userCacheService, requestCache});
|
||||
}
|
||||
|
||||
async reopenDmForBothUsers({
|
||||
userId,
|
||||
recipientId,
|
||||
|
||||
@@ -361,7 +361,21 @@ export class UserService {
|
||||
userCacheService: UserCacheService;
|
||||
requestCache: RequestCache;
|
||||
}): Promise<Relationship> {
|
||||
return await this.relationshipService.acceptFriendRequest({userId, targetId, userCacheService, requestCache});
|
||||
const relationship = await this.relationshipService.acceptFriendRequest({
|
||||
userId,
|
||||
targetId,
|
||||
userCacheService,
|
||||
requestCache,
|
||||
});
|
||||
|
||||
await this.channelService.ensureDmOpenForBothUsers({
|
||||
userId,
|
||||
recipientId: targetId,
|
||||
userCacheService,
|
||||
requestCache,
|
||||
});
|
||||
|
||||
return relationship;
|
||||
}
|
||||
|
||||
async blockUser({
|
||||
|
||||
Reference in New Issue
Block a user