2023-03-23 22:47:05 +00:00
|
|
|
import { store } from '../../store/auxStore';
|
2023-08-14 20:22:46 +00:00
|
|
|
import { IAttachment, IAttachmentTranslations, IMessage } from '../../../definitions';
|
2023-03-23 22:47:05 +00:00
|
|
|
import { getAvatarURL } from '../../methods/helpers';
|
|
|
|
|
|
|
|
export function createQuoteAttachment(message: IMessage, messageLink: string): IAttachment {
|
|
|
|
const { server, version: serverVersion } = store.getState().server;
|
2023-06-16 19:21:40 +00:00
|
|
|
const avatarExternalProviderUrl = (store.getState().settings?.Accounts_AvatarExternalProviderUrl as string) || '';
|
2023-03-23 22:47:05 +00:00
|
|
|
|
|
|
|
return {
|
|
|
|
text: message.msg,
|
2023-08-14 20:22:46 +00:00
|
|
|
// this type is wrong
|
|
|
|
...('translations' in message && { translations: message?.translations as unknown as IAttachmentTranslations }),
|
2023-03-23 22:47:05 +00:00
|
|
|
message_link: messageLink,
|
|
|
|
author_name: message.alias || message.u.username,
|
|
|
|
author_icon: getAvatarURL({
|
|
|
|
avatar: message.u?.username && `/avatar/${message.u?.username}`,
|
|
|
|
type: message.t,
|
|
|
|
userId: message.u?._id,
|
|
|
|
server,
|
|
|
|
serverVersion,
|
2023-06-16 19:21:40 +00:00
|
|
|
avatarExternalProviderUrl
|
2023-03-23 22:47:05 +00:00
|
|
|
}),
|
|
|
|
attachments: message.attachments || [],
|
|
|
|
ts: message.ts
|
|
|
|
};
|
|
|
|
}
|