WFCCUserInfo.m 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // WFCCUserInfo.m
  3. // WFChatClient
  4. //
  5. // Created by heavyrain on 2017/9/29.
  6. // Copyright © 2017年 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCCUserInfo.h"
  9. #import "WFCCUtilities.h"
  10. @implementation WFCCUserInfo
  11. - (void)cloneFrom:(WFCCUserInfo *)other {
  12. self.userId = other.userId;
  13. self.name = other.name;
  14. self.displayName = other.displayName;
  15. self.groupAlias = other.groupAlias;
  16. self.friendAlias = other.friendAlias;
  17. self.portrait = other.portrait;
  18. self.gender = other.gender;
  19. self.mobile = other.mobile;
  20. self.email = other.email;
  21. self.address = other.address;
  22. self.company = other.company;
  23. self.social = other.social;
  24. self.extra = other.extra;
  25. self.updateDt = other.updateDt;
  26. self.type = other.type;
  27. self.deleted = other.deleted;
  28. }
  29. - (id)toJsonObj {
  30. NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
  31. dict[@"uid"] = self.userId;
  32. dict[@"name"] = self.name;
  33. dict[@"displayName"] = self.displayName;
  34. dict[@"groupAlias"] = self.groupAlias;
  35. dict[@"friendAlias"] = self.friendAlias;
  36. dict[@"portrait"] = self.portrait;
  37. dict[@"gender"] = @(self.gender);
  38. dict[@"type"] = @(self.type);
  39. dict[@"mobile"] = self.mobile;
  40. dict[@"email"] = self.email;
  41. dict[@"address"] = self.address;
  42. dict[@"company"] = self.company;
  43. dict[@"social"] = self.social;
  44. dict[@"extra"] = self.extra;
  45. dict[@"updateDt"] = @(self.updateDt);
  46. dict[@"deleted"] = @(self.deleted);
  47. return dict;
  48. }
  49. - (NSString *)readableName {
  50. BOOL isExternal = [WFCCUtilities isExternalTarget:self.userId];
  51. NSString *name;
  52. if (self.friendAlias.length > 0) {
  53. name = self.friendAlias;
  54. } else if(self.groupAlias.length > 0) {
  55. name = self.groupAlias;
  56. } else if (self.displayName.length > 0) {
  57. name = self.displayName;
  58. } else {
  59. if(isExternal) {
  60. name = [WFCCUtilities getTargetWithoutDomain:self.userId];
  61. } else {
  62. name = self.userId;
  63. }
  64. }
  65. if(isExternal) {
  66. NSString *domainId = [WFCCUtilities getExternalDomain:self.userId];
  67. WFCCDomainInfo *domainInfo = [[WFCCIMService sharedWFCIMService] getDomainInfo:domainId refresh:NO];
  68. if(domainInfo.name.length) {
  69. name = [NSString stringWithFormat:@"%@@%@", name, domainInfo.name];
  70. } else {
  71. name = [NSString stringWithFormat:@"%@@%@", name, domainId];
  72. }
  73. }
  74. return name;
  75. }
  76. @end