Compare commits

..

49 Commits

Author SHA1 Message Date
FoxxMD
3bcc3d78e8 Merge branch 'edge' 2022-09-28 09:28:38 -04:00
FoxxMD
296f1c8dee Merge branch 'edge' 2022-09-14 15:30:27 -04:00
FoxxMD
e32ac60db5 Merge branch 'edge' 2022-09-14 15:29:13 -04:00
FoxxMD
859680dca8 Merge branch 'edge' 2022-09-01 09:03:27 -04:00
FoxxMD
ffa1e423b2 Merge branch 'edge' 2022-08-23 09:49:23 -04:00
FoxxMD
09cb08492c Merge branch 'edge' 2022-08-23 09:47:59 -04:00
FoxxMD
d9ab81ab8c Merge branch 'edge' 2022-07-27 09:19:30 -04:00
FoxxMD
98691bd19c Merge branch 'edge' 2022-07-15 09:27:22 -04:00
FoxxMD
8123c34463 Merge branch 'edge' 2022-06-21 16:13:54 -04:00
FoxxMD
3292d011fa Merge branch 'edge' 2022-06-21 10:03:14 -04:00
FoxxMD
661a0ae440 Merge branch 'edge' 2022-05-26 09:59:32 -04:00
FoxxMD
05f477b67d Merge branch 'edge' 2022-05-12 12:27:51 -04:00
Matt Foxx
1317a5916c Merge pull request #86 from wchristian/example_fix
trying to use names key in authorfilter causes config parse failure
2022-04-05 16:55:56 -04:00
Christian Walde
e9135ec1ef trying to use names key in authorfilter causes config parse failure 2022-04-05 13:49:41 +02:00
FoxxMD
e58a0f8f21 Merge branch 'edge' 2022-03-14 12:39:05 -04:00
FoxxMD
f7cebc013b Merge branch 'edge' 2022-03-08 09:48:06 -05:00
FoxxMD
ae8e11feb4 Merge branch 'edge' 2022-02-22 11:11:46 -05:00
FoxxMD
e07b8cc291 Merge branch 'edge' 2022-02-18 11:58:28 -05:00
FoxxMD
fc51928054 Merge branch 'edge' 2022-02-02 16:59:56 -05:00
FoxxMD
e2590e50f8 Merge branch 'edge' 2022-01-28 17:27:51 -05:00
FoxxMD
aaed0d3419 Merge branch 'edge' 2022-01-21 10:46:11 -05:00
FoxxMD
bc7eff8928 Merge branch 'edge' 2022-01-14 15:27:09 -05:00
FoxxMD
d6954533a0 Merge branch 'edge' 2022-01-10 12:32:14 -05:00
FoxxMD
ba53233640 Merge branch 'edge' 2022-01-07 09:31:14 -05:00
FoxxMD
1ac7ad4724 Merge branch 'edge' 2022-01-03 16:35:01 -05:00
FoxxMD
2a282a0d6f Merge branch 'edge' 2021-12-21 09:35:21 -05:00
FoxxMD
fd5a92758d Merge branch 'edge' 2021-11-28 19:43:20 -05:00
FoxxMD
39daa11f2d Merge branch 'edge' 2021-11-15 12:53:28 -05:00
FoxxMD
dac6541e28 Merge branch 'edge' 2021-11-01 16:12:43 -04:00
FoxxMD
97906281e6 Merge branch 'edge' 2021-11-01 14:55:10 -04:00
FoxxMD
487f13f704 Merge branch 'edge' 2021-10-12 11:56:51 -04:00
FoxxMD
631e21452c Merge branch 'edge' 2021-09-28 16:36:13 -04:00
FoxxMD
4f3685a1f5 Merge branch 'edge' 2021-09-21 15:18:38 -04:00
FoxxMD
d2d945db2c Merge branch 'edge' 2021-09-21 15:08:28 -04:00
FoxxMD
910f7f79ef Merge branch 'edge' 2021-09-20 10:54:32 -04:00
FoxxMD
a11b667d5e Merge branch 'edge' 2021-09-13 16:16:55 -04:00
FoxxMD
885e3fa765 Merge branch 'edge' 2021-08-26 16:04:01 -04:00
FoxxMD
465c3c9acf Merge branch 'edge' 2021-08-20 15:02:24 -04:00
FoxxMD
161251a943 Merge branch 'edge' 2021-08-05 14:40:06 -04:00
FoxxMD
ce4cb96d9a Merge branch 'edge' 2021-08-03 23:39:14 -04:00
FoxxMD
c317f95953 Merge branch 'edge' 2021-08-03 22:43:02 -04:00
FoxxMD
d0e0515990 Merge branch 'edge' 2021-08-02 15:44:57 -04:00
FoxxMD
cdddd8de48 Merge branch 'edge' 2021-07-30 18:17:38 -04:00
FoxxMD
f598215d88 Merge branch 'edge' 2021-07-30 14:46:51 -04:00
FoxxMD
0c7218571c Merge branch 'edge' 2021-07-29 13:25:16 -04:00
FoxxMD
acc7c49e0e Merge branch 'edge' 2021-07-29 11:27:42 -04:00
FoxxMD
01839512d5 Merge branch 'edge' 2021-07-29 11:14:33 -04:00
FoxxMD
4680640b0c Merge branch 'develop' 2021-07-28 16:58:36 -04:00
Matt Foxx
b813ebdd96 Create dockerhub.yml 2021-07-28 11:27:04 -04:00
7 changed files with 23 additions and 184 deletions

