whatsmeow icon indicating copy to clipboard operation
whatsmeow copied to clipboard

Implement writing app state

Open 1337-sys opened this issue 3 years ago • 6 comments

If we write one of these functions, we write the rest. App state write so important.

1337-sys avatar Dec 26 '21 00:12 1337-sys

I'm offering you $500. I really need appstates.

1337-sys avatar Jan 25 '22 20:01 1337-sys

Ping, ping...

1337-sys avatar Apr 01 '22 16:04 1337-sys

I beg you, can we at least do chat pinning? Only Pin, only..

1337-sys avatar May 12 '22 08:05 1337-sys

https://github.com/tulir/whatsmeow/commit/a168fde5a9dee4d950ca1dd26b5093a80eea2399

Really? 👯‍♀️ I'm so excited..

1337-sys avatar May 16 '22 20:05 1337-sys

@tulir Baileys already implement app state, Do you have any plan to add it?

Ased2235 avatar Aug 07 '22 09:08 Ased2235

I already started working on it myself but there's few things i don't understand. For example how do i get App State Sync Key? Here's the mute function i'm working on

func (cli *Client) Mute(jid types.JID) error {

	version, hash, err := cli.Store.AppState.GetAppStateVersion("regular_high")
	if err != nil {
		return fmt.Errorf("failed to get app state %s version: %w", "regular_high", err)
	}

	state := appstate.HashState{Version: version, Hash: hash}

	type Patch struct {
		SyncAction SyncAction `json:"syncAction"`
		Index      []string   `json:"index"`
		Type       string     `json:"type"`
		APIVersion int64      `json:"apiVersion"`
		Operation  int64      `json:"operation"`
	}

	type SyncAction struct {
		MuteAction MuteAction `json:"muteAction"`
		Timestamp  int64      `json:"timestamp"`
	}

	type MuteAction struct {
		Muted            bool  `json:"muted"`
		MuteEndTimestamp int64 `json:"muteEndTimestamp"`
	}

	index := []string{"mute", jid.String()}

	patch := Patch{
		SyncAction: SyncAction{
			MuteAction: MuteAction{
				Muted: true,
			},
			Timestamp: int64(time.Now().UnixNano()),
		},
		Type:       "regular_high",
		APIVersion: state.Version,
		Operation:  0,
	}

	patchbytes, _ := json.Marshal(patch)

	mu := cli.Store.AppState.EncodeMutations()/// Missing func

	statusNode, err := cli.sendIQ(infoQuery{
		Namespace: "w:sync:app:state",
		Type:      "set",
		To:        types.ServerJID,
		ID:        cli.generateRequestID(),
		Content: []waBinary.Node{{
			Tag: "sync",
			Content: []waBinary.Node{{
				Tag: "collection",
				Attrs: waBinary.Attrs{
					"name":            "regular_high",
					"version":         state.Version,
					"return_snapshot": "false",
				},
				Content: []waBinary.Node{{
					Tag:     "patch",
					Content: mu,
				}},
			}},
		}},
	})
	log.Printf("Mute:-\n%v\nerr:- %v", Typetojson(statusNode), err)
	if err != nil {
		return err
	}
	_, ok := statusNode.GetOptionalChildByTag("error")
	if ok {
		return parseIQError(statusNode)
	}
	return nil
}

Ased2235 avatar Aug 07 '22 09:08 Ased2235

Any update on this?

ffauzan avatar Dec 24 '22 11:12 ffauzan

@tulir Any update? Only pin..

1337-sys avatar Jan 04 '23 19:01 1337-sys

@tulir Any update? Only pin..

what will you do with chat pin?

salman0ansari avatar Jan 05 '23 08:01 salman0ansari

Let's do chat pin in honor of the 1st year @tulir

At least show me the way. Let's do it ourselves. We need it more than ever. Not just for me. Thousands of developer are waiting for this writing to app state.

Please...

To do what it takes? Time? Money? Let's raise funds your between us.

We love you and we are so grateful @tulir. If you won't tell us, let's not wait or develop programs in this library any more.

Thanks

  • One of the dozens of developer who love you

1337-sys avatar Jan 26 '23 09:01 1337-sys

I'm offering you $500. I really need appstates.

@1337-sys If it's a real bounty, I suggest you join the repo's official Matrix room and offer it up there.

@Ased2235 I suggest you do the same. The WhatsMeow community's more vocal on the Matrix than on Github.

codespearhead avatar Jan 28 '23 22:01 codespearhead

@Paguiar735 Those in this group already know the criticality of the situation. I tried to github sponsor a lot, but Github does not accept any card. I want a swift code from him. This is not a bribe. I give this not in exchange for a feature, but of all sincerity.

SS

1337-sys avatar Jan 29 '23 13:01 1337-sys

I wish I could see such a commit when I wake up morning.

https://github.com/Auties00/WhatsappWeb4j/commit/5a4a8ae389cff88921fd00c3f901eba16c121a1b (App state writes now work!)

1337-sys avatar Feb 19 '23 19:02 1337-sys

dude stop spamming if you really need state that bad why not just use other libs ??

ahmedRSA avatar Feb 20 '23 10:02 ahmedRSA

You even have the other libs to look at. If Tulir won't do it, you can work on it on your own and do a pull request 😅

burstfreeze avatar Feb 20 '23 11:02 burstfreeze