Skip to content

Commit 1cff5d4

Browse files
committed
remove group tracking not working with pgp-contacts
1 parent 186a769 commit 1cff5d4

File tree

4 files changed

+2
-166
lines changed

4 files changed

+2
-166
lines changed

python/examples/group_tracking.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

python/examples/test_examples.py

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import echo_and_quit
2-
import group_tracking
32
import py
43
import pytest
54

6-
from deltachat.events import FFIEventLogger
7-
85

96
@pytest.fixture(scope="session")
107
def datadir():
@@ -37,54 +34,3 @@ def test_echo_quit_plugin(acfactory, lp):
3734
bot_chat.send_text("/quit")
3835
botproc.wait()
3936

40-
41-
def test_group_tracking_plugin(acfactory, lp):
42-
lp.sec("creating one group-tracking bot and two temp accounts")
43-
botproc = acfactory.run_bot_process(group_tracking)
44-
45-
ac1, ac2 = acfactory.get_online_accounts(2)
46-
47-
ac1.add_account_plugin(FFIEventLogger(ac1))
48-
ac2.add_account_plugin(FFIEventLogger(ac2))
49-
50-
lp.sec("creating bot test group with bot")
51-
bot_chat = ac1.qr_setup_contact(botproc.qr)
52-
ac1._evtracker.wait_securejoin_joiner_progress(1000)
53-
bot_contact = bot_chat.get_contacts()[0]
54-
ch = ac1.create_group_chat("bot test group")
55-
ch.add_contact(bot_contact)
56-
ch.send_text("hello")
57-
58-
botproc.fnmatch_lines(
59-
"""
60-
*ac_chat_modified*bot test group*
61-
""",
62-
)
63-
64-
lp.sec("adding third member {}".format(ac2.get_config("addr")))
65-
contact3 = ac1.create_contact(ac2)
66-
ch.add_contact(contact3)
67-
68-
reply = ac1._evtracker.wait_next_incoming_message()
69-
assert "hello" in reply.text
70-
71-
lp.sec("now looking at what the bot received")
72-
botproc.fnmatch_lines(
73-
"""
74-
*ac_member_added {}*from*{}*
75-
""".format(
76-
contact3.addr,
77-
ac1.get_config("addr"),
78-
),
79-
)
80-
81-
lp.sec("contact successfully added, now removing")
82-
ch.remove_contact(contact3)
83-
botproc.fnmatch_lines(
84-
"""
85-
*ac_member_removed {}*from*{}*
86-
""".format(
87-
contact3.addr,
88-
ac1.get_config("addr"),
89-
),
90-
)

python/src/deltachat/events.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from .capi import ffi, lib
1414
from .cutil import from_optional_dc_charpointer
1515
from .hookspec import account_hookimpl
16-
from .message import map_system_message
1716

1817

1918
def get_dc_event_name(integer, _DC_EVENTNAME_MAP={}):
@@ -304,21 +303,15 @@ def _map_ffi_event(self, ffi_event: FFIEvent):
304303
elif name == "DC_EVENT_INCOMING_MSG":
305304
msg = account.get_message_by_id(ffi_event.data2)
306305
if msg is not None:
307-
yield map_system_message(msg) or ("ac_incoming_message", {"message": msg})
306+
yield ("ac_incoming_message", {"message": msg})
308307
elif name == "DC_EVENT_MSGS_CHANGED":
309308
if ffi_event.data2 != 0:
310309
msg = account.get_message_by_id(ffi_event.data2)
311310
if msg is not None:
312311
if msg.is_outgoing():
313-
res = map_system_message(msg)
314-
if res and res[0].startswith("ac_member"):
315-
yield res
316312
yield "ac_outgoing_message", {"message": msg}
317313
elif msg.is_in_fresh():
318-
yield map_system_message(msg) or (
319-
"ac_incoming_message",
320-
{"message": msg},
321-
)
314+
yield "ac_incoming_message", {"message": msg}
322315
elif name == "DC_EVENT_REACTIONS_CHANGED":
323316
assert ffi_event.data1 > 0
324317
msg = account.get_message_by_id(ffi_event.data2)

python/src/deltachat/message.py

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import json
44
import os
5-
import re
65
from datetime import datetime, timezone
76
from typing import Optional, Union
87

@@ -504,56 +503,3 @@ def get_viewtype_code_from_name(view_type_name):
504503
raise ValueError(
505504
f"message typecode not found for {view_type_name!r}, available {list(_view_type_mapping.keys())!r}",
506505
)
507-
508-
509-
#
510-
# some helper code for turning system messages into hook events
511-
#
512-
513-
514-
def map_system_message(msg):
515-
if msg.is_system_message():
516-
res = parse_system_add_remove(msg.text)
517-
if not res:
518-
return None
519-
action, affected, actor = res
520-
affected = msg.account.get_contact_by_addr(affected)
521-
actor = None if actor == "me" else msg.account.get_contact_by_addr(actor)
522-
d = {"chat": msg.chat, "contact": affected, "actor": actor, "message": msg}
523-
return "ac_member_" + res[0], d
524-
525-
526-
def extract_addr(text):
527-
m = re.match(r".*\((.+@.+)\)", text)
528-
if m:
529-
text = m.group(1)
530-
text = text.rstrip(".")
531-
return text.strip()
532-
533-
534-
def parse_system_add_remove(text):
535-
"""return add/remove info from parsing the given system message text.
536-
537-
returns a (action, affected, actor) triple
538-
"""
539-
# You removed member a@b.
540-
# You added member a@b.
541-
# Member Me (x@y) removed by a@b.
542-
# Member x@y added by a@b
543-
# Member With space ([email protected]) removed by [email protected].
544-
# Member With space ([email protected]) removed by Another member ([email protected]).",
545-
# Group left by some one ([email protected]).
546-
# Group left by [email protected].
547-
text = text.lower()
548-
m = re.match(r"member (.+) (removed|added) by (.+)", text)
549-
if m:
550-
affected, action, actor = m.groups()
551-
return action, extract_addr(affected), extract_addr(actor)
552-
m = re.match(r"you (removed|added) member (.+)", text)
553-
if m:
554-
action, affected = m.groups()
555-
return action, extract_addr(affected), "me"
556-
if text.startswith("group left by "):
557-
addr = extract_addr(text[13:])
558-
if addr:
559-
return "removed", addr, addr

0 commit comments

Comments
 (0)