If both the "onSuccessActivateScript" and
"onSuccessDeactivateScript" arguments are
present in the request, then
"onSuccessDeactivateScript" MUST be processed first.
If neither argument is present in the request, the currently
active SieveScript (if any) will remain as such.¶
This method provides functionality equivalent to that of the
PUTSCRIPT, DELETESCRIPT, RENAMESCRIPT, and SETACTIVE commands defined
in [RFC5804].¶
If the SieveScript cannot be created or updated because it
would result in two SieveScripts with the same name, the
server MUST reject the request with an "alreadyExists"
SetError.
An "existingId" property of type "Id" MUST be included on the
SetError object with the id of the existing SieveScript.¶
If the SieveScript cannot be created or updated because
its size exceeds the "maxSizeScript" limit, the server MUST
reject the request with a "tooLarge" SetError.¶
If the SieveScript cannot be created because it would
exceed the "maxNumberScripts" limit or would exceed a
server-imposed storage limit, the server MUST
reject the request with an "overQuota" SetError.¶
Upload a script
requiring the Imap4Flags Extension
[RFC5232]
using the JMAP uploadUrl as advertised in the example in
Section 1.2.2:¶
POST /jmap/upload/ken/ HTTP/1.1
Host: jmap.example.com
Authorization: Basic a2VuOnBhc3N3b3Jk
Content-Type: application/sieve
Content-Length: 98
require "imapflags";
if address :is ["To", "Cc"] "[email protected]" {
setflag "\\Flagged";
}
HTTP/1.1 201 Created
Date: Thu, 10 Dec 2020 17:14:31 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 171
{
"accountId": "ken",
"blobId": "Gabcc83e44a6e19991c4568d0b94e1767c83dd123",
"type": "application/sieve"
"size": 98
}
¶
Create and activate
a script using the uploaded blob.
Note that the response shows that an existing active
script has been deactivated in lieu of the newly
created script being activated.¶
[
["SieveScript/set", {
"accountId": "ken",
"create": {
"A": {
"name": null,
"blobId": "Gabcc83e44a6e19991c4568d0b94e1767c83dd123"
}
},
"onSuccessActivateScript": "#A"
}, "0"]
]
[
[
"SieveScript/set",
{
"oldState": "1603741717.50737918-4096",
"newState": "1603741751.227268529-4096",
"created": {
"A": {
"id": "dd1b164f-8cdc-448c-9f54",
"name": "ken-20201210T171432-0",
"blobId": "Sdd1b164f-8cdc-448c-9f54",
"isActive": true
}
},
"updated": {
"8abd6f4a-bcb4d-87650-3fcd": {
"isActive": false
}
},
"destroyed": null,
"notCreated": null,
"notUpdated": null,
"notDestroyed": null,
"accountId": "ken"
},
"0"
]
]
¶
Update the script content using
the JMAP Blob management extension [RFC9404]:¶
{
[
["Blob/upload", {
"accountId": "ken",
"create": {
"B": {
"data": [ {
"data:asText":
"redirect \"[email protected]\"\r\n;"
} ],
"type": "application/sieve"
}
}
}, "1"],
["SieveScript/set", {
"accountId": "ken",
"update": { "dd1b164f-8cdc-448c-9f54": {
"blobId": "#B"
}
}
}, "2"]
]
[
[
"Blob/upload",
{
"oldState": null,
"newState": "1603741700.309607123-0128",
"created": {
"B": {
"id": "G969c83e44a6e10871c4568d0b94e1767c83ddeae",
"blobId": "G969c83e44a6e10871c4568d0b94e1767c83ddeae",
"type": "application/sieve",
"size": 29
}
},
"notCreated": null,
"accountId": "ken"
},
"1"
],
[
"SieveScript/set",
{
"oldState": "1603741751.227268529-4096",
"newState": "1603742603.309607868-4096",
"created": null,
"updated": {
"dd1b164f-8cdc-448c-9f54": null
},
"destroyed": null,
"notCreated": null,
"notUpdated": null,
"notDestroyed": null,
"accountId": "ken"
},
"2"
]
]
¶
Update the script name, and deactivate it:¶
[
["SieveScript/set", {
"accountId": "ken",
"update": { "dd1b164f-8cdc-448c-9f54": {
"name": "myscript"
}
},
"onSuccessDeactivateScript": true
}, "3"]
]
[
[
"SieveScript/set",
{
"oldState": "1603742603.309607868-4096",
"newState": "1603742967.852315428-4096",
"created": null,
"updated": {
"dd1b164f-8cdc-448c-9f54": {
"isActive": false
}
},
"destroyed": null,
"notCreated": null,
"notUpdated": null,
"notDestroyed": null,
"accountId": "ken"
},
"3"
]
]
¶
Reactivate the script:¶
[
["SieveScript/set", {
"accountId": "ken",
"onSuccessActivateScript": "dd1b164f-8cdc-448c-9f54"
}, "4"]
]
[
[
"SieveScript/set",
{
"oldState": "1603742967.852315428-4096",
"newState": "1603744460.316617118-4096",
"created": null,
"updated": {
"dd1b164f-8cdc-448c-9f54": {
"isActive": true
}
},
"destroyed": null,
"notCreated": null,
"notUpdated": null,
"notDestroyed": null,
"accountId": "ken"
},
"4"
]
]
¶
Deactivate and destroy the active script:¶
[
["SieveScript/set", {
"accountId": "ken",
"onSuccessDeactivateScript": true
}, "5"],
["SieveScript/set", {
"accountId": "ken",
"destroy": [ "dd1b164f-8cdc-448c-9f54" ]
}, "6"]
]
[
[
"SieveScript/set",
{
"oldState": "1603744460.316617118-4096",
"newState": "1603744637.575375572-4096",
"created": null,
"updated": {
"dd1b164f-8cdc-448c-9f54": {
"isActive": false
}
},
"destroyed": null,
"notCreated": null,
"notUpdated": null,
"notDestroyed": null,
"accountId": "ken"
},
"5"
],
[
"SieveScript/set",
{
"oldState": "1603744637.575375572-4096",
"newState": "1603744637.854390875-4096",
"created": null,
"updated": null,
"destroyed": [
"dd1b164f-8cdc-448c-9f54"
],
"notCreated": null,
"notUpdated": null,
"notDestroyed": null,
"accountId": "ken"
},
"6"
]
]
¶