From d49d174c105cf3a38eb42767dacc6e40a3552915 Mon Sep 17 00:00:00 2001 From: Matthieu Lalonde Date: Wed, 27 Jan 2021 18:45:32 +0000 Subject: [PATCH] Blind and silent truncation on post message --- pkg/altvr/altvr.go | 1 - pkg/altvr/fetch.go | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/altvr/altvr.go b/pkg/altvr/altvr.go index 2950889..8130147 100644 --- a/pkg/altvr/altvr.go +++ b/pkg/altvr/altvr.go @@ -277,6 +277,5 @@ func (avr *AltVR) AcknowkledgeConversation(conversationID string) error { // PostNewConversation send a new message func (avr *AltVR) PostNewConversation(userID, message string) error { - // XXX: Truncate 140 chars return avr.postNewConversation(userID, message) } diff --git a/pkg/altvr/fetch.go b/pkg/altvr/fetch.go index 99b1715..5b209f0 100644 --- a/pkg/altvr/fetch.go +++ b/pkg/altvr/fetch.go @@ -13,6 +13,7 @@ import ( "strconv" "strings" + "git.lalonde.me/matth/AltVRBot/pkg/utils" "github.com/PuerkitoBio/goquery" "golang.org/x/net/html" ) @@ -217,6 +218,7 @@ func (avr *AltVR) fetchPendingConversations() ([]Conversation, error) { func (avr *AltVR) postNewConversation(userID, message string) error { uid, _ := strconv.ParseUint(userID, 10, 64) + message = utils.TruncateString(message, 140) jv, _ := json.Marshal(&ConversationNewMessageOutgoing{ Conversation: ConversationNewMessage{ UserID: uid,