Skip to content

Commit 42bf4a2

Browse files
committed
create post url once
1 parent 543883e commit 42bf4a2

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

docs/faq.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ See more info at https://github.com/tinode/tindroid/#push_notifications
6464
See more info at https://github.com/tinode/ios/#push_notifications
6565

6666

67-
### Q: How can new users be added to Tinode?<br/>
67+
### Q: How to add new users?<br/>
6868
**A**: There are three ways to create accounts:
6969
* A user can create a new account using one of the applications (web, Android, iOS).
70-
* A new account can be created using [tn-cli](../tn-cli/) (`acc` command). The process can be scripted.
70+
* A new account can be created using [tn-cli](../tn-cli/) (`acc` command or `useradd` macro). The process can be scripted.
7171
* If the user already exists in an external database, the Tinode account can be automatically created on the first login using the [rest authenticator](../server/auth/rest/).
7272

7373

server/push/tnpg/push_tnpg.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ const (
2222
var handler Handler
2323

2424
type Handler struct {
25-
input chan *push.Receipt
26-
stop chan bool
25+
input chan *push.Receipt
26+
stop chan bool
27+
postUrl string
2728
}
2829

2930
type configType struct {
@@ -47,6 +48,7 @@ func (Handler) Init(jsonconf string) error {
4748
return errors.New("push.tnpg.org not specified.")
4849
}
4950

51+
handler.postUrl = baseTargetAddress + config.OrgName
5052
handler.input = make(chan *push.Receipt, bufferSize)
5153
handler.stop = make(chan bool, 1)
5254

@@ -69,8 +71,8 @@ func postMessage(body interface{}, config *configType) (int, string, error) {
6971
gz := gzip.NewWriter(buf)
7072
json.NewEncoder(gz).Encode(body)
7173
gz.Close()
72-
targetAddress := baseTargetAddress + config.OrgName
73-
req, err := http.NewRequest("POST", targetAddress, buf)
74+
75+
req, err := http.NewRequest("POST", handler.postUrl, buf)
7476
if err != nil {
7577
return -1, "", err
7678
}

0 commit comments

Comments
 (0)