Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ describe('New Activity Automation Worker tests', () => {
default: true,
custom: true,
},
isBot: {
default: false,
},
},
},

Expand All @@ -86,7 +89,6 @@ describe('New Activity Automation Worker tests', () => {
id: '1234',
type: 'comment',
platform: PlatformType.DISCORD,

body: 'Crowd.dev is awesome!',
}

Expand Down Expand Up @@ -129,6 +131,35 @@ describe('New Activity Automation Worker tests', () => {
expect(await shouldProcessActivity(activity, automation)).toBeFalsy()
})

it("Shouldn't process an activity that belongs to a bot", async () => {
const automation = createAutomationData({
platforms: [PlatformType.DEVTO],
types: ['comment'],
keywords: ['Crowd.dev'],
teamMemberActivities: false,
})

const activity = {
id: '1234',
type: 'comment',
platform: PlatformType.DEVTO,
member: {
attributes: {
isTeamMember: {
default: false,
custom: true,
},
isBot: {
default: true,
},
},
},
body: 'Crowd.dev all awesome!',
}

expect(await shouldProcessActivity(activity, automation)).toBeFalsy()
})

it("Shouldn't process an activity that belongs to a team member", async () => {
const automation = createAutomationData({
platforms: [PlatformType.DEVTO],
Expand All @@ -147,6 +178,9 @@ describe('New Activity Automation Worker tests', () => {
default: true,
custom: true,
},
isBot: {
default: false,
},
},
},
body: 'Crowd.dev all awesome!',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ export const shouldProcessActivity = async (
process = false
}

if (activity?.member?.attributes?.isBot && activity?.member?.attributes?.isBot.default) {
log.warn(
`Ignoring automation ${automation.id} - Activity ${activity.id} belongs to a bot, cannot be processed automaticaly!`,
)
process = false
}

if (process) {
const userContext = await SequelizeRepository.getDefaultIRepositoryOptions()
const repo = new AutomationExecutionRepository(userContext)
Expand Down