-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recipient store has moved into db - scli no longer starts #202
Comments
I feel like this is a very hacky patch made out of desperation to get back a working desktop version of Signal, but I want to leave it here as a reference point, on how to for example get (some of?) the necessary info from database. Hope it helps! Patchdiff --git a/scli b/scli
index 07811b6..592a220 100755
--- a/scli
+++ b/scli
@@ -18,6 +18,7 @@ import shutil
import signal as signal_ipc
import subprocess
import sys
+import sqlite3
import tempfile
import textwrap
from abc import ABC, abstractmethod
@@ -1073,17 +1074,21 @@ class SignalData:
try:
indivs = self._get_recipients()
except FileNotFoundError:
- indivs = self._get_recipients_v1()
+ try:
+ indivs = self._get_recipients_v1()
+ except KeyError:
+ indivs = self._get_recipients_v2()
groups = []
- for g in get_nested(self._data, 'groupStore', 'groups', default=()):
- if is_group_v2(g):
- group_id = g['groupId']
- cached_name = self._get_group_v2_cache_name(group_id)
- g['name'] = cached_name or group_id[:10] + '[..]'
- if g.get('archived') or not g.get('name'):
- continue
- g['name'] = strip_non_printable_chars(g['name'])
+ account_db_file = os.path.join(self._file_path + '.d', 'account.db')
+ con = sqlite3.connect(account_db_file)
+ cur = con.cursor()
+ for group_id, group_data in cur.execute("select group_id, group_data from group_v2"):
+ g = {
+ "groupId": base64.b64encode(group_id).decode('utf-8'),
+ "group_id": base64.b64encode(group_id).decode('utf-8'),
+ "name": strip_non_printable_chars(str(group_data)[:10] + '[..]'),
+ }
groups.append(g)
return indivs, groups
@@ -1196,6 +1201,34 @@ class SignalData:
profile_names[num] = profile_name
return profile_names
+ def _get_recipients_v2(self):
+ account_db_file = os.path.join(self._file_path + '.d', 'account.db')
+ con = sqlite3.connect(account_db_file)
+ cur = con.cursor()
+ indivs = []
+ for number, given_name, family_name, profile_given_name, profile_family_name in cur.execute("select number, given_name, family_name, profile_given_name, profile_family_name from recipient"):
+ if not number:
+ continue
+
+ name = ''
+ for name_part in (given_name, family_name):
+ if name_part:
+ name += name_part
+
+ profile_name = ''
+ for name_part in (profile_given_name, profile_family_name):
+ if name_part:
+ profile_name += name_part
+
+ cont = {
+ "number": number,
+ "name": strip_non_printable_chars(name) if name else None,
+ "profile_name": strip_non_printable_chars(profile_name) if profile_name else None,
+ }
+
+ indivs.append(cont)
+ return indivs
+
@property
def own_num(self):
return self._data['username']
UPDATE: can be applied using |
I haven't upgraded to signal.cli 0.11 (or signal-cli 0.11.1) yet, but looking at the commit from the OP, it looks like the recipient store migration to the database is not easily revertible (unless you have a |
What about those that have already gotten their socks wet? 🙃 |
I lost some messages because my first attempt at the patch didn't account for groups also being moved (in another commit in signal-cli repo), but after that, the above patch seems to work fine - no guarantees though 😜 Except today signal-cli broke for different reason anyway, returning 499 code... |
I've updated signal-cli to 0.11.2 and made sure it recieves messages and daemon runs, but still scli throws an error on start. How would I go about to apply the patch mentioned in this thread?
|
@zer0lean |
To be fair, I couldn't apply the patch through And after editing it manually, it still didn't solve the issue, but I didn't press any further, I used signal in a different way today. |
Oh I completely forgot, the patch is actually on top of #198 as I rely on that feature daily 🙂 |
@moppman Yes, this I know. What I was asking is how I do this. @maximbaz Please eli5 how I apply this patch the easiest way. Do I run |
Sure!
(At this moment you are in terminal in a folder, where there is
Let me know if this makes sense! |
This makes total sense now. I've never applied a patch like this before but there's a first time for everything.
Big thanks for a quick reply and thorough guide. |
Sure thing! Did it actually work? I have confirmation from one other person that everything seems fine, it would be good to have one more, to reassure people who are otherwise blocked that they can safely use this patch, until the proper cleaner fix is developed. |
I should've been more clear, yes it works! |
I will make a fix for this as soon as I can. Unfortunately, I probably would not be able to attend to this for at least a few days.. |
This problem stems from relying on signal-cli's internal file structure, rather than its external API. If we want to avoid this in the future, we should only interact with signal-cli through its documented calls, and not try to access its internal data (whose format changes often enough). |
I tried the patch as well, but I got this error. |
I have made a fix in the hotfix/202 branch. It should now work with the newer versions of |
Works great for me, thanks! Nice solution with the contacts cache, by the way 😉 |
Another 👍 from me, |
With this Hotfix I get the following error: |
Could it be that your python is older than 3.9? |
You were right, I was still using python3.8 updating the version fixed everything. The Hotfix is working for me now as well. |
Thanks @Lager80 for reporting the error, and thanks @maximbaz for the quick troubleshooting! |
When will you merge it? @exquo People that installed it from AUR can't run scli until merged.
|
The fix has been merged 3 weeks ago 8ccae9f |
Ha you're right, the scli-git AUR package is bonkers :D :O I thought it suppose to take latest git I am confused by pkgbuilds again |
scli used to read some info on startup from recipient store files, but with signal-cli 0.11 the data has been moved to the db, causing the scli to fail to launch.
AsamK/signal-cli@862c2fe
The text was updated successfully, but these errors were encountered: