mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-11-02 10:51:57 +00:00
fix(companion): hashtag join trims like the app, prefs survive a downgrade, a sender named Me
- Joining #topic drops surrounding spaces and keeps the case, as meshcore-open's derivePskFromHashtag() does. - /prefs written by a newer build (bigger NodePrefs, same version): the extra bytes are read through the CRC and skipped instead of resetting every setting. - A channel post from someone named "Me" is filed as "\"Me\": ...", so the views don't take it for our own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -113,11 +113,17 @@ static Result addPublic() {
|
||||
}
|
||||
|
||||
// "#topic": name and passphrase both "#topic" (a leading '#' typed is kept once).
|
||||
// Spaces around it are dropped and the case kept, as the phone app does
|
||||
// (meshcore-open's derivePskFromHashtag()), so "#Kraków " joins the same channel.
|
||||
static Result addHashtag(const char* topic) {
|
||||
if (topic && topic[0] == '#') topic++;
|
||||
if (!topic || !topic[0]) return NO_NAME;
|
||||
if (!topic) return NO_NAME;
|
||||
while (*topic == ' ') topic++;
|
||||
if (topic[0] == '#') topic++;
|
||||
char name[32];
|
||||
snprintf(name, sizeof(name), "#%s", topic);
|
||||
size_t n = strlen(name);
|
||||
while (n > 1 && name[n - 1] == ' ') name[--n] = '\0';
|
||||
if (n < 2) return NO_NAME;
|
||||
uint8_t secret[32];
|
||||
phraseToSecret(name, secret);
|
||||
return save(freeSlot(), name, secret);
|
||||
|
||||
@@ -246,6 +246,11 @@ public:
|
||||
}
|
||||
void onChannelMessageRecvEx(mesh::Packet *pkt, uint8_t channel_idx, ChannelDetails& channel_details,
|
||||
uint32_t timestamp, const char* text) override {
|
||||
// Our own posts are filed as "Me: ..." and every view reads that prefix as
|
||||
// "ours". Someone else named "Me" gets quotes, so theirs stays theirs (a
|
||||
// bubble on the left, counted unread).
|
||||
char quoted[MSG_TEXT_BUF];
|
||||
if (strncmp(text, "Me: ", 4) == 0) { snprintf(quoted, sizeof(quoted), "\"Me\"%s", text + 2); text = quoted; }
|
||||
addChannelMsg(channel_idx, text, timestamp, pkt->path, (uint8_t)pkt->path_len);
|
||||
pushMessageArrived(UIEventType::channelMessage, channel_details.name, channel_idx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user