Skip to content

Commit 56e47ba

Browse files
committed
reverted back the unnecessary code
1 parent eb54703 commit 56e47ba

File tree

2 files changed

+0
-61
lines changed

2 files changed

+0
-61
lines changed

server/api/api.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ func NewAPI(
6262
}
6363

6464
func (a *API) RegisterRoutes(r *mux.Router) {
65-
// V1 routes for simple endpoints
66-
apiv1 := r.PathPrefix("/api/v1").Subrouter()
67-
apiv1.Use(a.panicHandler)
68-
apiv1.Use(a.requireCSRFToken)
69-
a.registerKeepaliveRoute(apiv1)
70-
7165
apiv2 := r.PathPrefix("/api/v2").Subrouter()
7266
apiv2.Use(a.panicHandler)
7367
apiv2.Use(a.requireCSRFToken)
@@ -233,20 +227,3 @@ func setResponseHeader(w http.ResponseWriter, key string, value string) { //noli
233227
}
234228
header.Set(key, value)
235229
}
236-
237-
// registerKeepaliveRoute registers the keepalive endpoint for session management.
238-
func (a *API) registerKeepaliveRoute(r *mux.Router) {
239-
r.HandleFunc("/keepalive", a.handleKeepalive).Methods("GET")
240-
}
241-
242-
// handleKeepalive handles the keepalive request to maintain session.
243-
// The main purpose is to keep the session alive and prevent WebSocket staleness.
244-
func (a *API) handleKeepalive(w http.ResponseWriter, r *http.Request) {
245-
userID := getUserID(r)
246-
if userID == "" {
247-
a.errorResponse(w, r, model.NewErrUnauthorized("unauthorized"))
248-
return
249-
}
250-
a.logger.Debug("Keepalive request received", mlog.String("userID", userID))
251-
jsonStringResponse(w, http.StatusOK, `{"status":"ok"}`)
252-
}

webapp/src/index.tsx

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ export default class Plugin {
167167
rhsId?: string
168168
boardSelectorId?: string
169169
registry?: PluginRegistry
170-
activityFunc?: () => void
171170

172171
// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function
173172
async initialize(registry: PluginRegistry, mmStore: Store<GlobalState, Action<Record<string, unknown>>>): Promise<void> {
@@ -231,8 +230,6 @@ export default class Plugin {
231230
})
232231
}
233232

234-
this.userActivityWatch()
235-
236233
let lastViewedChannel = mmStore.getState().entities.channels.currentChannelId
237234
let prevTeamID: string
238235

@@ -394,36 +391,6 @@ export default class Plugin {
394391
}
395392
}
396393

397-
userActivityWatch(): void {
398-
let lastActivityTime = Number.MAX_SAFE_INTEGER
399-
const activityTimeout = 60 * 60 * 1000 // 1 hour
400-
401-
this.activityFunc = () => {
402-
const now = new Date().getTime()
403-
if (now - lastActivityTime > activityTimeout) {
404-
this.notifyConnect()
405-
}
406-
lastActivityTime = now
407-
}
408-
document.addEventListener('click', this.activityFunc)
409-
}
410-
411-
async notifyConnect(): Promise<void> {
412-
try {
413-
const response = await fetch(`${windowAny.baseURL}/api/v1/keepalive`, {
414-
method: 'GET',
415-
headers: {
416-
'X-Timezone-Offset': (-new Date().getTimezoneOffset() / 60).toString(),
417-
},
418-
})
419-
if (!response.ok) {
420-
Utils.logError(`Keep-alive request failed: ${response.status}`)
421-
}
422-
} catch (error) {
423-
Utils.logError(`Keep-alive request error: ${error}`)
424-
}
425-
}
426-
427394
uninitialize(): void {
428395
if (this.channelHeaderButtonId) {
429396
this.registry?.unregisterComponent(this.channelHeaderButtonId)
@@ -435,11 +402,6 @@ export default class Plugin {
435402
this.registry?.unregisterComponent(this.boardSelectorId)
436403
}
437404

438-
// Clean up activity watch
439-
if (this.activityFunc) {
440-
document.removeEventListener('click', this.activityFunc)
441-
}
442-
443405
// unregister websocket handlers
444406
this.registry?.unregisterWebSocketEventHandler(wsClient.clientPrefix + ACTION_UPDATE_BLOCK)
445407
}

0 commit comments

Comments
 (0)