decord/alpha/source/utils/ReportUtils.tsx

111 lines
3.3 KiB
TypeScript
Raw Permalink Normal View History

2026-10-12 06:59:38 +00:00
// Module ID: 6987
// Function ID: 6988
// Name: ReportUtils
2026-10-10 08:08:14 +00:00
// Dependencies: [2065, 4750, 1390, 1085, 2]
2026-07-29 08:29:29 +00:00
// Exports: canDeleteAndReportMessage, canReportAndDeleteInChannel, canReportMessage, canReportUser
2026-07-20 16:05:17 +00:00
2026-10-12 06:59:38 +00:00
// Module 6987 (ReportUtils)
2026-10-10 08:08:14 +00:00
import ChannelStore from "ChannelStore" /* 2065 */;
import PermissionStore from "PermissionStore" /* 4750 */;
2026-10-09 10:00:15 +00:00
import UserStore from "UserStore" /* 1390 */;
2026-10-03 08:58:59 +00:00
import Constants from "Constants" /* 1085 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-10-03 08:58:59 +00:00
let c3;
let closure_4;
let hasOwnProperty;
({ ChannelTypes: c3, Permissions: closure_4, MessageTypesSets: hasOwnProperty } = Constants);
let result = size.fileFinishedImporting("utils/ReportUtils.tsx");
2026-07-29 08:29:29 +00:00
export const canReportUser = function canReportUser(user) {
if (null == user) {
2026-07-20 16:05:17 +00:00
return false;
} else {
2026-10-03 08:58:59 +00:00
const id = user.id;
const currentUser = UserStore.getCurrentUser();
2026-07-20 16:05:17 +00:00
let tmp3 = null != currentUser;
if (tmp3) {
2026-10-03 08:58:59 +00:00
tmp3 = currentUser.id !== id && true !== user.system;
const tmp4 = currentUser.id !== id && true !== user.system;
2026-07-20 16:05:17 +00:00
}
return tmp3;
}
2026-07-29 08:29:29 +00:00
};
export const canReportMessage = function canReportMessage(message) {
2026-07-20 16:05:17 +00:00
let tmp = null != message;
2026-08-24 06:08:38 +00:00
if (tmp) {
2026-10-03 08:58:59 +00:00
const NON_REPORTABLE = hasOwnProperty.NON_REPORTABLE;
2026-08-24 06:08:38 +00:00
tmp = !NON_REPORTABLE.has(message.type);
}
2026-07-20 16:05:17 +00:00
if (tmp) {
2026-07-29 08:29:29 +00:00
const author = message.author;
let flag = false;
if (null != author) {
2026-10-03 08:58:59 +00:00
const id = author.id;
const currentUser = UserStore.getCurrentUser();
2026-08-24 06:08:38 +00:00
let tmp5 = null != currentUser;
if (tmp5) {
2026-10-03 08:58:59 +00:00
tmp5 = currentUser.id !== id && true !== author.system;
const tmp6 = currentUser.id !== id && true !== author.system;
2026-07-29 08:29:29 +00:00
}
2026-08-24 06:08:38 +00:00
flag = tmp5;
2026-07-29 08:29:29 +00:00
}
tmp = flag;
2026-07-20 16:05:17 +00:00
}
return tmp;
2026-07-29 08:29:29 +00:00
};
export const canReportAndDeleteInChannel = function canReportAndDeleteInChannel(channelId) {
const channel = ChannelStore.getChannel(channelId);
let tmp2 = null != channel;
if (tmp2) {
let result = channel.type === constants.DM || channel.type === tmp3.GROUP_DM;
if (!result) {
const obj = { channelId };
result = PermissionStore.canWithPartialContext(constants2.MANAGE_MESSAGES, obj);
2026-07-20 16:05:17 +00:00
}
tmp2 = result;
2026-07-20 16:05:17 +00:00
}
return tmp2;
2026-07-29 08:29:29 +00:00
};
2026-08-24 06:08:38 +00:00
export const canDeleteAndReportMessage = function canDeleteAndReportMessage(type) {
let tmp = null != type;
2026-07-20 16:05:17 +00:00
if (tmp) {
2026-08-24 06:08:38 +00:00
let tmp2 = null != type;
if (tmp2) {
2026-10-03 08:58:59 +00:00
const NON_REPORTABLE = hasOwnProperty.NON_REPORTABLE;
2026-08-24 06:08:38 +00:00
tmp2 = !NON_REPORTABLE.has(type.type);
}
2026-07-29 08:29:29 +00:00
if (tmp2) {
2026-08-24 06:08:38 +00:00
const author = type.author;
2026-07-29 08:29:29 +00:00
let flag = false;
if (null != author) {
2026-10-03 08:58:59 +00:00
const id = author.id;
const currentUser = UserStore.getCurrentUser();
2026-08-24 06:08:38 +00:00
let tmp6 = null != currentUser;
if (tmp6) {
2026-10-03 08:58:59 +00:00
tmp6 = currentUser.id !== id && true !== author.system;
const tmp7 = currentUser.id !== id && true !== author.system;
2026-07-29 08:29:29 +00:00
}
2026-08-24 06:08:38 +00:00
flag = tmp6;
2026-07-29 08:29:29 +00:00
}
tmp2 = flag;
}
tmp = tmp2;
2026-07-20 16:05:17 +00:00
}
if (tmp) {
2026-08-24 06:08:38 +00:00
const channelId = type.getChannelId();
const channel = ChannelStore.getChannel(channelId);
let tmp11 = null != channel;
if (tmp11) {
let result = channel.type === constants.DM || channel.type === tmp12.GROUP_DM;
if (!result) {
const obj = { channelId };
result = PermissionStore.canWithPartialContext(constants2.MANAGE_MESSAGES, obj);
2026-07-29 08:29:29 +00:00
}
tmp11 = result;
2026-07-29 08:29:29 +00:00
}
tmp = tmp11;
2026-07-20 16:05:17 +00:00
}
return tmp;
};