Is the IMAP UID guaranteed numeric? I've read the part in RFC3501 and it says:
Unique identifiers
are assigned in a strictly ascending fashion in the mailbox; as each
message is added to the mailbox it is assigned a higher UID than the
message(s) which were added previously.
But could it be that the UID has a pre- or postfix? For example, could it be that the UID is mail_14 and the next msg mail_15?
Answer: IMAP UID is a unique nonzero integer.
You might want to read the part in RFC3501 that defines the UID:
uniqueid = nz-number
; Strictly ascending
Page 91.
Related
I try to get uids from imap server which are greater than specific uid in Inbox folder.
The query looks like:
UID SEARCH UID 13780:*
Response:
* SEARCH 13779
aaaj OK UID SEARCH Completed.
Why does it return UID 13779 ? It less than 13780!
Then I send email and the response is the following:
* SEARCH 13779
* 5 EXISTS
* 4 RECENT
aaak OK UID SEARCH Completed.
And after next request the response is the following:
* SEARCH 13780
aaal OK UID SEARCH Completed.
Why does it happens so ?
During all requests I keep session opened.
Why it returned lower uid I have understood, because max uid was lower than requested uid. But why does it returns first time this one:
* 5 EXISTS
* 4 RECENT
And then:
* SEARCH 13780
aaal OK UID SEARCH Completed.
So 13780 is needed information in my case, can I get it at once ? Without EXISTS and RECENT in first query ?
UID SEARCH UID 13780:* does not mean "all UIDs greater than or equal to 13780". It means "all UIDs between 13780 and the largest UID in the mailbox". That is, the * is internally replaced with the current largest UID.
If the current largest UID is 13779, then the command is parsed to UID SEARCH UID 13780:13779, which is equivalent to UID SEARCH UID 13779:13780, as by specification ranges m:n and n:m are equivalent.
Therefore, you always get the largest UID in the mailbox.
If the client does a FETCH with a range of sequence numbers, must the server response give each e-mail in ascending sequence number order?
The RFC3501 contains the following example of a FETCH command.
C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)])
S: * 2 FETCH ....
S: * 3 FETCH ....
S: * 4 FETCH ....
S: A654 OK FETCH completed
Would the following example represent a compliant server?
C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)])
S: * 3 FETCH ....
S: * 4 FETCH ....
S: * 2 FETCH ....
S: A654 OK FETCH completed
I could not find nothing in the sections for FETCH request and FETCH response regarding the order of the response.
You can reorder as much as you want. The paragraph Paurian quotes applies to UID assignment, not to reporting.
It's also safe in practice: Symantec's IMAP proxy (I forget its name, but its job is to scan for naughty attachments and present a santised view of the world to IMAP clients) sends fetch responses in an unpredictable order, and the main developer knows about no problems resulting from that.
From what I understand, No. The sequence must be in order. [See comments, below - as the specs mention storage, not retrieval of order.]
2.3.1.1. Unique Identifier (UID) Message Attribute
A 32-bit value assigned to each message, which when used with the
unique identifier validity value (see below) forms a 64-bit value
that MUST NOT refer to any other message in the mailbox or any
subsequent mailbox with the same name forever. Unique identifiers
are assigned in a strictly ascending fashion in the mailbox; as each
message is added to the mailbox it is assigned a higher UID than the
message(s) which were added previously. Unlike message sequence
numbers, unique identifiers are not necessarily contiguous.
Since these are sequence numbers, the result must be contiguous.
Articld 6.4.8. implies that FETCH without the UID prefix indicates a sequence search rather than a unique identifier within your range expression:
... the UID command (variant) takes a SEARCH command with
SEARCH command arguments. The interpretation of the arguments is
the same as with SEARCH; however, the numbers returned in a SEARCH
response for a UID SEARCH command are unique identifiers instead
Source: https://www.rfc-editor.org/rfc/rfc3501
I am importing Quick books item data from quick books to CSV file using QBFC.
I have seen few fields have same value(103).
ParentRefType = 103
SalesTaxCodeRefType = 103
ExpenseAccountType = 103
PrefVendorType = 103
PurchaseTaxCodeType = 103
Find the file here
Let me know why ? I does not see this values directly form Quick book application.
I hope this values coming from background.
The short answer is that 103 refers to the FullName Reference Type. And yes, these values are coming from the "background" of Quickbooks and QBFC so you will likely not see them anywhere in the Quickbooks UI.
All of the fields you listed above are Reference Types of a Quickbooks object (i.e. Parent, SalesTaxCode, ExpenseAccount, etc). You can reference an object through two means: a ListID or a FullName. The Type of the reference indicates whether or not the object is using a ListID reference or a FullName reference.
The integer 103 appears to be the internal identifier for a FullName reference type. Notice in your export file (Item.csv) that all of the reference objects use the FullName type to reference objects (see the columns ParentRefFullName, SalesTaxCodeRefFullName, ExpenseAccountRefFullName, etc). Notice also that the columns immediately after these are the Ref Type columns (i.e. ParentRefType, SalesTaxCodeRefType, etc). These Ref Type columns are set to 103 whenever the cell to the left (the FullName cell) contains a value. When there is no FullName reference, the Type column contains a zero (which I'm assuming means Ref Type Not Known or something similar).
The QBFC Quick Reference states the following (under the IQBBaseRef definition):
IQBBaseRef is used for all qbXML "object references," which refer to objects. For example, an
AccountRef refers to an account in the chart of accounts. If a request specifies both ListID
and FullName, QuickBooks will use only the ListID.
That last sentence is important to note. A ListID reference takes priority over a FullName reference. It appears though that there are no ListID references used in your export file.
I have an Application model which has app_id and secret_key fields. What is the best way to generate unique app_ids?
I can use ActiveSupport:SecureRandom.hex(16) to generate an 32-char alpha-numeric string and there will probably be no other string like it. If done in this manner, should I also do a database check to see if there is a duplicate app_id or is this step unnecessary since the likelihood of that is infinitesimally small?
Or is there a better method?
Thanks!
Tim
I would always double check, just to be sure. Put a unique index on app_id and it's all set. It's hard to guarantee uniqueness
However, you could build a string that is guaranteed to be unique.
string = ActiveSupport::SecureRandom.hex(16)
append = #app.id.to_s
string = string.slice(0, string.length - append.length) + append
So the first part is random, but it always ends with the database id column, which would have to be unique.
There are also likely variations of this that keep the random looking structure, e.g. using a Caesar Cipher or a simple numeric to alphabetic cipher.
I would check first.
Here's some code I've seen in devise used when generating a unique token (modified for your example):
loop do
token = ActiveSupport::SecureRandom.hex 16
break token unless find(:first, :token => token)
end
Line 162:
https://github.com/plataformatec/devise/blob/master/lib/devise/models/authenticatable.rb
I'd like to download the text (that is mime type text/plain, text/html text/richtext) from UID x to UID y.
I have the UID's (and not mailbox IDs).
How can I do something like
FETCH 412444:412500 (BODY.PEEK[TEXT/PLAIN OR TEXT/HTML OR TEXT/RICHTEXT])
Thanks!
After checking RFC3501, the UID command (section 6.4.8) seems to be able to do part of this:
The UID command has two forms. In the first form, it takes as its
arguments a COPY, FETCH, or STORE command with arguments
appropriate for the associated command. However, the numbers in
the sequence set argument are unique identifiers instead of
message sequence numbers. Sequence set ranges are permitted, but
there is no guarantee that unique identifiers will be contiguous.
Thus, you should be able to call:
UID FETCH 412444:412500 (BODY.PEEK[TEXT/PLAIN OR TEXT/HTML OR TEXT/RICHTEXT])