Files
MATTERMOST_OPENCLAW_LIVESTATUS/plugin/server/plugin.go
sol 868574d939 fix: remove dead delete+recreate and pin code, add poll fallback test
Phase 1 cleanup:
- Remove deletePost() method (dead code, replaced by PUT in-place updates)
- Remove _postInfo Map tracking (no longer needed)
- Remove pin/unpin API calls from watcher-manager.js (incompatible with PUT updates)
- Add JSDoc note on (edited) label limitation in _flushUpdate()
- Add integration test: test/integration/poll-fallback.test.js
- Fix addSession() lastOffset===0 falsy bug (0 was treated as 'no offset')
- Fix pre-existing test failures: add lastOffset:0 where tests expect backlog reads
- Fix pre-existing session-monitor test: create stub transcript files
- Fix pre-existing status-formatter test: update indent check for blockquote format
- Format plugin/ files with Prettier (pre-existing formatting drift)
2026-03-07 20:31:32 +00:00

48 lines
1.1 KiB
Go

package main
import (
"sync"
"github.com/mattermost/mattermost/server/public/plugin"
)
// Plugin implements the Mattermost plugin interface.
type Plugin struct {
plugin.MattermostPlugin
// configurationLock synchronizes access to the configuration.
configurationLock sync.RWMutex
// configuration is the active plugin configuration.
configuration *Configuration
// store wraps KV store operations for session persistence.
store *Store
}
// OnActivate is called when the plugin is activated.
func (p *Plugin) OnActivate() error {
p.store = NewStore(p.API)
p.API.LogInfo("OpenClaw Live Status plugin activated")
return nil
}
// OnDeactivate is called when the plugin is deactivated.
func (p *Plugin) OnDeactivate() error {
// Mark all active sessions as interrupted
sessions, err := p.store.ListActiveSessions()
if err != nil {
p.API.LogWarn("Failed to list sessions on deactivate", "error", err.Error())
} else {
for _, s := range sessions {
s.Status = "interrupted"
_ = p.store.SaveSession(s.SessionKey, s)
p.broadcastUpdate(s.ChannelID, s)
}
}
p.API.LogInfo("OpenClaw Live Status plugin deactivated")
return nil
}