Как получить одинаковый ответ propfind для каждого запроса при перечислении календарей icloud? - PullRequest
1 голос
/ 14 июня 2019

Я перечисляю календари из icloud с помощью caldav request propfind, я могу получить коллекцию календарей, но вывод отличается для каждого прогона.Свойства с поддержкой календаря и current-user-Principal отсутствуют некоторое время, и некоторое время это показывает, из-за того, что мой код дает сбой.Мне нужно свойство calendar-enabled , чтобы проверить, включен ли календарь на мобильном телефоне или нет.Я ничего не изменил на уровне календаря и в коде между запусками.Любое решение, пожалуйста.

Это метод запроса

methodPropfind = (headers, auth, body, url, cb) -> options = method: заголовки 'PROPFIND': заголовки auth: auth body: body url: url http options, cb return true

body:

<?xml version='1.0' encoding='UTF-8'?>
<propfind xmlns="DAV:" xmlns:D="http://apple.com/ns/ical/">
  <prop>
    <displayname/>
    <C:getctag xmlns:C="http://calendarserver.org/ns/"/>
    <owner/>
    <D:calendar-color/>
    <D:calendar-order/>
    <current-user-privilege-set/>
    <invite xmlns:A="http://calendarserver.org/ns/"/>
    <D:calendar-enabled />
    <C:schedule-default-calendar-URL xmlns:C='urn:ietf:params:xml:ns:caldav'/>
  </prop>
</propfind>

Заголовок:

Depth:1

Url url является основным URL.

Я преобразовал xml-ответ в объект javascript, и это один из календаря из списка, который я получаю.

Я ожидаю «ExpectedOutput» для каждого запуска, но через некоторое время я получаю «NotExpectedOutput».Почему это отличается?

Не ожидаемый выход:

{ displayname: { _attributes: { xmlns: 'DAV:' }, _text: 'Family' },
  getctag:
   { _attributes: { xmlns: 'http://calendarserver.org/ns/' },
     _text: 'FT=-@RU=39505321-e02c-46a5-a9ba-544e5c3f0fac@S=678' },
  owner:
   { _attributes: { xmlns: 'DAV:' },
     href: { _text: '/1146333145/principal/' } },
  'calendar-color':
   { _attributes: { xmlns: 'http://apple.com/ns/ical/' },
     _text: '#FFCC00' },
  'calendar-order':
   { _attributes: { xmlns: 'http://apple.com/ns/ical/' },
     _text: '1001' },
  'current-user-privilege-set':
   { _attributes: { xmlns: 'DAV:' },
     privilege:
      [ [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object] ] } }

Ожидаемый выход

 { displayname: { _text: 'Family' },
  getctag:
   { _attributes: { xmlns: 'http://calendarserver.org/ns/' },
     _text: 'FT=-@RU=39505321-e02c-46a5-a9ba-544e5c3f0fac@S=678' },
  owner: { href: { _text: '/11463333145/principal/' } },
  'calendar-color':
   { _attributes:
      { xmlns: 'http://apple.com/ns/ical/',
        'symbolic-color': 'yellow' },
     _text: '#FFCC00' },
  'calendar-order':
   { _attributes: { xmlns: 'http://apple.com/ns/ical/' },
     _text: '1001' },
  'current-user-privilege-set':
   { privilege:
      [ [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object],
        [Object] ] },
  'current-user-principal': { href: { _text: '/11463335145/principal/' } },
  'calendar-enabled':
   { _attributes: { xmlns: 'http://apple.com/ns/ical/' },
     _text: 'true' } }
...