128 lines
4.2 KiB
TypeScript
128 lines
4.2 KiB
TypeScript
// Metro module 10483 (f10484).
|
|
import ChannelStore from "../stores/ChannelStore";
|
|
import { ActivityTypes, AnalyticEvents, Endpoints, LoggingInviteTypes } from "../Constants";
|
|
import { MessageSendLocation } from "../modules/messages/MessageConstants";
|
|
import Dispatcher from "../Dispatcher";
|
|
import { HTTP, rejectWithMigratedError } from "../_bundle/sendRequest";
|
|
import MessageParser from "../modules/messages/MessageParser";
|
|
import MessageActionCreators from "./MessageActionCreators";
|
|
import AppAnalyticsUtils from "../modules/app_analytics/AppAnalyticsUtils";
|
|
import ChannelActionCreators from "./ChannelActionCreators";
|
|
const r26 = {
|
|
updateActivity: (a0) => {
|
|
const { applicationId, distributor, shareActivity, token = null, duration: duration2 = 0 } = a0;
|
|
const duration = duration2;
|
|
const { closed = false, exePath = null, voiceChannelId = null, sessionId = null, mediaSessionId = null } = a0;
|
|
Dispatcher.wait(() => Dispatcher.dispatch({
|
|
type: "ACTIVITY_UPDATE_START",
|
|
applicationId,
|
|
duration,
|
|
distributor
|
|
}));
|
|
HTTP.post({
|
|
url: Endpoints.ACTIVITIES,
|
|
body: {
|
|
application_id: applicationId,
|
|
token,
|
|
duration,
|
|
share_activity: shareActivity,
|
|
distributor,
|
|
closed,
|
|
exePath,
|
|
voice_channel_id: voiceChannelId,
|
|
session_id: sessionId,
|
|
media_session_id: mediaSessionId
|
|
},
|
|
retries: 1,
|
|
oldFormErrors: true,
|
|
rejectWithError: true
|
|
}).then((result) => {
|
|
Dispatcher.dispatch({
|
|
type: "ACTIVITY_UPDATE_SUCCESS",
|
|
applicationId,
|
|
token: result.body.token,
|
|
duration,
|
|
distributor
|
|
});
|
|
}).catch(() => {
|
|
Dispatcher.dispatch({
|
|
type: "ACTIVITY_UPDATE_FAIL",
|
|
applicationId
|
|
});
|
|
});
|
|
},
|
|
sendActivityInvite: (a0) => {
|
|
const { channelId, type: type2, activity } = a0;
|
|
let content2 = a0.content;
|
|
const { targetUserId, location: location2 } = a0;
|
|
const channel = ChannelStore.getChannel(channelId);
|
|
if (channel == null) {
|
|
return Promise.resolve(null);
|
|
}
|
|
if (content2 == null) {
|
|
content2 = "";
|
|
}
|
|
return MessageActionCreators.sendMessage(channel.id, MessageParser.parse(channel, content2), false, {
|
|
activityAction: {
|
|
type: type2,
|
|
activity,
|
|
targetUserId
|
|
},
|
|
location: MessageSendLocation.ACTIVITY_SHARE
|
|
}).then((result) => {
|
|
AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.INVITE_SENT, {
|
|
location: location2,
|
|
invite_type: activity.type === ActivityTypes.LISTENING ? LoggingInviteTypes.SPOTIFY : LoggingInviteTypes.APPLICATION,
|
|
application_id: activity.application_id,
|
|
guild_id: channel.getGuildId(),
|
|
channel_id: channel.id,
|
|
message_id: result != null ? result.body.id : null
|
|
});
|
|
return Promise.resolve(channel);
|
|
}, (a0) => Promise.reject(a0));
|
|
},
|
|
sendActivityInviteUser: function sendActivityInviteUser({ userId, type, activity: activity2, content, location: location3 }) {
|
|
return ChannelActionCreators.ensurePrivateChannel(userId).then((result) => this.sendActivityInvite({
|
|
channelId: result,
|
|
type,
|
|
activity: activity2,
|
|
content,
|
|
location: location3
|
|
}));
|
|
},
|
|
getJoinSecret: async (c17999_0, c17999_1, c17999_2, channel_id, message_id) => {
|
|
const query = {};
|
|
if (channel_id != null) {
|
|
query.channel_id = channel_id;
|
|
}
|
|
if (message_id != null) {
|
|
query.message_id = message_id;
|
|
}
|
|
let c30228_0 = await HTTP.get({
|
|
url: Endpoints.USER_ACTIVITY_JOIN(c17999_0, c17999_1, c17999_2),
|
|
retries: 3,
|
|
query,
|
|
rejectWithError: rejectWithMigratedError()
|
|
});
|
|
return {
|
|
secret: c30228_0.body.secret,
|
|
joinUrl: c30228_0.body.join_url
|
|
};
|
|
},
|
|
subscribeActivities: async (c18000_0) => (await HTTP.post({
|
|
url: Endpoints.USER_ACTIVITY_SUBSCRIBE,
|
|
body: {
|
|
subscriptions: c18000_0.map((item) => ({
|
|
user_id: item.userId,
|
|
application_id: item.applicationId,
|
|
party_id: item.partyId,
|
|
message_id: item.messageId,
|
|
channel_id: item.channelId
|
|
}))
|
|
},
|
|
retries: 1,
|
|
rejectWithError: rejectWithMigratedError()
|
|
})).body
|
|
};
|
|
export default r26;
|