Skip to content

Commit c3d1dec

Browse files
[docs-infra] Remove comment saving in G-sheet option (#46617)
1 parent 36476e2 commit c3d1dec

File tree

3 files changed

+2
-208
lines changed

3 files changed

+2
-208
lines changed

netlify/functions/feedback-management.mts

Lines changed: 1 addition & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import querystring from 'node:querystring';
22
import { App, AwsLambdaReceiver, BlockAction, ButtonAction } from '@slack/bolt';
3-
import { JWT } from 'google-auth-library';
4-
import { sheets } from '@googleapis/sheets';
53
import { Handler } from '@netlify/functions';
64

75
const X_FEEBACKS_CHANNEL_ID = 'C04U3R2V9UK';
@@ -97,34 +95,10 @@ app.action<BlockAction<ButtonAction>>('delete_action', async ({ ack, body, clien
9795
try {
9896
await ack();
9997

100-
const {
101-
user: { username },
102-
channel,
103-
message,
104-
actions: [{ value }],
105-
} = body;
98+
const { channel, message } = body;
10699

107100
const channelId = channel?.id;
108101

109-
const { comment, currentLocationURL = '', commentSectionURL = '' } = JSON.parse(value);
110-
111-
const googleAuth = new JWT({
112-
113-
key: process.env.G_SHEET_TOKEN!.replace(/\\n/g, '\n'),
114-
scopes: ['https://www.googleapis.com/auth/spreadsheets'],
115-
});
116-
const service = sheets({ version: 'v4', auth: googleAuth });
117-
118-
// @ts-ignore
119-
service.spreadsheets.values.append({
120-
spreadsheetId: spreadSheetsIds.forLater,
121-
range: 'Deleted messages!A:D',
122-
valueInputOption: 'USER_ENTERED',
123-
resource: {
124-
values: [[username, comment, currentLocationURL, commentSectionURL]],
125-
},
126-
});
127-
128102
if (!channelId) {
129103
throw Error('feedback-management: Unknonw channel Id');
130104
}
@@ -139,50 +113,6 @@ app.action<BlockAction<ButtonAction>>('delete_action', async ({ ack, body, clien
139113
}
140114
});
141115

142-
app.action('save_message', async ({ ack, body, client, logger }) => {
143-
try {
144-
await ack();
145-
const {
146-
user: { username },
147-
channel,
148-
message,
149-
actions: [{ value }],
150-
} = body as BlockAction<ButtonAction>;
151-
152-
const channelId = channel?.id;
153-
const { comment, currentLocationURL = '', commentSectionURL = '' } = JSON.parse(value);
154-
155-
const googleAuth = new JWT({
156-
157-
key: process.env.G_SHEET_TOKEN!.replace(/\\n/g, '\n'),
158-
scopes: ['https://www.googleapis.com/auth/spreadsheets'],
159-
});
160-
const service = sheets({ version: 'v4', auth: googleAuth });
161-
162-
// @ts-ignore
163-
service.spreadsheets.values.append({
164-
spreadsheetId: spreadSheetsIds.forLater,
165-
range: 'Sheet1!A:D',
166-
valueInputOption: 'USER_ENTERED',
167-
updates: {
168-
values: [[username, comment, currentLocationURL, commentSectionURL]],
169-
},
170-
});
171-
172-
if (!channelId) {
173-
throw Error('feedback-management: Unknonw channel Id');
174-
}
175-
client.chat.postMessage({
176-
channel: channelId,
177-
thread_ts: message!.ts,
178-
as_user: true,
179-
text: `Saved in <https://docs.google.com/spreadsheets/d/${spreadSheetsIds.forLater}/>`,
180-
});
181-
} catch (error) {
182-
logger.error(JSON.stringify(error, null, 2));
183-
}
184-
});
185-
186116
// eslint-disable-next-line import/prefer-default-export
187117
export const handler: Handler = async (event, context, callback) => {
188118
if (event.httpMethod !== 'POST') {
@@ -249,19 +179,6 @@ from ${commentSectionURL}
249179
},
250180
url: `${githubRepo}/issues/new?${githubNewIssueParams}`,
251181
},
252-
{
253-
type: 'button',
254-
text: {
255-
type: 'plain_text',
256-
text: 'Save',
257-
},
258-
value: JSON.stringify({
259-
comment,
260-
currentLocationURL,
261-
commentSectionURL,
262-
}),
263-
action_id: 'save_message',
264-
},
265182
{
266183
type: 'button',
267184
text: {

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,10 @@
102102
"nx_test_unit": "cross-env NODE_ENV=test mocha \"packages/**/*.test.?(c|m)[jt]s?(x)\" \"packages-internal/**/*.test.?(c|m)[jt]s?(x)\" \"docs/**/*.test.?(c|m)[jt]s?(x)\""
103103
},
104104
"dependencies": {
105-
"@googleapis/sheets": "^9.8.0",
106105
"@netlify/functions": "^3.1.10",
107106
"@slack/bolt": "^4.4.0",
108107
"babel-plugin-transform-import-meta": "^2.3.3",
109-
"execa": "^9.6.0",
110-
"google-auth-library": "^9.15.1"
108+
"execa": "^9.6.0"
111109
},
112110
"devDependencies": {
113111
"@arethetypeswrong/cli": "^0.18.2",

pnpm-lock.yaml

Lines changed: 0 additions & 121 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)