@@ -5,7 +5,6 @@ package plugin
55
66import (
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
13071305func (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.
0 commit comments