123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- //
- // WFCCChangeGroupNameNotificationContent.m
- // WFChatClient
- //
- // Created by heavyrain on 2017/9/20.
- // Copyright © 2017年 WildFireChat. All rights reserved.
- //
- #import "WFCCChangeGroupPortraitNotificationContent.h"
- #import "WFCCIMService.h"
- #import "WFCCNetworkService.h"
- #import "Common.h"
- @implementation WFCCChangeGroupPortraitNotificationContent
- - (WFCCMessagePayload *)encode {
- WFCCMessagePayload *payload = [[WFCCMessagePayload alloc] init];
- payload.contentType = [self.class getContentType];
-
- NSMutableDictionary *dataDict = [NSMutableDictionary dictionary];
- if (self.operateUser) {
- [dataDict setObject:self.operateUser forKey:@"o"];
- }
-
-
- payload.binaryContent = [NSJSONSerialization dataWithJSONObject:dataDict
- options:kNilOptions
- error:nil];
-
- return payload;
- }
- - (void)decode:(WFCCMessagePayload *)payload {
- NSError *__error = nil;
- NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:payload.binaryContent
- options:kNilOptions
- error:&__error];
- if (!__error) {
- self.operateUser = dictionary[@"o"];
- }
- }
- + (int)getContentType {
- return MESSAGE_CONTENT_TYPE_CHANGE_GROUP_PORTRAIT;
- }
- + (int)getContentFlags {
- return WFCCPersistFlag_PERSIST;
- }
- + (void)load {
- [[WFCCIMService sharedWFCIMService] registerMessageContent:self];
- }
- - (NSString *)digest {
- return [self formatNotification];
- }
- - (NSString *)formatNotification {
- NSString *formatMsg;
- if ([[WFCCNetworkService sharedInstance].userId isEqualToString:self.operateUser]) {
- formatMsg = @"你更新了群头像";
- } else {
- WFCCUserInfo *userInfo = [[WFCCIMService sharedWFCIMService] getUserInfo:self.operateUser refresh:NO];
- if (userInfo.displayName.length > 0) {
- formatMsg = [NSString stringWithFormat:@"%@更新了群头像", userInfo.displayName];
- } else {
- formatMsg = [NSString stringWithFormat:@"用户<%@>更新了群头像", self.operateUser];
- }
- }
-
- return formatMsg;
- }
- @end
|