2020-08-05 12:16:17 +00:00
|
|
|
export const INBOX_TYPES = {
|
|
|
|
WEB: 'Channel::WebWidget',
|
|
|
|
FB: 'Channel::FacebookPage',
|
|
|
|
TWITTER: 'Channel::TwitterProfile',
|
|
|
|
TWILIO: 'Channel::TwilioSms',
|
2021-10-05 18:05:06 +00:00
|
|
|
WHATSAPP: 'Channel::Whatsapp',
|
2020-08-05 12:16:17 +00:00
|
|
|
API: 'Channel::Api',
|
|
|
|
EMAIL: 'Channel::Email',
|
2021-09-15 12:42:56 +00:00
|
|
|
TELEGRAM: 'Channel::Telegram',
|
2021-09-14 17:14:53 +00:00
|
|
|
LINE: 'Channel::Line',
|
2022-02-03 23:22:13 +00:00
|
|
|
SMS: 'Channel::Sms',
|
2020-08-05 12:16:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
computed: {
|
|
|
|
channelType() {
|
|
|
|
return this.inbox.channel_type;
|
|
|
|
},
|
|
|
|
isAPIInbox() {
|
|
|
|
return this.channelType === INBOX_TYPES.API;
|
|
|
|
},
|
|
|
|
isATwitterInbox() {
|
|
|
|
return this.channelType === INBOX_TYPES.TWITTER;
|
|
|
|
},
|
|
|
|
isAFacebookInbox() {
|
|
|
|
return this.channelType === INBOX_TYPES.FB;
|
|
|
|
},
|
|
|
|
isAWebWidgetInbox() {
|
|
|
|
return this.channelType === INBOX_TYPES.WEB;
|
|
|
|
},
|
|
|
|
isATwilioChannel() {
|
|
|
|
return this.channelType === INBOX_TYPES.TWILIO;
|
|
|
|
},
|
2021-09-14 17:14:53 +00:00
|
|
|
isALineChannel() {
|
|
|
|
return this.channelType === INBOX_TYPES.LINE;
|
|
|
|
},
|
2020-08-05 12:16:17 +00:00
|
|
|
isAnEmailChannel() {
|
|
|
|
return this.channelType === INBOX_TYPES.EMAIL;
|
|
|
|
},
|
2021-09-30 20:15:29 +00:00
|
|
|
isATelegramChannel() {
|
|
|
|
return this.channelType === INBOX_TYPES.TELEGRAM;
|
|
|
|
},
|
2020-08-05 12:16:17 +00:00
|
|
|
isATwilioSMSChannel() {
|
2021-09-29 07:26:45 +00:00
|
|
|
const { medium: medium = '' } = this.inbox;
|
|
|
|
return this.isATwilioChannel && medium === 'sms';
|
2020-08-05 12:16:17 +00:00
|
|
|
},
|
2022-03-02 09:39:56 +00:00
|
|
|
isASmsInbox() {
|
|
|
|
return this.channelType === INBOX_TYPES.SMS || this.isATwilioSMSChannel;
|
|
|
|
},
|
2020-08-05 12:16:17 +00:00
|
|
|
isATwilioWhatsappChannel() {
|
2021-09-29 07:26:45 +00:00
|
|
|
const { medium: medium = '' } = this.inbox;
|
|
|
|
return this.isATwilioChannel && medium === 'whatsapp';
|
|
|
|
},
|
2021-10-06 14:04:34 +00:00
|
|
|
chatAdditionalAttributes() {
|
|
|
|
const { additional_attributes: additionalAttributes } = this.chat || {};
|
|
|
|
return additionalAttributes || {};
|
|
|
|
},
|
2021-09-29 07:26:45 +00:00
|
|
|
isTwitterInboxTweet() {
|
2021-10-06 14:04:34 +00:00
|
|
|
return this.chatAdditionalAttributes.type === 'tweet';
|
2021-09-29 07:26:45 +00:00
|
|
|
},
|
|
|
|
twilioBadge() {
|
|
|
|
return `${this.isATwilioSMSChannel ? 'sms' : 'whatsapp'}`;
|
|
|
|
},
|
|
|
|
twitterBadge() {
|
2021-10-06 14:04:34 +00:00
|
|
|
return `${this.isTwitterInboxTweet ? 'twitter-tweet' : 'twitter-dm'}`;
|
|
|
|
},
|
|
|
|
facebookBadge() {
|
|
|
|
return this.chatAdditionalAttributes.type || 'facebook';
|
2021-09-29 07:26:45 +00:00
|
|
|
},
|
|
|
|
inboxBadge() {
|
2021-10-14 14:48:43 +00:00
|
|
|
let badgeKey = '';
|
2021-09-29 07:26:45 +00:00
|
|
|
if (this.isATwitterInbox) {
|
2021-10-14 07:25:46 +00:00
|
|
|
badgeKey = this.twitterBadge;
|
|
|
|
} else if (this.isAFacebookInbox) {
|
|
|
|
badgeKey = this.facebookBadge;
|
|
|
|
} else if (this.isATwilioChannel) {
|
|
|
|
badgeKey = this.twilioBadge;
|
|
|
|
} else if (this.isAWhatsappChannel) {
|
|
|
|
badgeKey = 'whatsapp';
|
2021-09-29 07:26:45 +00:00
|
|
|
}
|
2021-10-14 07:25:46 +00:00
|
|
|
return badgeKey || this.channelType;
|
2020-08-05 12:16:17 +00:00
|
|
|
},
|
2021-10-05 18:05:06 +00:00
|
|
|
isAWhatsappChannel() {
|
|
|
|
return (
|
|
|
|
this.channelType === INBOX_TYPES.WHATSAPP ||
|
|
|
|
this.isATwilioWhatsappChannel
|
|
|
|
);
|
|
|
|
},
|
2020-08-05 12:16:17 +00:00
|
|
|
},
|
|
|
|
};
|