Skip to content

Commit

Permalink
ran go-fmt on complete sourcecode
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernhard B committed Apr 1, 2022
1 parent d34fcb9 commit 0b6bd44
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 32 deletions.
15 changes: 7 additions & 8 deletions src/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package api
import (
"bytes"
"encoding/json"
"errors"
"net/http"
"strconv"
"time"
"errors"

"github.com/gabriel-vasile/mimetype"
"github.com/gin-gonic/gin"
Expand All @@ -29,9 +29,9 @@ const (
)

type UpdateContactRequest struct {
Recipient string `json:"recipient"`
Name *string `json:"name"`
ExpirationInSeconds *int `json:"expiration_in_seconds"`
Recipient string `json:"recipient"`
Name *string `json:"name"`
ExpirationInSeconds *int `json:"expiration_in_seconds"`
}

type GroupPermissions struct {
Expand All @@ -48,11 +48,11 @@ type CreateGroupRequest struct {
}

type ChangeGroupMembersRequest struct {
Members []string `json:"members"`
Members []string `json:"members"`
}

type ChangeGroupAdminsRequest struct {
Admins []string `json:"admins"`
Admins []string `json:"admins"`
}

type LoggingConfiguration struct {
Expand Down Expand Up @@ -360,7 +360,7 @@ func (a *Api) handleSignalReceive(ws *websocket.Conn, number string, stop chan s

for {
select {
case <-stop:
case <-stop:
ws.Close()
return
case msg := <-receiveChannel:
Expand Down Expand Up @@ -1351,7 +1351,6 @@ func (a *Api) SearchForNumbers(c *gin.Context) {
c.JSON(200, searchResponse)
}


// @Summary Updates the info associated to a number on the contact list. If the contact doesn’t exist yet, it will be added.
// @Tags Contacts
// @Description Updates the info associated to a number on the contact list.
Expand Down
26 changes: 13 additions & 13 deletions src/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ type About struct {
}

type SearchResultEntry struct {
Number string `json:"number"`
Registered bool `json:"registered"`
Number string `json:"number"`
Registered bool `json:"registered"`
}

func cleanupTmpFiles(paths []string) {
Expand Down Expand Up @@ -470,7 +470,7 @@ func (s *SignalClient) send(number string, message string,

func (s *SignalClient) About() About {
about := About{SupportedApiVersions: []string{"v1", "v2"}, BuildNr: 2, Mode: getSignalCliModeString(s.signalCliMode),
Version: utils.GetEnv("BUILD_VERSION", "unset")}
Version: utils.GetEnv("BUILD_VERSION", "unset")}
return about
}

Expand Down Expand Up @@ -533,7 +533,7 @@ func (s *SignalClient) getJsonRpc2Client(number string) (*JsonRpc2Client, error)
return nil, errors.New("Number not registered with JSON-RPC")
}

func (s *SignalClient) getJsonRpc2Clients() ([]*JsonRpc2Client) {
func (s *SignalClient) getJsonRpc2Clients() []*JsonRpc2Client {
jsonRpc2Clients := []*JsonRpc2Client{}
for _, client := range s.jsonRpc2Clients {
jsonRpc2Clients = append(jsonRpc2Clients, client)
Expand Down Expand Up @@ -709,10 +709,10 @@ func (s *SignalClient) updateGroupMembers(number string, groupId string, members

if s.signalCliMode == JsonRpc {
type Request struct {
Name string `json:"name,omitempty"`
Members []string `json:"member,omitempty"`
Name string `json:"name,omitempty"`
Members []string `json:"member,omitempty"`
RemoveMembers []string `json:"remove-member,omitempty"`
GroupId string `json:"groupId"`
GroupId string `json:"groupId"`
}
request := Request{GroupId: internalGroupId}
if add {
Expand Down Expand Up @@ -772,10 +772,10 @@ func (s *SignalClient) updateGroupAdmins(number string, groupId string, admins [

if s.signalCliMode == JsonRpc {
type Request struct {
Name string `json:"name,omitempty"`
Admins []string `json:"admin,omitempty"`
Name string `json:"name,omitempty"`
Admins []string `json:"admin,omitempty"`
RemoveAdmins []string `json:"remove-admin,omitempty"`
GroupId string `json:"groupId"`
GroupId string `json:"groupId"`
}
request := Request{GroupId: internalGroupId}
if add {
Expand Down Expand Up @@ -1367,9 +1367,9 @@ func (s *SignalClient) UpdateContact(number string, recipient string, name *stri
var err error
if s.signalCliMode == JsonRpc {
type Request struct {
Recipient string `json:"recipient"`
Name string `json:"name,omitempty"`
Expiration int `json:"expiration,omitempty"`
Recipient string `json:"recipient"`
Name string `json:"name,omitempty"`
Expiration int `json:"expiration,omitempty"`
}
request := Request{Recipient: recipient}
if name != nil {
Expand Down
2 changes: 1 addition & 1 deletion src/client/jsonrpc2.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (r *JsonRpc2Client) ReceiveData(number string) {
str, err := connbuf.ReadString('\n')
if err != nil {
elapsed := time.Since(r.lastTimeErrorMessageSent)
if(elapsed) > time.Duration(5*time.Minute) { //avoid spamming the log file and only log the message at max every 5 minutes
if (elapsed) > time.Duration(5*time.Minute) { //avoid spamming the log file and only log the message at max every 5 minutes
log.Error("Couldn't read data for number ", number, ": ", err.Error(), ". Is the number properly registered?")
r.lastTimeErrorMessageSent = time.Now()
}
Expand Down
7 changes: 3 additions & 4 deletions src/scripts/jsonrpc2-helper.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package main

import (
"encoding/json"
"fmt"
"github.com/bbernhard/signal-cli-rest-api/utils"
"github.com/gabriel-vasile/mimetype"
log "github.com/sirupsen/logrus"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"github.com/gabriel-vasile/mimetype"
"encoding/json"
)

const supervisorctlConfigTemplate = `
Expand Down Expand Up @@ -48,7 +48,6 @@ func isSignalCliLinkedNumberConfigFile(filename string) (bool, error) {
return false, nil
}


func getUsernameFromLinkedNumberConfigFile(filename string) (string, error) {
type LinkedNumberConfigFile struct {
Username string `json:"username"`
Expand Down Expand Up @@ -126,7 +125,7 @@ func main() {

uid := utils.GetEnv("SIGNAL_CLI_UID", "1000")
gid := utils.GetEnv("SIGNAL_CLI_GID", "1000")
_, err = exec.Command("chown", uid + ":" + gid, fifoPathname).Output()
_, err = exec.Command("chown", uid+":"+gid, fifoPathname).Output()
if err != nil {
log.Fatal("Couldn't change permissions of fifo with name ", fifoPathname, ": ", err.Error())
}
Expand Down
12 changes: 6 additions & 6 deletions src/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ func GetIntEnv(key string, defaultVal int) (int, error) {
}

func StringInSlice(a string, list []string) bool {
for _, b := range list {
if b == a {
return true
}
}
return false
for _, b := range list {
if b == a {
return true
}
}
return false
}

func IsPhoneNumber(s string) bool {
Expand Down

0 comments on commit 0b6bd44

Please sign in to comment.