1
1
import querystring from 'node:querystring' ;
2
2
import { App , AwsLambdaReceiver , BlockAction , ButtonAction } from '@slack/bolt' ;
3
- import { JWT } from 'google-auth-library' ;
4
- import { sheets } from '@googleapis/sheets' ;
5
3
import { Handler } from '@netlify/functions' ;
6
4
7
5
const X_FEEBACKS_CHANNEL_ID = 'C04U3R2V9UK' ;
@@ -97,34 +95,10 @@ app.action<BlockAction<ButtonAction>>('delete_action', async ({ ack, body, clien
97
95
try {
98
96
await ack ( ) ;
99
97
100
- const {
101
- user : { username } ,
102
- channel,
103
- message,
104
- actions : [ { value } ] ,
105
- } = body ;
98
+ const { channel, message } = body ;
106
99
107
100
const channelId = channel ?. id ;
108
101
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
-
128
102
if ( ! channelId ) {
129
103
throw Error ( 'feedback-management: Unknonw channel Id' ) ;
130
104
}
@@ -139,50 +113,6 @@ app.action<BlockAction<ButtonAction>>('delete_action', async ({ ack, body, clien
139
113
}
140
114
} ) ;
141
115
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
-
186
116
// eslint-disable-next-line import/prefer-default-export
187
117
export const handler : Handler = async ( event , context , callback ) => {
188
118
if ( event . httpMethod !== 'POST' ) {
@@ -249,19 +179,6 @@ from ${commentSectionURL}
249
179
} ,
250
180
url : `${ githubRepo } /issues/new?${ githubNewIssueParams } ` ,
251
181
} ,
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
- } ,
265
182
{
266
183
type : 'button' ,
267
184
text : {
0 commit comments