ADNKit icon indicating copy to clipboard operation
ADNKit copied to clipboard

Regression causes "Bad Request: 'readers.user_ids': Must be a list."

Open winzig opened this issue 10 years ago • 1 comments

I wrote some code against release 1.3.1 which creates channels, and it was working. I decided to fork ADNKit to try and mess with a few ideas, and noticed I was seeing this error when trying to create my channels:

Bad Request: 'readers.user_ids': Must be a list. 'writers.user_ids': Must be a list.

Traced it back to this commit: 676e9b1a69f44a8ee9b2a2aecc1df4dcddaec141

I'm relatively new to Objective-C and it's not immediately obvious to me why that commit would suddenly cause the error above, but something is off.

FYI, I'm creating an ANKChannel as shown below, and passing it into [[ANKClient sharedClient] createChannel]

ANKChannel *channel = [[ANKChannel alloc] initWithJSONDictionary:
   @{
     @"type":       @"com.fanfriendly.channel",
     @"readers":
         @{
             @"any_user":   @NO,
             @"immutable":  @NO,
             @"public":     @NO,
             @"user_ids":   [NSMutableArray arrayWithCapacity:0],
             @"you":            @YES
             },
     @"writers":
         @{
             @"any_user":   @NO,
             @"immutable":  @NO,
             @"public":     @NO,
             @"user_ids":   [NSMutableArray arrayWithObjects:@170301, @6378, nil],
             @"you":            @YES
             },
     @"editors":
         @{
             @"any_user":   @NO,
             @"immutable":  @NO,
             @"public":     @NO,
             @"user_ids":   @[],
             @"you":            @YES
             },
     @"annotations":
         @[
             @{
                 @"type":   @"com.fanfriendly.event",
                 @"value":
                     @{
                         @"title":  title
                         }
                 }
             ]
     }];

winzig avatar Dec 17 '13 07:12 winzig

Thanks for the patch, @winzig! I'll take a look and sort out this behavior. In the meantime, try using the native APIs instead:


ANKChannel *channel = [[ANKChannel alloc] init];

channel.type = @"com.fanfriendly.channel";

channel.writers = [[ANKACL alloc] init];
channel.writers.userIDs = @[@"170301", @"6378"];

ANKAnnotation *eventAnnotation = [[ANKAnnotation alloc] init];
eventAnnotation.type = @"com.fanfriendly.event";
eventAnnotation.value = @{ @"title": title };

channel.annotations = @[eventAnnotation];

[[ANKClient sharedClient] createChannel:channel ...

The API's defaults should get you the rest of the way there (setting things otherwise private, etc.).

berg avatar Dec 17 '13 18:12 berg