Skip to content

Commit

Permalink
send the app + initial status update in a single message
Browse files Browse the repository at this point in the history
  • Loading branch information
adbenitez committed Feb 3, 2024
1 parent 74490ca commit ba00b7c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To generate the frontend (WebXDC app) that is shipped/embedded inside the bot:
go generate ./...
```

For development instructions of the frontend check [frontend/README.md](https://github.com/deltachat-bot/public-bots/blob/master/frontend/README.md)
For development instructions of the frontend check [frontend/README.md](./frontend/README.md)

### Automated testing

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ Run `public-bots --help` to see all available options.

## Contributing

Pull requests are welcome! check [CONTRIBUTING.md](https://github.com/deltachat-bot/public-bots/blob/master/CONTRIBUTING.md)
Pull requests are welcome! check [CONTRIBUTING.md](./CONTRIBUTING.md)
2 changes: 1 addition & 1 deletion frontend/public/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.4.2
2.5.0
6 changes: 1 addition & 5 deletions frontend/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function isOnline(lastSync: Date, lastSeen?: Date): boolean {
const api = (() => {
return {
sync: () => {
const lastSyncReq = localStorage.getItem(lastSyncReqKey) || "";
const lastSyncReq = localStorage.getItem(lastSyncReqKey) || localStorage.getItem(lastSyncKey) || "";
const hash = localStorage.getItem(hashKey) || null;
if (
lastSyncReq &&
Expand Down Expand Up @@ -116,10 +116,6 @@ export const useStore = create<State>()((set) => ({
}));

export async function init() {
// The first time the bot sends the state so no need to request
if (!localStorage.getItem(lastSyncReqKey)) {
localStorage.setItem(lastSyncReqKey, new Date().toString());
}
const hash = localStorage.getItem(hashKey);
if (hash) {
const lastSync = new Date(localStorage.getItem(lastSyncKey) || "");
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ go 1.21

require (
github.com/deltachat-bot/deltabot-cli-go v0.5.0
github.com/deltachat/deltachat-rpc-client-go v1.127.0
github.com/deltachat/deltachat-rpc-client-go v1.127.1-0.20240203211634-c7ed4b2cd4c4
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.8.2
)

require (
github.com/creachadair/jrpc2 v1.0.0 // indirect
github.com/creachadair/mds v0.0.1 // indirect
github.com/creachadair/jrpc2 v1.1.2 // indirect
github.com/creachadair/mds v0.8.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/mdp/qrterminal/v3 v3.0.0 // indirect
Expand All @@ -20,7 +20,7 @@ require (
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sync v0.6.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
rsc.io/qr v0.2.0 // indirect
)
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creachadair/jrpc2 v1.0.0 h1:MJecUFNbda24o0Qa4CYru5NJvs6BEnmzupdAx3f7+98=
github.com/creachadair/jrpc2 v1.0.0/go.mod h1:VNiDz7Qbua37RrefUJdMki9dVmsbrQPIQOPy907UvtE=
github.com/creachadair/mds v0.0.1 h1:2nX6Sww4dXpScx3b6aYjH1n7iuEH715+jj+cKkKw9BY=
github.com/creachadair/mds v0.0.1/go.mod h1:caBACU+n1Q/rZ252FTzfnG0/H+ZUi+UnIQtEOraMv/g=
github.com/creachadair/jrpc2 v1.1.2 h1:UOYMipEFYlwd5qmcvs9GZBurn3oXt1UDIX5JLjWWFzo=
github.com/creachadair/jrpc2 v1.1.2/go.mod h1:JcCe2Eny3lIvVwZLm92WXyU+tNUgTBWFCLMsfNkjEGk=
github.com/creachadair/mds v0.8.2 h1:+Jvq8XBrREerXI/QZpNAeiLjIBuVMOl8p3v+mKgSexY=
github.com/creachadair/mds v0.8.2/go.mod h1:4vrFYUzTXMJpMBU+OA292I6IUxKWCCfZkgXg+/kBZMo=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deltachat-bot/deltabot-cli-go v0.5.0 h1:WHHbG5++bO65risHzBj2jo0AOpBhJjVTKt6XH7d1KYo=
github.com/deltachat-bot/deltabot-cli-go v0.5.0/go.mod h1:Lj4cmrHgOk0LKUOei5RAjx94VLTs11CfPhIqOBT+g8c=
github.com/deltachat/deltachat-rpc-client-go v1.127.0 h1:fl0GAarlZsZBI3azYsBjGPV5kqZ9jxCVETyy2ONsCKI=
github.com/deltachat/deltachat-rpc-client-go v1.127.0/go.mod h1:BAmhQofUS1dJltema3k1ACBMqw7lZCpm399P4ZX4IhY=
github.com/deltachat/deltachat-rpc-client-go v1.127.1-0.20240203211634-c7ed4b2cd4c4 h1:XLOZK7ktfVlZbkAVW6yJvRA48ytmZFkxWKsmbYrbT/I=
github.com/deltachat/deltachat-rpc-client-go v1.127.1-0.20240203211634-c7ed4b2cd4c4/go.mod h1:Ctd0M0o87y2B0QSOn8QN6IMDWjHD7XzDKsjNMYwP208=
github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw=
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
Expand Down Expand Up @@ -47,8 +47,8 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
12 changes: 11 additions & 1 deletion src/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,15 @@ func sendApp(rpc *deltachat.Rpc, accId deltachat.AccountId, chatId deltachat.Cha
return
}

msgId, err := rpc.SendMsg(accId, chatId, deltachat.MsgData{File: xdcPath})
err = rpc.MiscSetDraft(accId, chatId, option.None[string](), option.Some(xdcPath), option.None[deltachat.MsgId](), option.None[deltachat.MsgType]())
if err != nil {
logger.Error(err)
}
draft, err := rpc.GetDraft(accId, chatId)
if err != nil {
logger.Error(err)
}
msgId := draft.Unwrap().Id

if cfg.BotsData.Hash != "" {
syncTime, botsData, statusData, _ := (&API{}).Sync("")
Expand All @@ -181,4 +186,9 @@ func sendApp(rpc *deltachat.Rpc, accId deltachat.AccountId, chatId deltachat.Cha
logger.Error(err)
}
}

_, err = rpc.MiscSendDraft(accId, chatId)
if err != nil {
logger.Error(err)
}
}

0 comments on commit ba00b7c

Please sign in to comment.