Skip to content

Commit edcd5e8

Browse files
committed
feat: chat settings store (untested)
1 parent 7dfdf9a commit edcd5e8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2709
-2812
lines changed

docs/build.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,19 @@
22
from subprocess import call
33
from pathlib import Path
44
import shlex
5+
56
workdir = Path(__file__).parent.parent
7+
8+
69
def build():
710
env = os.environ
8-
env['SPHINX'] = 'true'
9-
call(shlex.split("poetry run sphinx-apidoc -o docs/source neonize neonize.proto neonize.utils"), env=env)
11+
env["SPHINX"] = "true"
12+
call(
13+
shlex.split(
14+
"poetry run sphinx-apidoc -o docs/source neonize neonize.proto neonize.utils"
15+
),
16+
env=env,
17+
)
1018
call(shlex.split("poetry run make html"), cwd=workdir / "docs")
1119
with open(workdir / "docs/_build/html/.nojekyll", "wb") as file:
12-
file.write(b"")
20+
file.write(b"")

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
project = "neonize"
1313
copyright = "2024, krypton-byte"
1414
author = "krypton-byte"
15-
release = importlib.metadata.version('neonize')
15+
release = importlib.metadata.version("neonize")
1616

1717
# -- General configuration ---------------------------------------------------
1818
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

goneonize/Neonize.proto

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,4 +850,20 @@ message UpdateGroupParticipantsReturnFunction {
850850
message GetMessageForRetryReturnFunction{
851851
optional bool isEmpty = 1 [default=false];
852852
optional WAWebProtobufsE2E.Message Message = 2;
853+
}
854+
855+
//chat_setting_store
856+
message LocalChatSettings {
857+
required bool Found = 1;
858+
required double MutedUntil = 2;
859+
required bool Pinned = 3;
860+
required bool Archived = 4;
861+
}
862+
// New Verision for Function
863+
message ReturnFunctionWithError {
864+
optional string Error = 1;
865+
oneof Return {
866+
LocalChatSettings LocalChatSettings = 2;
867+
}
868+
853869
}

goneonize/build.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# "protoc --go_out=. --go-grpc_out=. -I . Neonize.proto def.proto",
1717
# ]
1818
shell = [
19-
"echo *.proto",
2019
"protoc --go_out=. --go_opt=paths=source_relative Neonize.proto",
2120
"protoc --python_out=../../neonize/proto --mypy_out=../../neonize/proto Neonize.proto",
2221
*[
@@ -73,6 +72,9 @@ def __build():
7372

7473

7574
def build_proto():
75+
with open(cwd + "/Neonize.proto", "rb") as file:
76+
with open(cwd + "/defproto/Neonize.proto", "wb") as wf:
77+
wf.write(file.read())
7678
for sh in shell:
7779
subprocess.call(shlex.split(sh), cwd=cwd + "/defproto")
7880
# if (Path(cwd) / "defproto").exists():

goneonize/chat_settings_store.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package main
2+
3+
/*
4+
5+
#include <stdlib.h>
6+
#include <stdbool.h>
7+
#include <stdint.h>
8+
*/
9+
10+
import (
11+
"C"
12+
13+
"github.com/krypton-byte/neonize/defproto"
14+
"github.com/krypton-byte/neonize/utils"
15+
)
16+
import (
17+
"time"
18+
19+
"google.golang.org/protobuf/proto"
20+
)
21+
22+
//export PutMutedUntil
23+
func PutMutedUntil(id *C.char, user *C.uchar, userSize C.int, mutedUntil C.float) *C.char {
24+
var JID defproto.JID
25+
proto.Unmarshal(getByteByAddr(user, userSize), &JID)
26+
err := clients[C.GoString(id)].Store.ChatSettings.PutMutedUntil(utils.DecodeJidProto(&JID), time.Unix(int64(mutedUntil), 0))
27+
if err != nil {
28+
return C.CString(err.Error())
29+
}
30+
return C.CString("")
31+
}
32+
33+
//export GetChatSettings
34+
func GetChatSettings(id *C.char, user *C.uchar, userSize C.int) C.struct_BytesReturn {
35+
var JID defproto.JID
36+
proto.Unmarshal(getByteByAddr(user, userSize), &JID)
37+
local_chat_settings, err := clients[C.GoString(id)].Store.ChatSettings.GetChatSettings(utils.DecodeJidProto(&JID))
38+
return_ := defproto.ReturnFunctionWithError{}
39+
if err != nil {
40+
return_.Error = proto.String(err.Error())
41+
}
42+
return_.Return = &defproto.ReturnFunctionWithError_LocalChatSettings{
43+
LocalChatSettings: &defproto.LocalChatSettings{
44+
Found: proto.Bool(local_chat_settings.Found),
45+
MutedUntil: proto.Float64(float64(local_chat_settings.MutedUntil.Unix())),
46+
Pinned: proto.Bool(local_chat_settings.Pinned),
47+
Archived: proto.Bool(local_chat_settings.Pinned),
48+
},
49+
}
50+
return_bytes, err_proto := proto.Marshal(&return_)
51+
if err_proto != nil {
52+
panic(err_proto)
53+
}
54+
return ReturnBytes(return_bytes)
55+
}

0 commit comments

Comments
 (0)