Skip to content

Commit 0b6bd44

Browse files
author
Bernhard B
committed
ran go-fmt on complete sourcecode
1 parent d34fcb9 commit 0b6bd44

File tree

5 files changed

+30
-32
lines changed

5 files changed

+30
-32
lines changed

src/api/api.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package api
33
import (
44
"bytes"
55
"encoding/json"
6+
"errors"
67
"net/http"
78
"strconv"
89
"time"
9-
"errors"
1010

1111
"github.com/gabriel-vasile/mimetype"
1212
"github.com/gin-gonic/gin"
@@ -29,9 +29,9 @@ const (
2929
)
3030

3131
type UpdateContactRequest struct {
32-
Recipient string `json:"recipient"`
33-
Name *string `json:"name"`
34-
ExpirationInSeconds *int `json:"expiration_in_seconds"`
32+
Recipient string `json:"recipient"`
33+
Name *string `json:"name"`
34+
ExpirationInSeconds *int `json:"expiration_in_seconds"`
3535
}
3636

3737
type GroupPermissions struct {
@@ -48,11 +48,11 @@ type CreateGroupRequest struct {
4848
}
4949

5050
type ChangeGroupMembersRequest struct {
51-
Members []string `json:"members"`
51+
Members []string `json:"members"`
5252
}
5353

5454
type ChangeGroupAdminsRequest struct {
55-
Admins []string `json:"admins"`
55+
Admins []string `json:"admins"`
5656
}
5757

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

361361
for {
362362
select {
363-
case <-stop:
363+
case <-stop:
364364
ws.Close()
365365
return
366366
case msg := <-receiveChannel:
@@ -1351,7 +1351,6 @@ func (a *Api) SearchForNumbers(c *gin.Context) {
13511351
c.JSON(200, searchResponse)
13521352
}
13531353

1354-
13551354
// @Summary Updates the info associated to a number on the contact list. If the contact doesn’t exist yet, it will be added.
13561355
// @Tags Contacts
13571356
// @Description Updates the info associated to a number on the contact list.

src/client/client.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ type About struct {
123123
}
124124

125125
type SearchResultEntry struct {
126-
Number string `json:"number"`
127-
Registered bool `json:"registered"`
126+
Number string `json:"number"`
127+
Registered bool `json:"registered"`
128128
}
129129

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

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

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

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

710710
if s.signalCliMode == JsonRpc {
711711
type Request struct {
712-
Name string `json:"name,omitempty"`
713-
Members []string `json:"member,omitempty"`
712+
Name string `json:"name,omitempty"`
713+
Members []string `json:"member,omitempty"`
714714
RemoveMembers []string `json:"remove-member,omitempty"`
715-
GroupId string `json:"groupId"`
715+
GroupId string `json:"groupId"`
716716
}
717717
request := Request{GroupId: internalGroupId}
718718
if add {
@@ -772,10 +772,10 @@ func (s *SignalClient) updateGroupAdmins(number string, groupId string, admins [
772772

773773
if s.signalCliMode == JsonRpc {
774774
type Request struct {
775-
Name string `json:"name,omitempty"`
776-
Admins []string `json:"admin,omitempty"`
775+
Name string `json:"name,omitempty"`
776+
Admins []string `json:"admin,omitempty"`
777777
RemoveAdmins []string `json:"remove-admin,omitempty"`
778-
GroupId string `json:"groupId"`
778+
GroupId string `json:"groupId"`
779779
}
780780
request := Request{GroupId: internalGroupId}
781781
if add {
@@ -1367,9 +1367,9 @@ func (s *SignalClient) UpdateContact(number string, recipient string, name *stri
13671367
var err error
13681368
if s.signalCliMode == JsonRpc {
13691369
type Request struct {
1370-
Recipient string `json:"recipient"`
1371-
Name string `json:"name,omitempty"`
1372-
Expiration int `json:"expiration,omitempty"`
1370+
Recipient string `json:"recipient"`
1371+
Name string `json:"name,omitempty"`
1372+
Expiration int `json:"expiration,omitempty"`
13731373
}
13741374
request := Request{Recipient: recipient}
13751375
if name != nil {

src/client/jsonrpc2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (r *JsonRpc2Client) ReceiveData(number string) {
101101
str, err := connbuf.ReadString('\n')
102102
if err != nil {
103103
elapsed := time.Since(r.lastTimeErrorMessageSent)
104-
if(elapsed) > time.Duration(5*time.Minute) { //avoid spamming the log file and only log the message at max every 5 minutes
104+
if (elapsed) > time.Duration(5*time.Minute) { //avoid spamming the log file and only log the message at max every 5 minutes
105105
log.Error("Couldn't read data for number ", number, ": ", err.Error(), ". Is the number properly registered?")
106106
r.lastTimeErrorMessageSent = time.Now()
107107
}

src/scripts/jsonrpc2-helper.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package main
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"github.com/bbernhard/signal-cli-rest-api/utils"
7+
"github.com/gabriel-vasile/mimetype"
68
log "github.com/sirupsen/logrus"
79
"io/ioutil"
810
"os"
911
"os/exec"
1012
"path/filepath"
1113
"strconv"
1214
"strings"
13-
"github.com/gabriel-vasile/mimetype"
14-
"encoding/json"
1515
)
1616

1717
const supervisorctlConfigTemplate = `
@@ -48,7 +48,6 @@ func isSignalCliLinkedNumberConfigFile(filename string) (bool, error) {
4848
return false, nil
4949
}
5050

51-
5251
func getUsernameFromLinkedNumberConfigFile(filename string) (string, error) {
5352
type LinkedNumberConfigFile struct {
5453
Username string `json:"username"`
@@ -126,7 +125,7 @@ func main() {
126125

127126
uid := utils.GetEnv("SIGNAL_CLI_UID", "1000")
128127
gid := utils.GetEnv("SIGNAL_CLI_GID", "1000")
129-
_, err = exec.Command("chown", uid + ":" + gid, fifoPathname).Output()
128+
_, err = exec.Command("chown", uid+":"+gid, fifoPathname).Output()
130129
if err != nil {
131130
log.Fatal("Couldn't change permissions of fifo with name ", fifoPathname, ": ", err.Error())
132131
}

src/utils/utils.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ func GetIntEnv(key string, defaultVal int) (int, error) {
2424
}
2525

2626
func StringInSlice(a string, list []string) bool {
27-
for _, b := range list {
28-
if b == a {
29-
return true
30-
}
31-
}
32-
return false
27+
for _, b := range list {
28+
if b == a {
29+
return true
30+
}
31+
}
32+
return false
3333
}
3434

3535
func IsPhoneNumber(s string) bool {

0 commit comments

Comments
 (0)