// // MBIMMarkOperation.m // kordophoned // // Created by James Magahern on 11/19/18. // Copyright © 2018 James Magahern. All rights reserved. // #import "MBIMMarkOperation.h" #import @implementation MBIMMarkOperation + (void)load { [super load]; } + (NSString *)endpointName { return @"markConversation"; } - (void)main { __block NSObject *response = nil; do { NSString *guid = [self valueForQueryItemWithName:@"guid"]; if (!guid) { NSLog(@"No query item provided"); response = [[HTTPErrorResponse alloc] initWithErrorCode:500]; break; } dispatch_sync([[self class] sharedIMAccessQueue], ^{ IMChat *chat = [sChatRegistry existingChatWithGUID:guid]; if (!chat) { NSLog(@"Chat with guid: %@ not found", guid); response = [[HTTPErrorResponse alloc] initWithErrorCode:500]; } else { // TODO: be smarter about this and mark individual messages as read? Could lead // to a race condition if ([chat unreadMessageCount] > 0) { [chat markAllMessagesAsRead]; } } }); response = [[HTTPErrorResponse alloc] initWithErrorCode:200]; } while (0); self.serverCompletionBlock(response); } @end