CVKNewsItem* CVkProto::GetVkNotificationsItem(const JSONNode &jnItem, OBJLIST<CVkUserInfo> &vkUsers) { debugLogA("CVkProto::GetVkNotificationsItem"); if (!jnItem) return NULL; CMString tszType(jnItem["type"].as_mstring()); VKObjType vkFeedbackType = vkNull, vkParentType = vkNull; CMString tszNotificationTranslate = SpanVKNotificationType(tszType, vkFeedbackType, vkParentType); const JSONNode &jnFeedback = jnItem["feedback"]; const JSONNode &jnParent = jnItem["parent"]; if (!jnFeedback || !jnParent) return NULL; CVkUserInfo *vkUser = NULL; CMString tszFeedback = GetVkFeedback(jnFeedback, vkFeedbackType, vkUsers, vkUser); CVKNewsItem* vkNotification = GetVkParent(jnParent, vkParentType); if (!vkNotification) return NULL; if (vkNotification && !tszFeedback.IsEmpty()) { CMString tszNotificaton; tszNotificaton.AppendFormat(tszFeedback, tszNotificationTranslate, vkNotification->tszText); vkNotification->tszText = tszNotificaton; tszFeedback = RemoveBBC(tszFeedback); int idx = tszFeedback.Find(_T(" %s %s")); vkNotification->tszPopupTitle.AppendFormat(_T("%s %s"), tszFeedback.Mid(0, idx), tszNotificationTranslate); if (tszFeedback.GetLength() > idx + 7) { if (!vkNotification->tszPopupText.IsEmpty()) vkNotification->tszPopupText += _T("\n>> "); vkNotification->tszPopupText += tszFeedback.Mid(idx + 7, tszFeedback.GetLength() - idx - 7); } vkNotification->tszType = tszType; vkNotification->tDate = jnItem["date"].as_int(); vkNotification->vkFeedbackType = vkFeedbackType; vkNotification->vkParentType = vkParentType; vkNotification->vkUser = vkUser; return vkNotification; } delete vkNotification; return NULL; }
CVKNewsItem* CVkProto::GetVkGroupInvates(const JSONNode &jnItem, OBJLIST<CVkUserInfo> &vkUsers) { debugLogA("CVkProto::GetVkGroupInvates"); if (!jnItem) return NULL; CMString tszType(jnItem["type"].as_mstring()); VKObjType vkFeedbackType = vkNull, vkParentType = vkNull; CMString tszNotificationTranslate = SpanVKNotificationType(tszType, vkFeedbackType, vkParentType); if (!jnItem["id"]) return NULL; LONG iGroupId = jnItem["id"].as_int(); CMString tszId; tszId.AppendFormat(_T("%d,"), iGroupId); CMString tszIds = ptrT(db_get_tsa(NULL, m_szModuleName, "InviteGroupIds")); if (tszIds.Find(tszId, 0) != -1) return NULL; LONG iUserId = !jnItem["invited_by"] ? 0 : jnItem["invited_by"].as_int(); CVKNewsItem *vkNotification = new CVKNewsItem(); vkNotification->tDate = time(NULL); vkNotification->vkUser = GetVkUserInfo(iUserId, vkUsers); vkNotification->tszType = tszType; vkNotification->tszId = tszId; vkNotification->vkFeedbackType = vkFeedbackType; vkNotification->vkParentType = vkParentType; CMString tszGroupName, tszGLink; CMString tszGName = jnItem["name"].as_mstring(); tszGLink.AppendFormat(_T("https://vk.com/%s"), jnItem["screen_name"].as_mstring()); tszGroupName = SetBBCString(tszGName, m_iBBCForNews, vkbbcUrl, tszGLink); CMString tszUsers = SetBBCString(iUserId ? vkNotification->vkUser->m_tszUserNick : TranslateT("Unknown"), m_iBBCForNews, vkbbcUrl, iUserId ? vkNotification->vkUser->m_tszLink : _T("https://vk.com/")); vkNotification->tszText.AppendFormat(_T("%s %s %s"), tszUsers, tszNotificationTranslate, tszGroupName); tszIds += tszId; setTString("InviteGroupIds", tszIds); return vkNotification; }
CVKNewsItem* CVkProto::GetVkNotificationsItem(const JSONNode &jnItem, OBJLIST<CVkUserInfo> &vkUsers) { debugLogA("CVkProto::GetVkNotificationsItem"); if (!jnItem) return NULL; CMString tszType(jnItem["type"].as_mstring()); VKObjType vkFeedbackType = vkNull, vkParentType = vkNull; CMString tszNotificationTranslate = SpanVKNotificationType(tszType, vkFeedbackType, vkParentType); const JSONNode &jnFeedback = jnItem["feedback"]; const JSONNode &jnParent = jnItem["parent"]; if (!jnFeedback || !jnParent) return NULL; CVkUserInfo *vkUser = NULL; CMString tszFeedback = GetVkFeedback(jnFeedback, vkFeedbackType, vkUsers, vkUser); CVKNewsItem* vkNotification = GetVkParent(jnParent, vkParentType); if (!vkNotification) return NULL; if (vkNotification && !tszFeedback.IsEmpty()) { CMString tszNotificaton; tszNotificaton.AppendFormat(tszFeedback, tszNotificationTranslate, vkNotification->tszText); vkNotification->tszText = tszNotificaton; vkNotification->tszType = tszType; vkNotification->tDate = jnItem["date"].as_int(); vkNotification->vkFeedbackType = vkFeedbackType; vkNotification->vkParentType = vkParentType; vkNotification->vkUser = vkUser; return vkNotification; } delete vkNotification; return NULL; }