Skip to content

Commit

Permalink
Merge branch 'vkposturl' into 'master'
Browse files Browse the repository at this point in the history
[buteo-sync-plugins-social] Fixed VK post url handling for group posts. Fixes JB#33237

This should construct correct url for VK group posts. "Should" because this isn't really documented anywhere, as far as I can tell, but has worked with everything I've tried so far.

See merge request !8
  • Loading branch information
aseppala committed Nov 13, 2015
2 parents 77ade53 + 781149b commit ba0ce6a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/vk/vk-posts/vkpostsyncadaptor.cpp
Expand Up @@ -325,13 +325,14 @@ void VKPostSyncAdaptor::saveVKPostFromObject(int accountId, const QJsonObject &p
if (!body.isEmpty()) {
hasValidContent = true;
}
QString posterName, posterIcon;
QString posterName, posterIcon, screenName;
int fromId = newPost.fromId;
if (newPost.fromId < 0) {
// it was posted by a group
const GroupProfile &group(VKDataTypeSyncAdaptor::findGroupProfile(groupProfiles, newPost.fromId));
posterName = group.name;
posterIcon = group.icon;
screenName = group.screenName;
fromId = -fromId;
} else {
// it was posted by a user
Expand All @@ -347,7 +348,13 @@ void VKPostSyncAdaptor::saveVKPostFromObject(int accountId, const QJsonObject &p
? QString::number(post.value(QStringLiteral("id")).toDouble())
: QString::number(post.value(QStringLiteral("post_id")).toDouble()));

newPost.link = QStringLiteral("https://m.vk.com/wall") + identifier;
if (newPost.fromId < 0) {
// construct group post url
newPost.link = QStringLiteral("https://vk.com/%1?w=wall-%2").arg(screenName).arg(identifier);
} else {
// construct wall post url
newPost.link = QStringLiteral("https://m.vk.com/wall") + identifier;
}

Q_FOREACH (const QString &line, body.split('\n')) { SOCIALD_LOG_TRACE(line); }

Expand Down

0 comments on commit ba0ce6a

Please sign in to comment.