Skip to content
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

%to(addressbook,other.custom*)% not working from smart fragments menu [Cardbook] #246

Closed
orcofthedarkness opened this issue Jul 16, 2023 · 25 comments
Assignees
Labels
bug cardbook Integration with the Cardbook Add-on ESR 115 Changes for Thunderbird SuperNova UI

Comments

@orcofthedarkness
Copy link

orcofthedarkness commented Jul 16, 2023

Hi,

TB version: 115.0
SmartTemplates version: 4.0pre256
Cardbook version: 90.4

Here is the content of my template (it doesn't matter "which" template (write, reply, forward...)
<p>Hi %to(firstname)%<br /><br />Dein User: %to(addressbook,other.custom1)%</p>

When you have NO license applied, both the %to(firstname)% and the %to(addressbook,other.custom1)% are working just fine.
Once you apply the (valid) license (all PRO features are enabled), the %to(firstname)% still works, but %to(addressbook,other.custom1)% doesn't work anymore. If you remove the license key, everything work as expected.

Tested also with other.custom[2-4].

thx in advance,
Ron

@RealRaven2000 RealRaven2000 self-assigned this Jul 16, 2023
@RealRaven2000 RealRaven2000 added bug ESR 115 Changes for Thunderbird SuperNova UI labels Jul 16, 2023
@RealRaven2000
Copy link
Owner

Could be a compatibility bug in Cardbook
That you get a result without license suggests that the data was retrieved from the standard AB instead. Do you see any error messages in the error console (open with Ctrl_Shift+J) when you lload the template?

@orcofthedarkness
Copy link
Author

yes, i get the following 2 messages, when i click on the clickable variable
image

@RealRaven2000
Copy link
Owner

Ok. could you export one contact for me for testing please? Please send to thunderbirddaily@gmail.com, please reference [SmartTemplates] issue 246 in the subject line, if you want to send it off Github.

Also, I while testing I discovered a bad issue #247 that breaks the templates file in all versions of SmartTemplates 4.0, so don't try to add templates to the menu until that is fixed (is going to go into the next beta with high priority)

@RealRaven2000
Copy link
Owner

RealRaven2000 commented Jul 16, 2023

Thanks for sending test data - I couldn't reproduce the particular p[roblem (TypRror: nodeList is undefined), I got partial data back but didn't get the data for "other1, other2":

image

It looks like in my previous test versions I would have expected a array member looking like this:

"VALUE:some string"

but we see this data in card.others (information partially redacted):

card.others
Array [ "X-CUSTOM1:WolfgangR***********r", "X-CUSTOM2:r*******w" ]
0: "X-CUSTOM1:WolfgangR*******"​
1: "X-CUSTOM2:r*******w"​
length: 2

@RealRaven2000
Copy link
Owner

Below is a test template for all Cardbook / Addressbook fields

Address-Book-tests.zip

@RealRaven2000
Copy link
Owner

The error of nodeList = null seems to point to the way you are using the field. Interactively? from a plain text message? If the account template contains the address book fields, can you please export your smartTemplates account templates : too?

image

(this includes all the data on the left side of the dialog for the selected account)

@orcofthedarkness
Copy link
Author

Here is the exported account json
Ronald.zip

@orcofthedarkness
Copy link
Author

Below is a test template for all Cardbook / Addressbook fields

Address-Book-tests.zip

now it gets weird.
I installed the attached pre273 version from #247
When i import the templates from the "Address-Book-test.zip" as HTML template: Write - the correct data is pulled from the AB
When i import the templates as Smart Snippet, it doesnt work any longer, no data will be pulled from the AB

@RealRaven2000
Copy link
Owner

Below is a test template for all Cardbook / Addressbook fields
Address-Book-tests.zip

now it gets weird. I installed the attached pre273 version from #247 When i import the templates from the "Address-Book-test.zip" as HTML template: Write - the correct data is pulled from the AB When i import the templates as Smart Snippet, it doesnt work any longer, no data will be pulled from the AB

great that helps. I am inserting HTML elements into the document and they are later resolved in form of a list. Maybe that fails with a document that's pulled from the smartTemplate menu. For more info in error console, please install the version below

smartTemplate-fx-4.0pre274.zip

this will avoid the nodeList problem but not do anything immediately (e.g. try to insert text into the Editor immediately). I need to test first, but it should advance us a little...

@orcofthedarkness
Copy link
Author

installed pre274, used my template as a template for new mail

  1. write new email -> template is used in msg body
  2. fill in receipient in TO field
  3. click on the clickable variables (one is working, on is not (see above)

Heres the output:
image

@RealRaven2000
Copy link
Owner

Personally, I wouldn't ever use %to% (or %from%) in a snippet. Because it is not clear who that is. The to from the original email that you reply to or the to you are now writing to?

instead, use either %recipient()% (for whoever you are sending the email to) or %identity()% representing the sender of this email (your from identity). To and from are very confusing to use for the text of the template, but are ok to use within quote header.

try this instead:

<p>Hi %recipient(firstname)%<br /><br />
Dein User: %recipient(addressbook,name,other.custom1,other.custom2)%
</p>

@orcofthedarkness
Copy link
Author

Personally, I wouldn't ever use %to% (or %from%) in a snippet. Because it is not clear who that is. The to from the original email that you reply to or the to you are now writing to?

yes, that makes sense. thanks. changed it to your suggested version but still...no luck :(
template used as template for a new email (and click ond the clickable variables)
image

template used as smart snippet: doesnt work at all

@RealRaven2000
Copy link
Owner

RealRaven2000 commented Jul 16, 2023

By the way, testing with Thunderbird 102, here is what I get returned from a custom1 field:

image

the first line is the label of the custom property "custom 1!", the second line is the contained data "C1". That's why I was looking for "VALUE:(some data)". So I need to check why your data is not formatted that way ... hope it is not vCard version dependant, I based it on the format that Phillipe V (the owner of the Cardbook Add-on) returned at the time I implemented the communication between ST and CB

@RealRaven2000
Copy link
Owner

RealRaven2000 commented Jul 16, 2023

I am still down the rabbit hole of testing. it seems there are some "mixed up perspective" problems still when it tries to get the header variables. The function classifyReservedWord(..) in this case uses lookup list TokenMap["recipient"] and that returns "to"... which is correct, but the "hdr" is filled with the header information of the original mail (the one I reply to). I wonder if this is an artifact of using the addressbook lookup during a fragment, I still have to wrap my head around that.

@RealRaven2000
Copy link
Owner

Ok I made some unfortunate finding what happens when we use the fragment in a reply. For %recipient% it doesn't use the current value from the "to" address but the "from" of the original email header. So if we change the addressee by typing a completely different recipient in the "to:" address this will be ignored and still retrieve data from the original sender. I guess I need to look very hard whether I can either swap out the "hdr" structure to reflect data from the current document once the fragments are used, or not replace the "recipient" keywords until much later. Depending on what is easier; this is complicated stuff right there...

@RealRaven2000
Copy link
Owner

RealRaven2000 commented Jul 16, 2023

I dealt with the %recipient% problem, at least it works in fragments now. I will very likely raise a separate bug to explain it. Here is a version for testing:

smartTemplate-fx-4.0pre277.zip

the upshot is that you can now edit the addresse and change the "To:" and the fragments will pick up the correct address items via %recipient()%.

@RealRaven2000 RealRaven2000 changed the title %to(addressbook,other.custom*)% not working when entering the licence key %to(addressbook,other.custom*)% not working from smart fragments menu Jul 16, 2023
@orcofthedarkness
Copy link
Author

orcofthedarkness commented Jul 19, 2023

I dealt with the %recipient% problem, at least it works in fragments now. I will very likely raise a separate bug to explain it. Here is a version for testing:

smartTemplate-fx-4.0pre277.zip

tested, looks good to me (re-populate the clickable variables after changing the receipient in TO: field)

one more thing (not related to the pre277 version): if i use the html template as snipplet, i cannot populate cthe clickable variables. if i use the very same template in a "new e-mail", it works as expected:
image

here you can see, that its the same template (i dont have a template in "write email":
image

@RealRaven2000
Copy link
Owner

if i use the html template as snipplet, i cannot populate the clickable variables.

Sorry I don't understand that sentence, can you give an example?

Do you mean the "deferred" variables that turn up when you write a new email using fields like %recipient(name)% ?

image

@RealRaven2000
Copy link
Owner

... hmm looks like inserting a fragment via "open template file..." directly is broken, I will raise a separate bug. see #249

image

@orcofthedarkness
Copy link
Author

if i use the html template as snipplet, i cannot populate the clickable variables.

Sorry I don't understand that sentence, can you give an example?

Do you mean the "deferred" variables that turn up when you write a new email using fields like %recipient(name)% ?

image

sorry...my bad. my text was little confusing.
My template starts like this:

<p>Hi %recipient(firstname)%,<br /><br />Dein User: %recipient(addressbook,name,other.custom1)%</br>Dein Passwort: %clipboard%</p>

if i insert this template via
image

and click on the first "To - button" (next to "Hi") in the msg body, nothing happens at all.
image

if i insert the very same template via
image

a click on the first "To - button" (next to "Hi") works indeed
image

@RealRaven2000
Copy link
Owner

I am not sure if I can make the script commands work from a "Fragments" entry - did this use to work in Thunderbird 102? There may also be some fallout from the changes (fixes) to %recipient%. I mainly use the "insert snippet" menu for extracting information from the original mail or adding some FAQ / Layout elements, nothing too heavy that interacts with the address headers ....

I made a new version over at:

#249 (comment)

Are there any errors in javascript error console? (use the right-click menu to copy all messages, no screenshots please)

@RealRaven2000 RealRaven2000 changed the title %to(addressbook,other.custom*)% not working from smart fragments menu %to(addressbook,other.custom*)% not working from smart fragments menu Jul 21, 2023
@RealRaven2000 RealRaven2000 pinned this issue Oct 23, 2023
@RealRaven2000
Copy link
Owner

Since we closed #249 can we close this one as well? I am not sure if there any open issues... if it still is a problem, simply reopen this one and send the error log...

@RealRaven2000 RealRaven2000 added the cardbook Integration with the Cardbook Add-on label Feb 19, 2024
@RealRaven2000 RealRaven2000 changed the title %to(addressbook,other.custom*)% not working from smart fragments menu %to(addressbook,other.custom*)% not working from smart fragments menu [Cardbook] Feb 19, 2024
@RealRaven2000
Copy link
Owner

I am just revisiting this bug to make sure it is fixed - I don't know where I can edit the "custom" values in the CardBook editor, any ideas?

@RealRaven2000 RealRaven2000 reopened this Feb 19, 2024
@RealRaven2000
Copy link
Owner

I am just revisiting this bug to make sure it is fixed - I don't know where I can edit the "custom" values in the CardBook editor, any ideas?

I think I managed it in cardbook settings under Custom fields, I set up this:

image

Then I made a new version which makes sure to use the correct email when using the variables %recipient% and %identity% even from a smart fragment menu and used the following fragment for testing:

<div style="border: 1px solid gray; padding: 0.5em; margin-block: 0.5em; border-radius: 5px;">
  <h3>test cardbook <i>other.custom</i>:</h3> 
  Recipient: %recipient(addressbook,name)%<br>
  [[C1: %recipient(addressbook,other.custom1)%<br>]]
  [[Shoe Size: %recipient(addressbook,other.custom2)%<br>]]
  [[YouTuber: %recipient(addressbook,other.custom3)%<br>]]
  [[Support: %recipient(addressbook,other.custom4)%<br>]]
</div>

The results looked correct to me - test version below:

smartTemplate-fx-4.4pre17.zip


To test the version above, download the zip file and drag the file into Thunderbird Add-ons Manager without extracting contents.

RealRaven2000 added a commit that referenced this issue Feb 21, 2024
Support for prefix, suffix, other.custom. Fixed %recipient% when Tb changes perspective after replying to oneself. lowercase option for cardbook lookups. Added larger delay for loading header menu
@RealRaven2000 RealRaven2000 unpinned this issue Feb 21, 2024
@RealRaven2000
Copy link
Owner

Implemented in 4.4 - published 28/03/2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cardbook Integration with the Cardbook Add-on ESR 115 Changes for Thunderbird SuperNova UI
Projects
None yet
Development

No branches or pull requests

2 participants