Skip to content

Commit fda1ff2

Browse files
author
Nevyana Angelova
committed
MM-68540: Stop pushing sidebar data over cluster WS; refetch via REST
1 parent c1fde58 commit fda1ff2

2 files changed

Lines changed: 4 additions & 57 deletions

File tree

server/plugin/plugin.go

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package plugin
55

66
import (
77
"context"
8-
"encoding/json"
98
"fmt"
109
"net/http"
1110
"net/url"
@@ -25,7 +24,6 @@ import (
2524
"github.com/mattermost/mattermost/server/public/plugin"
2625
"github.com/mattermost/mattermost/server/public/pluginapi"
2726
"github.com/mattermost/mattermost/server/public/pluginapi/cluster"
28-
"github.com/mattermost/mattermost/server/public/pluginapi/experimental/bot/logger"
2927
"github.com/mattermost/mattermost/server/public/pluginapi/experimental/bot/poster"
3028

3129
"github.com/mattermost/mattermost-plugin-github/server/plugin/graphql"
@@ -1305,66 +1303,20 @@ func (p *Plugin) isOrganizationLocked() bool {
13051303
}
13061304

13071305
func (p *Plugin) sendRefreshEvent(userID string) {
1308-
eventLogger := logger.New(p.API).With(logger.LogContext{
1309-
"userid": userID,
1310-
})
1311-
1312-
ctx, cancel := context.WithTimeout(context.Background(), requestTimeout)
1313-
1314-
context := &Context{
1315-
Ctx: ctx,
1316-
UserID: userID,
1317-
Log: eventLogger,
1318-
}
1319-
1320-
defer cancel()
1321-
1322-
info, apiErr := p.getGitHubUserInfo(context.UserID)
1323-
if apiErr != nil {
1306+
if _, apiErr := p.getGitHubUserInfo(userID); apiErr != nil {
13241307
if apiErr.ID != apiErrorIDNotConnected {
13251308
p.client.Log.Debug("Failed to get github user info", "error", apiErr.Error())
13261309
}
13271310
return
13281311
}
13291312

1330-
userContext := &UserContext{
1331-
Context: *context,
1332-
GHInfo: info,
1333-
}
1334-
1335-
sidebarContent, err := p.getSidebarData(userContext)
1336-
if err != nil {
1337-
p.client.Log.Warn("Failed to get the sidebar data", "error", err.Error())
1338-
return
1339-
}
1340-
1341-
contentMap, err := sidebarContent.toMap()
1342-
if err != nil {
1343-
p.client.Log.Warn("Failed to convert sidebar content to map", "error", err.Error())
1344-
return
1345-
}
1346-
13471313
p.client.Frontend.PublishWebSocketEvent(
13481314
wsEventRefresh,
1349-
contentMap,
1315+
map[string]any{"user_id": userID},
13501316
&model.WebsocketBroadcast{UserId: userID},
13511317
)
13521318
}
13531319

1354-
func (s *SidebarContent) toMap() (map[string]any, error) {
1355-
var m map[string]any
1356-
bytes, err := json.Marshal(&s)
1357-
if err != nil {
1358-
return nil, err
1359-
}
1360-
1361-
if err = json.Unmarshal(bytes, &m); err != nil {
1362-
return nil, err
1363-
}
1364-
1365-
return m, nil
1366-
}
1367-
13681320
// getUsername returns the GitHub username for a given Mattermost user,
13691321
// if the user is connected to GitHub via this plugin.
13701322
// Otherwise it return the Mattermost username. It will be escaped via backticks.

webapp/src/websocket/index.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,9 @@ export function handleReconnect(store, reminder = false) {
7979
}
8080

8181
export function handleRefresh(store) {
82-
return (msg) => {
82+
return () => {
8383
if (store.getState()[`plugins-${manifest.id}`].connected) {
84-
const {data} = msg;
85-
86-
store.dispatch({
87-
type: ActionTypes.RECEIVED_SIDEBAR_CONTENT,
88-
data,
89-
});
84+
getSidebarContent()(store.dispatch, store.getState);
9085
}
9186
};
9287
}

0 commit comments

Comments
 (0)