mirror of
https://github.com/lone-cloud/prism
synced 2026-06-03 08:43:10 -07:00
fix notify self, fix superfluous WriteHeader warning
This commit is contained in:
parent
3f8fbe5b99
commit
519dd9e46f
4 changed files with 10 additions and 11 deletions
|
|
@ -66,7 +66,7 @@ func (m *Monitor) monitor(ctx context.Context) error {
|
|||
case <-m.newMessagesChan:
|
||||
idleCmd.Close()
|
||||
|
||||
m.sendNotification() // Errors already logged in sendNotification()
|
||||
m.sendNotification()
|
||||
|
||||
idleCmd, err = m.client.Idle()
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -107,7 +107,6 @@ func (c *Client) GetLinkedAccount() (*Account, error) {
|
|||
return &Account{Number: accounts[0].Number}, nil
|
||||
}
|
||||
|
||||
// CreateGroup creates a Signal group using updateGroup JSON-RPC method
|
||||
func (c *Client) CreateGroup(name string) (string, string, error) {
|
||||
if c == nil {
|
||||
return "", "", fmt.Errorf("signal client not initialized")
|
||||
|
|
@ -123,7 +122,7 @@ func (c *Client) CreateGroup(name string) (string, string, error) {
|
|||
|
||||
params := map[string]interface{}{
|
||||
"name": name,
|
||||
"member": []string{}, // Empty group
|
||||
"member": []string{},
|
||||
}
|
||||
|
||||
result, err := c.CallWithAccount("updateGroup", params, account.Number)
|
||||
|
|
@ -145,7 +144,6 @@ func (c *Client) CreateGroup(name string) (string, string, error) {
|
|||
return response.GroupID, account.Number, nil
|
||||
}
|
||||
|
||||
// SendGroupMessage sends a message to a Signal group
|
||||
func (c *Client) SendGroupMessage(groupID, message string) error {
|
||||
if c == nil {
|
||||
return fmt.Errorf("signal client not initialized")
|
||||
|
|
@ -160,9 +158,9 @@ func (c *Client) SendGroupMessage(groupID, message string) error {
|
|||
}
|
||||
|
||||
params := map[string]interface{}{
|
||||
"groupId": groupID,
|
||||
"message": message,
|
||||
"notify-self": true,
|
||||
"groupId": groupID,
|
||||
"message": message,
|
||||
"notifySelf": true,
|
||||
}
|
||||
|
||||
_, err = c.CallWithAccount("send", params, account.Number)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ func (l *LinkDevice) GenerateQR() (string, error) {
|
|||
return l.qrCode, nil
|
||||
}
|
||||
|
||||
// Call signal-cli's startLink JSON-RPC method directly
|
||||
result, err := l.client.Call("startLink", nil)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to start link: %w", err)
|
||||
|
|
|
|||
|
|
@ -51,14 +51,16 @@ func loggingMiddleware(logger *slog.Logger) func(http.Handler) http.Handler {
|
|||
|
||||
type responseWriter struct {
|
||||
http.ResponseWriter
|
||||
statusCode int
|
||||
statusCode int
|
||||
headerWritten bool
|
||||
}
|
||||
|
||||
func (rw *responseWriter) WriteHeader(code int) {
|
||||
if rw.statusCode == http.StatusOK {
|
||||
if !rw.headerWritten {
|
||||
rw.statusCode = code
|
||||
rw.ResponseWriter.WriteHeader(code)
|
||||
rw.headerWritten = true
|
||||
}
|
||||
rw.ResponseWriter.WriteHeader(code)
|
||||
}
|
||||
|
||||
func securityHeadersMiddleware() func(http.Handler) http.Handler {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue