Skip to content

Commit

Permalink
Release v1.15.0
Browse files Browse the repository at this point in the history
* Update: Depends on whatsmeow v0.0.0-20240521160649-74c49f5a7d31 or later.
* Update: Requires Go 1.21 due to changes in whatsmeow.
* Feature: Fetching the conversation history is no longer an option.
* Feature: Display incoming message edits.
  • Loading branch information
hoehermann committed May 24, 2024
1 parent 7c333e7 commit d405466
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 130 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ jobs:
needs: build

steps:
- name: Release
uses: ncipollo/release-action@v1
- uses: actions/checkout@v4 # so CHANGELOG.md is available

- uses: ncipollo/release-action@v1
with:
artifacts: libwhatsmeow.dll
bodyFile: CHANGELOG.md
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 1.15.0

* Update: Depends on whatsmeow v0.0.0-20240521160649-74c49f5a7d31 or later.
* Update: Requires Go 1.21 due to changes in whatsmeow.
* Feature: Fetching the conversation history is no longer an option.
* Feature: Display incoming message edits.

# 1.14.0

* Update: Requires Go 1.20.
Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Dependencies:
* pkg-config
* cmake (3.8 or newer)
* make
* go (1.20 or newer)
* go (1.21 or newer)
* gcc (9.2.0 or newer)
* libgdk-pixbuf-2.0 (optional)
* libopusfile (optional)
Expand Down Expand Up @@ -133,7 +133,7 @@ CMake will try to set-up a development environment automatically.

Additional dependencies:

* [go 1.20 or newer (32 bit)](https://go.dev/dl/go1.20.13.windows-386.msi)
* [go 1.21 or newer (32 bit)](https://go.dev/dl/go1.22.3.windows-386.msi)
* [gcc 13.2 (32 bit)](https://packages.msys2.org/package/mingw-w64-i686-gcc)

This is known to work with MSYS make and CMake generator "MSYS Makefiles". go and gcc must be in `%PATH%`.
Expand Down Expand Up @@ -184,9 +184,6 @@ For sending opus in ogg audio files as voice messages, add a static win32 build
* `message-cache-size`
Stores a number (default: 100) of messages in local volatile memory. Cached messages are used to provide context when displaying reactions.

* `fetch-history`
If set to true (default: false), the history of conversations will be displayed. This feature is experimental. WhatsApp servers send the history once during the linking process. Messages will appear out-of-order. Files will be downloaded again. If used when linking for the first time (without prior population of the buddy list), it may add name-less contacts to the buddy list.

* `discard-old-messages`
If set to true (default: false), messages older than the connection will be discarded.
Note: This is implemented without time-zone information. This might not work as expected when chatting with someone in a different time-zone.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.14.0
1.15.0
7 changes: 0 additions & 7 deletions src/c/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,6 @@ gowhatsapp_add_account_options(GList *account_options)
FALSE
);
account_options = g_list_append(account_options, option);

option = purple_account_option_bool_new( // MEMCHECK: account_options takes ownership
"Fetch conversation history (experimental)",
GOWHATSAPP_FETCH_HISTORY_OPTION,
FALSE
);
account_options = g_list_append(account_options, option);

option = purple_account_option_bool_new( // MEMCHECK: account_options takes ownership
"Automatically join all chats",
Expand Down
1 change: 0 additions & 1 deletion src/go/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ set(GO_SRCS
profile.go
send_file_checks.go
message_cache.go
conversations.go
groups.go
)
set(OUTPUT_PREFIX purple-go-whatsapp)
Expand Down
49 changes: 0 additions & 49 deletions src/go/conversations.go

This file was deleted.

12 changes: 5 additions & 7 deletions src/go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ module github.com/hoehermann/purple-gowhatsapp/src/go

go 1.21

toolchain go1.22.3

require (
github.com/alfg/mp4 v0.0.0-20210728035756-55ea58c08aeb
github.com/lib/pq v1.10.4
github.com/mattn/go-sqlite3 v1.14.22
github.com/mdp/qrterminal/v3 v3.0.0
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
go.mau.fi/whatsmeow v0.0.0-20240507080416-01b0547014dc
golang.org/x/net v0.21.0
go.mau.fi/whatsmeow v0.0.0-20240523075404-7f13c31d2cb1
golang.org/x/net v0.25.0
google.golang.org/protobuf v1.33.0
)

Expand All @@ -24,8 +22,8 @@ require (
github.com/rs/zerolog v1.32.0 // indirect
go.mau.fi/libsignal v0.1.0 // indirect
go.mau.fi/util v0.4.1 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
rsc.io/qr v0.2.0 // indirect
)
2 changes: 1 addition & 1 deletion src/go/go.mod.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/hoehermann/purple-gowhatsapp/src/go

go 1.20
go 1.21

require (
github.com/alfg/mp4 v0.0.0-20210728035756-55ea58c08aeb
Expand Down
20 changes: 10 additions & 10 deletions src/go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@ go.mau.fi/libsignal v0.1.0 h1:vAKI/nJ5tMhdzke4cTK1fb0idJzz1JuEIpmjprueC+c=
go.mau.fi/libsignal v0.1.0/go.mod h1:R8ovrTezxtUNzCQE5PH30StOQWWeBskBsWE55vMfY9I=
go.mau.fi/util v0.4.1 h1:3EC9KxIXo5+h869zDGf5OOZklRd/FjeVnimTwtm3owg=
go.mau.fi/util v0.4.1/go.mod h1:GjkTEBsehYZbSh2LlE6cWEn+6ZIZTGrTMM/5DMNlmFY=
go.mau.fi/whatsmeow v0.0.0-20240507080416-01b0547014dc h1:lcx1lVelwGYnRAFNlYmz2T6mjghUYV4zhFbUOX4D1tQ=
go.mau.fi/whatsmeow v0.0.0-20240507080416-01b0547014dc/go.mod h1:kNI5foyzqd77d5HaWc1Jico6/rxtZ/UE8nr80hIsbIk=
golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA=
golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
go.mau.fi/whatsmeow v0.0.0-20240523075404-7f13c31d2cb1 h1:mUEEmZs1xk5QHKXjDxiAP4bYgyj8r7PaZCafHN+KMQg=
go.mau.fi/whatsmeow v0.0.0-20240523075404-7f13c31d2cb1/go.mod h1:0+65CYaE6r4dWzr0dN8i+UZKy0gIfJ79VuSqIl0nKRM=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
Expand Down
36 changes: 24 additions & 12 deletions src/go/handle_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import (
"encoding/hex"
"errors"
"fmt"
waProto "go.mau.fi/whatsmeow/binary/proto"
"go.mau.fi/whatsmeow/types"
"golang.org/x/net/http2"
"mime"
"strings"
"time"

waProto "go.mau.fi/whatsmeow/binary/proto"
"go.mau.fi/whatsmeow/types"
"golang.org/x/net/http2"
)

func (handler *Handler) handle_message(message *waProto.Message, id string, source types.MessageSource, name *string, timestamp time.Time, is_historical bool) {
Expand All @@ -26,7 +27,17 @@ func (handler *Handler) handle_message(message *waProto.Message, id string, sour
// or other undesired behaviour such as just being annoying
return
}
text := message.GetConversation()

text := ""

if pm := message.GetProtocolMessage(); pm != nil {
if em := pm.GetEditedMessage(); em != nil {
message = em
text = "[EDIT] "
}
}

text += message.GetConversation()

etm := message.ExtendedTextMessage
if etm != nil {
Expand Down Expand Up @@ -57,18 +68,18 @@ func (handler *Handler) handle_message(message *waProto.Message, id string, sour
}

rm := message.GetReactionMessage()
if rm != nil && rm.Text != nil && rm.Key != nil && rm.Key.Id != nil {
if rm != nil && rm.Text != nil && rm.Key != nil && rm.Key.ID != nil {
quote := ""
for i := range handler.cachedMessages {
if handler.cachedMessages[i].id == *rm.Key.Id {
if handler.cachedMessages[i].id == rm.Key.GetID() {
message := &handler.cachedMessages[i]
quote = fmt.Sprintf("message \"%.50s\" from %s", message.text, message.timestamp.Format(time.RFC822))
// TODO: truncate string when storing, not when displaying
break
}
}
if quote == "" {
quote = fmt.Sprintf("unknown message with ID %s", *rm.Key.Id)
quote = fmt.Sprintf("unknown message with ID %s", rm.Key.GetID())
}
if *rm.Text == "" {
text += fmt.Sprintf("removed their reaction to %s.", quote)
Expand Down Expand Up @@ -123,20 +134,20 @@ func (handler *Handler) handle_attachment(message *waProto.Message, source types
im := message.GetImageMessage()
if im != nil {
data, err = handler.client.Download(im)
filename = hex.EncodeToString(im.FileSha256) + extension_from_mimetype(im.Mimetype)
filename = hex.EncodeToString(im.GetFileSHA256()) + extension_from_mimetype(im.Mimetype)
data_type = C.gowhatsapp_attachment_type_image
mimetype = im.Mimetype
}
vm := message.GetVideoMessage()
if vm != nil {
data, err = handler.client.Download(vm)
filename = hex.EncodeToString(vm.FileSha256) + extension_from_mimetype(vm.Mimetype)
filename = hex.EncodeToString(vm.GetFileSHA256()) + extension_from_mimetype(vm.Mimetype)
data_type = C.gowhatsapp_attachment_type_video
}
am := message.GetAudioMessage()
if am != nil {
data, err = handler.client.Download(am)
filename = hex.EncodeToString(am.FileSha256) + extension_from_mimetype(am.Mimetype)
filename = hex.EncodeToString(am.GetFileSHA256()) + extension_from_mimetype(am.Mimetype)
data_type = C.gowhatsapp_attachment_type_audio
}
dm := message.GetDocumentMessage()
Expand All @@ -149,16 +160,17 @@ func (handler *Handler) handle_attachment(message *waProto.Message, source types
sm := message.GetStickerMessage()
if sm != nil {
data, err = handler.client.Download(sm)
filename = hex.EncodeToString(sm.FileSha256) + extension_from_mimetype(sm.Mimetype)
filename = hex.EncodeToString(sm.GetFileSHA256()) + extension_from_mimetype(sm.Mimetype)
data_type = C.gowhatsapp_attachment_type_sticker
mimetype = sm.Mimetype
}
if err != nil {
if data == nil || len(data) == 0 {
if len(data) == 0 {
errmsg := fmt.Sprintf("Message contained an attachment, but the download failed: %v", err)
var h2se *http2.StreamError
if errors.As(err, &h2se) {
err = h2se.Cause
errmsg = fmt.Sprintf("%s %v", errmsg, err)
}
purple_display_system_message(handler.account, chat, source.IsGroup, errmsg)
return
Expand Down
17 changes: 8 additions & 9 deletions src/go/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import "C"

import (
"fmt"
"net/http"
"time"

"go.mau.fi/whatsmeow"
"go.mau.fi/whatsmeow/appstate"
"go.mau.fi/whatsmeow/store/sqlstore"
"go.mau.fi/whatsmeow/types"
"go.mau.fi/whatsmeow/types/events"
waLog "go.mau.fi/whatsmeow/util/log"
"net/http"
"time"
)

type CachedMessage struct {
Expand Down Expand Up @@ -91,9 +92,9 @@ func (handler *Handler) eventHandler(rawEvt interface{}) {
case *events.Message:
handler.handle_message(evt.Message, evt.Info.ID, evt.Info.MessageSource, &evt.Info.PushName, evt.Info.Timestamp, false)
case *events.Receipt:
if evt.Type == events.ReceiptTypeRead || evt.Type == events.ReceiptTypeReadSelf {
if evt.Type == types.ReceiptTypeRead || evt.Type == types.ReceiptTypeReadSelf {
log.Infof("%v was read by %s at %s", evt.MessageIDs, evt.SourceString(), evt.Timestamp)
} else if evt.Type == events.ReceiptTypeDelivered {
} else if evt.Type == types.ReceiptTypeDelivered {
log.Infof("%s was delivered to %s at %s", evt.MessageIDs[0], evt.SourceString(), evt.Timestamp)
}
case *events.Presence:
Expand All @@ -102,13 +103,11 @@ func (handler *Handler) eventHandler(rawEvt interface{}) {
// this happens after initial logon via QR code (after AppStateSyncComplete)
pushnames := evt.Data.GetPushnames()
for _, p := range pushnames {
if p.Id != nil && p.Pushname != nil {
purple_update_name(handler.account, *p.Id, *p.Pushname)
if p.ID != nil && p.Pushname != nil {
purple_update_name(handler.account, *p.ID, *p.Pushname)
}
}
if purple_get_bool(handler.account, C.GOWHATSAPP_FETCH_HISTORY_OPTION, false) {
handler.handle_historical_conversations(evt.Data.GetConversations())
}
// TODO: handle historical conversations obtained by evt.Data.GetConversations() utilising client.ParseWebMessage
case *events.ChatPresence:
handler.handle_chat_presence(evt)
case *events.AppState:
Expand Down
Loading

0 comments on commit d405466

Please sign in to comment.