View File

@@ -40,7 +40,7 @@
// for this to pass the Author of the Submission must not have the flair "Supreme Memer" and have the name "user1" or "user2"
{
"flairText": ["Supreme Memer"],
"names": ["user1","user2"]
"name": ["user1","user2"]
},
{
// for this to pass the Author of the Submission must not have the flair "Decent Memer"

View File

@@ -30,7 +30,7 @@ runs:
# for this to pass the Author of the Submission must not have the flair "Supreme Memer" and have the name "user1" or "user2"
- flairText:
- Supreme Memer
names:
name:
- user1
- user2
# for this to pass the Author of the Submission must not have the flair "Decent Memer"

View File

@@ -395,82 +395,3 @@ export interface RuleResultsTemplateData {
export interface GenericContentTemplateData extends BaseTemplateData, Partial<RuleResultsTemplateData>, Partial<ActionResultsTemplateData> {
item?: (SubmissionTemplateData | CommentTemplateData)
}
export type ModerationActionType =
'banuser'
| 'unbanuser'
| 'spamlink'
| 'removelink'
| 'approvelink'
| 'spamcomment'
| 'removecomment'
| 'approvecomment'
| 'addmoderator'
| 'showcomment'
| 'invitemoderator'
| 'uninvitemoderator'
| 'acceptmoderatorinvite'
| 'removemoderator'
| 'addcontributor'
| 'removecontributor'
| 'editsettings'
| 'editflair'
| 'distinguish'
| 'marknsfw'
| 'wikibanned'
| 'wikicontributor'
| 'wikiunbanned'
| 'wikipagelisted'
| 'removewikicontributor'
| 'wikirevise'
| 'wikipermlevel'
| 'ignorereports'
| 'unignorereports'
| 'setpermissions'
| 'setsuggestedsort'
| 'sticky'
| 'unsticky'
| 'setcontestmode'
| 'unsetcontestmode'
| 'lock'
| 'unlock'
| 'muteuser'
| 'unmuteuser'
| 'createrule'
| 'editrule'
| 'reorderrules'
| 'deleterule'
| 'spoiler'
| 'unspoiler'
| 'modmail_enrollment'
| 'community_styling'
| 'community_widgets'
| 'markoriginalcontent'
| 'collections'
| 'events'
| 'hidden_award'
| 'add_community_topics'
| 'remove_community_topics'
| 'create_scheduled_post'
| 'edit_scheduled_post'
| 'delete_scheduled_post'
| 'submit_scheduled_post'
| 'edit_post_requirements'
| 'invitesubscriber'
| 'submit_content_rating_survey'
| 'adjust_post_crowd_control_level'
| 'enable_post_crowd_control_filter'
| 'disable_post_crowd_control_filter'
| 'deleteoverriddenclassification'
| 'overrideclassification'
| 'reordermoderators'
| 'snoozereports'
| 'unsnoozereports'
| 'addnote'
| 'deletenote'
| 'addremovalreason'
| 'createremovalreason'
| 'updateremovalreason'
| 'deleteremovalreason';
export const moderatorActionTypes = ['banuser', 'unbanuser', 'spamlink', 'removelink', 'approvelink', 'spamcomment', 'removecomment', 'approvecomment', 'addmoderator', 'showcomment', 'invitemoderator', 'uninvitemoderator', 'acceptmoderatorinvite', 'removemoderator', 'addcontributor', 'removecontributor', 'editsettings', 'editflair', 'distinguish', 'marknsfw', 'wikibanned', 'wikicontributor', 'wikiunbanned', 'wikipagelisted', 'removewikicontributor', 'wikirevise', 'wikipermlevel', 'ignorereports', 'unignorereports', 'setpermissions', 'setsuggestedsort', 'sticky', 'unsticky', 'setcontestmode', 'unsetcontestmode', 'lock', 'unlock', 'muteuser', 'unmuteuser', 'createrule', 'editrule', 'reorderrules', 'deleterule', 'spoiler', 'unspoiler', 'modmail_enrollment', 'community_styling', 'community_widgets', 'markoriginalcontent', 'collections', 'events', 'hidden_award', 'add_community_topics', 'remove_community_topics', 'create_scheduled_post', 'edit_scheduled_post', 'delete_scheduled_post', 'submit_scheduled_post', 'edit_post_requirements', 'invitesubscriber', 'submit_content_rating_survey', 'adjust_post_crowd_control_level', 'enable_post_crowd_control_filter', 'disable_post_crowd_control_filter', 'deleteoverriddenclassification', 'overrideclassification', 'reordermoderators', 'snoozereports', 'unsnoozereports', 'addnote', 'deletenote', 'addremovalreason', 'createremovalreason', 'updateremovalreason', 'deleteremovalreason'];

View File

@@ -300,12 +300,6 @@ export class HistoryRule extends Rule {
this.logger.verbose(`${PASS} ${resultData.result}`);
return Promise.resolve([true, this.getResult(true, resultData)]);
} else {
// log failures for easier debugging
for(const res of criteriaResults) {
const resultData = this.generateResultDataFromCriteria(res);
this.logger.verbose(`${FAIL} ${resultData.result}`);
}
}
return Promise.resolve([false, this.getResult(false, {result: failCriteriaResult})]);

View File

@@ -1,111 +1,39 @@
import {Submission, RedditUser, Comment, Subreddit, PrivateMessage} from "snoowrap/dist/objects"
import {generateSnoowrapEntityFromRedditThing, parseRedditFullname} from "../../util"
import Snoowrap from "snoowrap";
import {ModerationActionType} from "../../Common/Infrastructure/Atomic";
//import {ExtendedSnoowrap} from "../../Utils/SnoowrapClients";
export interface ModActionRaw {
action?: ModerationActionType | null
action?: string | null
reddit_id?: string | null
details?: string | null
description?: string | null
}
export interface ModActionRawNormalized extends ModActionRaw {
createdBy?: RedditUser | Subreddit
subreddit: Subreddit
}
export interface ModLogRaw {
id: string
mod_id36: string // wtf
mod: string // name of moderator that performed the action
target_fullname: string // ThingID IE t3_wuywlr
target_author: string
details: string // flair_edit
action: ModerationActionType
description: string
target_body: string
subreddit_name_prefixed: string
subreddit: Subreddit // proxy object
created_utc: number
}
export class ModAction {
action?: ModerationActionType
action?: string
actedOn?: RedditUser | Submission | Comment | Subreddit | PrivateMessage
details?: string
description?: string
createdBy?: RedditUser | Subreddit
subreddit?: Subreddit
constructor(data: ModActionRawNormalized | ModLogRaw | undefined, client: Snoowrap, subreddit?: Subreddit) {
if(data !== undefined) {
const {
action,
details,
description
} = data || {};
constructor(data: ModActionRaw | undefined, client: Snoowrap) {
const {
action,
reddit_id,
details,
description
} = data || {};
this.action = action !== null ? action : undefined;
this.details = details !== null ? details : undefined;
this.description = description !== null ? description : undefined;
if(subreddit !== undefined) {
this.subreddit = subreddit;
if (reddit_id !== null && reddit_id !== undefined) {
const thing = parseRedditFullname(reddit_id);
if (thing !== undefined) {
this.actedOn = generateSnoowrapEntityFromRedditThing(thing, client);
}
if(asModActionRaw(data)) {
const {
reddit_id,
createdBy,
subreddit: subFromData
} = data as ModActionRawNormalized || {};
this.createdBy = createdBy;
if(this.subreddit === undefined) {
this.subreddit = subFromData;
}
if (reddit_id !== null && reddit_id !== undefined) {
const thing = parseRedditFullname(reddit_id);
if (thing !== undefined) {
this.actedOn = generateSnoowrapEntityFromRedditThing(thing, client);
}
}
} else {
const {
target_fullname,
target_author,
mod,
mod_id36,
subreddit: subFromData
} = data || {};
if (target_fullname !== null && target_fullname !== undefined) {
const thing = parseRedditFullname(target_fullname);
if (thing !== undefined) {
this.actedOn = generateSnoowrapEntityFromRedditThing(thing, client);
if (this.actedOn instanceof RedditUser) {
this.actedOn.name = target_author;
}
}
}
const author = parseRedditFullname(`t2_${mod_id36}`);
if(author !== undefined) {
this.createdBy = generateSnoowrapEntityFromRedditThing(author, client) as RedditUser;
if (this.createdBy instanceof RedditUser) {
this.createdBy.name = mod;
}
}
if(this.subreddit === undefined) {
this.subreddit = subFromData;
}
}
this.action = action !== null ? action : undefined;
this.details = details !== null ? details : undefined;
this.description = description !== null ? description : undefined;
}
}
toRaw(): ModActionRaw {
@@ -122,8 +50,4 @@ export class ModAction {
}
}
export const asModActionRaw = (data: any): data is ModActionRaw => {
return data !== null && 'reddit_id' in data;
}
export default ModAction;

View File

@@ -81,7 +81,7 @@ export class ModNote {
this.createdBy.name = data.operator;
}
this.action = new ModAction({...data.mod_action_data, createdBy: this.createdBy, subreddit: this.subreddit}, client);
this.action = new ModAction(data.mod_action_data, client);
if (this.action.actedOn instanceof RedditUser && this.action.actedOn.id === this.user.id) {
this.action.actedOn = this.user;
}

View File

@@ -57,7 +57,7 @@ import {
filterByTimeRequirement,
asSubreddit,
modActionCriteriaSummary,
parseRedditFullname, asStrongImageHashCache, matchesRelativeDateTime, generateFullWikiUrl
parseRedditFullname, asStrongImageHashCache, matchesRelativeDateTime
} from "../util";
import LoggedError from "../Utils/LoggedError";
import {
@@ -1770,7 +1770,7 @@ export class SubredditResources {
try {
// @ts-ignore
const wikiPage = sub.getWikiPage(wiki);
const wikiPage = sub.getWikiPage(wikiContext.wiki);
const wikiContent = await wikiPage.content_md;
return {val: wikiContent, fromCache: false, hash: cacheKey};
} catch (err: any) {
@@ -1786,9 +1786,9 @@ export class SubredditResources {
}
}
throw new CMError(`Wiki page ${generateFullWikiUrl(subreddit, wiki)} ${error} (${err.statusCode})${reasons.length > 0 ? `because: ${reasons.join(' | ')}` : '.'}`, {cause: err});
throw new CMError(`Wiki page ${location} ${error} (${err.statusCode})${reasons.length > 0 ? `because: ${reasons.join(' | ')}` : '.'}`, {cause: err});
} else {
throw new CMError(`Wiki page ${generateFullWikiUrl(subreddit, wiki)} could not be read`, {cause: err});
throw new CMError(`Wiki page ${location} could not be read`, {cause: err});
}
}
}