Skip to content

Commit 05bf5a0

Browse files
committed
add admin check
1 parent 72f817e commit 05bf5a0

File tree

11 files changed

+42
-12
lines changed

11 files changed

+42
-12
lines changed

components/linear/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/linear",
3-
"version": "0.5.5",
3+
"version": "0.5.6",
44
"description": "Pipedream Linear Components",
55
"main": "linear.app.mjs",
66
"keywords": [
@@ -15,6 +15,6 @@
1515
},
1616
"dependencies": {
1717
"@linear/sdk": "^13.0.0",
18-
"@pipedream/platform": "^1.3.0"
18+
"@pipedream/platform": "^3.0.3"
1919
}
2020
}

components/linear/sources/comment-created-instant/comment-created-instant.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ export default {
1010
...utils.getAppProps(commentCreatedInstant),
1111
key: "linear-comment-created-instant",
1212
description: "Emit new event when a new comment is created (OAuth). See the docs [here](https://developers.linear.app/docs/graphql/webhooks)",
13-
version: "0.1.5",
13+
version: "0.1.6",
1414
};

components/linear/sources/issue-created-instant/issue-created-instant.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ export default {
1010
...utils.getAppProps(issueCreatedInstant),
1111
key: "linear-issue-created-instant",
1212
description: "Emit new event when a new issue is created (OAuth). See the docs [here](https://developers.linear.app/docs/graphql/webhooks)",
13-
version: "0.3.5",
13+
version: "0.3.6",
1414
};

components/linear/sources/issue-updated-instant/issue-updated-instant.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ export default {
1010
...utils.getAppProps(issueUpdatedInstant),
1111
key: "linear-issue-updated-instant",
1212
description: "Emit new event when an issue is updated (OAuth). See the docs [here](https://developers.linear.app/docs/graphql/webhooks)",
13-
version: "0.3.5",
13+
version: "0.3.6",
1414
};

components/linear/sources/new-issue-status-updated/new-issue-status-updated.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ export default {
1010
...utils.getAppProps(newIssueStatusUpdated),
1111
key: "linear-new-issue-status-updated",
1212
description: "Emit new event when the status of an issue is updated (OAuth). See the docs [here](https://developers.linear.app/docs/graphql/webhooks)",
13-
version: "0.1.5",
13+
version: "0.1.6",
1414
};

components/linear_app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/linear_app",
3-
"version": "0.5.5",
3+
"version": "0.5.6",
44
"description": "Pipedream Linear_app Components",
55
"main": "linear_app.app.mjs",
66
"keywords": [
@@ -15,6 +15,6 @@
1515
},
1616
"dependencies": {
1717
"@linear/sdk": "^13.0.0",
18-
"@pipedream/platform": "^1.3.0"
18+
"@pipedream/platform": "^3.0.3"
1919
}
2020
}

components/linear_app/sources/comment-created-instant/comment-created-instant.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
name: "New Created Comment (Instant)",
88
description: "Emit new event when a new comment is created. See the docs [here](https://developers.linear.app/docs/graphql/webhooks)",
99
type: "source",
10-
version: "0.1.5",
10+
version: "0.1.6",
1111
dedupe: "unique",
1212
methods: {
1313
...common.methods,

components/linear_app/sources/common/webhook.mjs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import linearApp from "../../linear_app.app.mjs";
22
import constants from "../../common/constants.mjs";
33
import utils from "../../common/utils.mjs";
4+
import { ConfigurationError } from "@pipedream/platform";
45

56
export default {
67
props: {
@@ -12,6 +13,7 @@ export default {
1213
linearApp,
1314
"teamId",
1415
],
16+
reloadProps: true,
1517
},
1618
projectId: {
1719
propDefinition: [
@@ -22,6 +24,17 @@ export default {
2224
http: "$.interface.http",
2325
db: "$.service.db",
2426
},
27+
async additionalProps() {
28+
const props = {}; console.log(await this.isAdmin());
29+
if (!(await this.isAdmin())) {
30+
props.alert = {
31+
type: "alert",
32+
alertType: "error",
33+
content: "You must have an admin role to create or manage webhooks. See the Linear [documentation](https://linear.app/docs/api-and-webhooks#webhooks) for details.",
34+
};
35+
}
36+
return props;
37+
},
2538
methods: {
2639
setWebhookId(teamId, id) {
2740
this.db.set(`webhook-${teamId}`, id);
@@ -59,9 +72,26 @@ export default {
5972
getLoadedProjectId() {
6073
throw new Error("Get loaded project ID not implemented");
6174
},
75+
async isAdmin() {
76+
const { data } = await this.linearApp.makeAxiosRequest({
77+
method: "POST",
78+
data: {
79+
"query": `{
80+
user(id: "me") {
81+
admin
82+
}
83+
}`,
84+
},
85+
});
86+
return !data?.user?.admin;
87+
},
6288
},
6389
hooks: {
6490
async deploy() {
91+
if (!(await this.isAdmin())) {
92+
throw new ConfigurationError("You must have an admin role to create or manage webhooks. See the Linear [documentation](https://linear.app/docs/api-and-webhooks#webhooks) for details.");
93+
}
94+
6595
// Retrieve historical events
6696
console.log("Retrieving historical events...");
6797
const stream = this.linearApp.paginateResources({

components/linear_app/sources/issue-created-instant/issue-created-instant.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
name: "New Created Issue (Instant)",
88
description: "Emit new event when a new issue is created. See the docs [here](https://developers.linear.app/docs/graphql/webhooks)",
99
type: "source",
10-
version: "0.3.5",
10+
version: "0.3.6",
1111
dedupe: "unique",
1212
methods: {
1313
...common.methods,

components/linear_app/sources/issue-updated-instant/issue-updated-instant.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
name: "New Updated Issue (Instant)",
88
description: "Emit new event when an issue is updated. See the docs [here](https://developers.linear.app/docs/graphql/webhooks)",
99
type: "source",
10-
version: "0.3.5",
10+
version: "0.3.6",
1111
dedupe: "unique",
1212
methods: {
1313
...common.methods,

0 commit comments

Comments
 (0)