Skip to content

Commit

Permalink
fix(moco): add ability to provide impersonation information on activi…
Browse files Browse the repository at this point in the history
…ty update (N8N-22)
  • Loading branch information
MaSpeng committed Aug 27, 2024
1 parent 2509e5a commit 304fba9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
17 changes: 17 additions & 0 deletions nodes/moco/src/nodes/Moco/ActivityDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,23 @@ export const activityFields: INodeProperties[] = [
/* -------------------------------------------------------------------------- */
/* activity:update */
/* -------------------------------------------------------------------------- */
{
displayName: 'Impersonate User Name or ID',
name: 'impersonateUserId',
type: 'options',
default: '',
typeOptions: {
loadOptionsMethod: 'listUsers',
},
description:
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code-examples/expressions/">expression</a>',
displayOptions: {
show: {
resource: ['activity'],
operation: ['update'],
},
},
},
{
displayName: 'Activity ID',
name: 'activityId',
Expand Down
5 changes: 4 additions & 1 deletion nodes/moco/src/nodes/Moco/Moco.node.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,10 @@ describe('Moco', () => {
0,
'PUT',
`/activities/${activityId}`,
{ body },
{
impersonateUserId: undefined,
body,
},
);
});

Expand Down
6 changes: 5 additions & 1 deletion nodes/moco/src/nodes/Moco/Moco.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ export class Moco implements INodeType {
if (operation === 'update') {
const activityId = this.getNodeParameter('activityId', item);

const impersonateUserId =
(this.getNodeParameter('impersonateUserId', item) as string) ||
undefined;

const body: ActivityParameters = {
date: this.getNodeParameter('date', item) as string,
project_id: this.getNodeParameter('projectId', item) as number,
Expand All @@ -398,7 +402,7 @@ export class Moco implements INodeType {
item,
'PUT',
`/activities/${activityId}`,
{ body },
{ impersonateUserId, body },
)) as User;
}
}
Expand Down

0 comments on commit 304fba9

Please sign in to comment.