创建在 ical 中有多个事件的授权时出错

Error on creating a grant that has multiple events within ical

我正在使用 tapkey_management_api_v1,我需要创建一个补助金,其中包含每个工作日的重复事件。但我得到了一个错误。是否可以为一周中的每一天添加活动?

{
  "ErrorCode": "TimeRestrictionIcalTooComplex",
  "ErrorMessage": "encoded ical too long",
  "ErrorDetails": null,
  "UserErrorMessage": null
}

主题是,

BEGIN:VCALENDAR
VERSION:2.0
PRODID:www.test-app.test
CALSCALE:GREGORIAN
BEGIN:VEVENT
DTSTAMP:20211018T190000Z
UID:35a14f06-cd63-4185-b456-d872656abc7d
DTSTART:20211018T000000Z
DTEND:20211018T050000Z
RRULE:FREQ=WEEKLY;UNTIL=20220404T140000Z;BYDAY=MO
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20211018T190000Z
UID:dc02d22c-73d8-4d6f-abab-81247daeec2a
DTSTART:20211019T000000Z
DTEND:20211019T100000Z
RRULE:FREQ=WEEKLY;UNTIL=20220404T140000Z;BYDAY=TU
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20211018T190000Z
UID:618a67aa-5a35-4b9d-a735-8e8c0d83f84c
DTSTART:20211020T000000Z
DTEND:20211020T150000Z
RRULE:FREQ=WEEKLY;UNTIL=20220404T140000Z;BYDAY=WE
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20211018T190000Z
UID:67f7865b-3075-40d2-a788-c969d01ff01d
DTSTART:20211021T000000Z
DTEND:20211021T200000Z
RRULE:FREQ=WEEKLY;UNTIL=20220404T140000Z;BYDAY=TH
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20211018T190000Z
UID:e43a9a09-477b-4e0e-92eb-4a6d63ed1064
DTSTART:20211022T000000Z
DTEND:20211022T201500Z
RRULE:FREQ=WEEKLY;UNTIL=20220404T140000Z;BYDAY=FR
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20211018T190000Z
UID:05399c67-fae3-4529-b6f3-afd0e8ea2cbc
DTSTART:20211023T000000Z
DTEND:20211023T203000Z
RRULE:FREQ=WEEKLY;UNTIL=20220404T140000Z;BYDAY=SA
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20211018T190000Z
UID:50b23e9f-5e2e-470a-b83c-96af65c46199
DTSTART:20211024T000000Z
DTEND:20211025T000000Z
RRULE:FREQ=WEEKLY;UNTIL=20220404T140000Z;BYDAY=SU
END:VEVENT
END:VCALENDAR

卷曲请求

curl -X "PUT" "https://my.tapkey.com/api/v1/owners/xxxx/grants" \
     -H 'Authorization: Bearer xxxx' \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "timeRestrictionIcal": "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:www.test-app.test\nCALSCALE:GREGORIAN\nBEGIN:VEVENT\nDTSTAMP:20211018T190000Z\nUID:35a14f06-cd63-4185-b456-d872656abc7d\nDTSTART:20211018T000000Z\nDTEND:20211018T050000Z\nRRULE:FREQ=WEEKLY;UNTIL=20220404T140000Z;BYDAY=MO\nEND:VEVENT\nBEGIN:VEVENT\nDTSTAMP:20211018T190000Z\nUID:dc02d22c-73d8-4d6f-abab-81247daeec2a\nDTSTART:20211019T000000Z\nDTEND:20211019T100000Z\nRRULE:FREQ=WEEKLY;UNTIL=20220404T140000Z;BYDAY=TU\nEND:VEVENT\nBEGIN:VEVENT\nDTSTAMP:20211018T190000Z\nUID:618a67aa-5a35-4b9d-a735-8e8c0d83f84c\nDTSTART:20211020T000000Z\nDTEND:20211020T150000Z\nRRULE:FREQ=WEEKLY;UNTIL=20220404T140000Z;BYDAY=WE\nEND:VEVENT\nBEGIN:VEVENT\nDTSTAMP:20211018T190000Z\nUID:67f7865b-3075-40d2-a788-c969d01ff01d\nDTSTART:20211021T000000Z\nDTEND:20211021T200000Z\nRRULE:FREQ=WEEKLY;UNTIL=20220404T140000Z;BYDAY=TH\nEND:VEVENT\nBEGIN:VEVENT\nDTSTAMP:20211018T190000Z\nUID:e43a9a09-477b-4e0e-92eb-4a6d63ed1064\nDTSTART:20211022T000000Z\nDTEND:20211022T201500Z\nRRULE:FREQ=WEEKLY;UNTIL=20220404T140000Z;BYDAY=FR\nEND:VEVENT\nBEGIN:VEVENT\nDTSTAMP:20211018T190000Z\nUID:05399c67-fae3-4529-b6f3-afd0e8ea2cbc\nDTSTART:20211023T000000Z\nDTEND:20211023T203000Z\nRRULE:FREQ=WEEKLY;UNTIL=20220404T140000Z;BYDAY=SA\nEND:VEVENT\nBEGIN:VEVENT\nDTSTAMP:20211018T190000Z\nUID:50b23e9f-5e2e-470a-b83c-96af65c46199\nDTSTART:20211024T000000Z\nDTEND:20211025T000000Z\nRRULE:FREQ=WEEKLY;UNTIL=20220404T140000Z;BYDAY=SU\nEND:VEVENT\nEND:VCALENDAR",
  "boundLockId": "xxxx",
  "contactId": "xxxx",
  "active": true
}' | jq

根据document about creating a grant,它说

The calendar passed to Tapkey can contain one or multiple events. Events can hold recurrence rules as specified in RFC 5545, section 3.8.5.3..

The ICAL will be evaluated on the lock, where memory and computing power are limited. When a grant is created, the Tapkey Trust Service checks whether the affected locks will be able to process the specified ICAL. If that is not the case, the operation returns TimeRestrictionIcalTooComplex.

不幸的是,截至今天,单个 Grant 的 ICAL 中可能包含的 RRULES 数量限制为 5 个。这通常不是相关限制,因为很少发生用户每天被授予不同访问时间的情况。顺便提一句。到目前为止,您的 ICAL 没有指定任何时区。这样做会进一步减少单个 ICAL 中可用的 RRULES 数量。

可能的解决方法(虽然不适用于这个特定的 ICAL):

  • 尝试将多个 RRULE 组合成较少数量的 RRULE(即通过在单个 RRULE 中指定多个工作日)。
  • 在重复次数较少的情况下使用 RDATE 而不是 RRULE。
  • 不是为每个 RRULE 指定 UNTIL 日期,而是为整个 Grant 指定一个 validBefore 值。
  • 在 VEVENT 不重叠的情况下(即 DTSTART – UNTIL 不重叠),可以创建多个 Grants,每个 Grants 的 ICAL 都不那么复杂。