Browse Source

fix DM group joining via key import

readme-update
Simon Grim 8 years ago
parent
commit
214ec3f3c7
  1. 2
      css/style.css
  2. 4
      home.html
  3. 52
      js/interface_localization.js
  4. 72
      js/twister_directmsg.js
  5. 2
      theme_calm/css/style.css
  6. 4
      theme_nin/css/style.css

2
css/style.css

@ -1822,7 +1822,7 @@ ol.toptrends-list {
.group-messages-join-group.modal-wrapper { .group-messages-join-group.modal-wrapper {
height: auto; /*about 360px*/ height: auto; /*about 360px*/
margin-top: -240px; margin-top: -204px;
} }
.group-messages-join-group .modal-content .module { .group-messages-join-group .modal-content .module {

4
home.html

@ -632,10 +632,6 @@
<p class="label">Import secret key</p> <p class="label">Import secret key</p>
<input class="secret-key-import" type="textbox" placeholder="52-characters secret" size="52" rows="1"></input> <input class="secret-key-import" type="textbox" placeholder="52-characters secret" size="52" rows="1"></input>
</div> </div>
<div>
<p class="label">With group alias</p>
<input class="username-import" type="textbox" placeholder="Type group alias here" size="16" rows="1"></input>
</div>
<div> <div>
<button class="import-secret-key" disabled="disabled">Import key</button> <button class="import-secret-key" disabled="disabled">Import key</button>
</div> </div>

52
js/interface_localization.js

@ -69,6 +69,10 @@ if(preferredLanguage == "en"){
"Group Messages": "Group Messages", "Group Messages": "Group Messages",
"Group Messages — New Group Creation": "Group Messages — New Group Creation", "Group Messages — New Group Creation": "Group Messages — New Group Creation",
"Group Messages — Join Group": "Group Messages — Join Group", "Group Messages — Join Group": "Group Messages — Join Group",
"group_key_cant_import": "Can\'t import DM group key",
"group_key_is_invalid_perhaps": "perhaps the key is invalid",
"group_key_was_imported": "Key for DM group %{alias} was imported.\n"
+ "Its messages will be fetched soon.",
"direct_messages_with": "Direct messages with %{username}", "direct_messages_with": "Direct messages with %{username}",
"Disable": "Disable", "Disable": "Disable",
"display_mentions": "Display mentions", "display_mentions": "Display mentions",
@ -413,6 +417,10 @@ if(preferredLanguage == "es"){
"Group Messages": "Group Messages", "Group Messages": "Group Messages",
"Group Messages — New Group Creation": "Group Messages — New Group Creation", "Group Messages — New Group Creation": "Group Messages — New Group Creation",
"Group Messages — Join Group": "Group Messages — Join Group", "Group Messages — Join Group": "Group Messages — Join Group",
"group_key_cant_import": "Can\'t import DM group key",
"group_key_is_invalid_perhaps": "perhaps the key is invalid",
"group_key_was_imported": "Key for DM group %{alias} was imported.\n"
+ "Its messages will be fetched soon.",
"direct_messages_with": "Mensajes directos con %{username}", "direct_messages_with": "Mensajes directos con %{username}",
"Disable": "Inhabilitar", "Disable": "Inhabilitar",
"display_mentions": "Visualización de menciones", "display_mentions": "Visualización de menciones",
@ -754,6 +762,10 @@ if(preferredLanguage == "uk"){
"Group Messages": "Group Messages", "Group Messages": "Group Messages",
"Group Messages — New Group Creation": "Group Messages — New Group Creation", "Group Messages — New Group Creation": "Group Messages — New Group Creation",
"Group Messages — Join Group": "Group Messages — Join Group", "Group Messages — Join Group": "Group Messages — Join Group",
"group_key_cant_import": "Can\'t import DM group key",
"group_key_is_invalid_perhaps": "perhaps the key is invalid",
"group_key_was_imported": "Key for DM group %{alias} was imported.\n"
+ "Its messages will be fetched soon.",
"direct_messages_with": "Direct messages with %{username}", "direct_messages_with": "Direct messages with %{username}",
"Disable": "Вимкнено", "Disable": "Вимкнено",
"display_mentions": "Показати сповіщення", "display_mentions": "Показати сповіщення",
@ -1093,6 +1105,10 @@ if(preferredLanguage == "zh-CN"){
"Group Messages": "Group Messages", "Group Messages": "Group Messages",
"Group Messages — New Group Creation": "Group Messages — New Group Creation", "Group Messages — New Group Creation": "Group Messages — New Group Creation",
"Group Messages — Join Group": "Group Messages — Join Group", "Group Messages — Join Group": "Group Messages — Join Group",
"group_key_cant_import": "Can\'t import DM group key",
"group_key_is_invalid_perhaps": "perhaps the key is invalid",
"group_key_was_imported": "Key for DM group %{alias} was imported.\n"
+ "Its messages will be fetched soon.",
"direct_messages_with": "Direct messages with %{username}", "direct_messages_with": "Direct messages with %{username}",
"Disable": "关闭", "Disable": "关闭",
"display_mentions": "显示", "display_mentions": "显示",
@ -1437,6 +1453,10 @@ if(preferredLanguage == "nl"){
"Group Messages": "Group Messages", "Group Messages": "Group Messages",
"Group Messages — New Group Creation": "Group Messages — New Group Creation", "Group Messages — New Group Creation": "Group Messages — New Group Creation",
"Group Messages — Join Group": "Group Messages — Join Group", "Group Messages — Join Group": "Group Messages — Join Group",
"group_key_cant_import": "Can\'t import DM group key",
"group_key_is_invalid_perhaps": "perhaps the key is invalid",
"group_key_was_imported": "Key for DM group %{alias} was imported.\n"
+ "Its messages will be fetched soon.",
"direct_messages_with": "Direct messages with %{username}", "direct_messages_with": "Direct messages with %{username}",
"Disable": "Uitschakelen", "Disable": "Uitschakelen",
"display_mentions": "Toon vermeldingen", "display_mentions": "Toon vermeldingen",
@ -1778,6 +1798,10 @@ if(preferredLanguage == "it"){
"Group Messages": "Group Messages", "Group Messages": "Group Messages",
"Group Messages — New Group Creation": "Group Messages — New Group Creation", "Group Messages — New Group Creation": "Group Messages — New Group Creation",
"Group Messages — Join Group": "Group Messages — Join Group", "Group Messages — Join Group": "Group Messages — Join Group",
"group_key_cant_import": "Can\'t import DM group key",
"group_key_is_invalid_perhaps": "perhaps the key is invalid",
"group_key_was_imported": "Key for DM group %{alias} was imported.\n"
+ "Its messages will be fetched soon.",
"direct_messages_with": "Messaggi Diretti come %{username}", "direct_messages_with": "Messaggi Diretti come %{username}",
"Disable": "Disabilitato", "Disable": "Disabilitato",
"display_mentions": "Mostra le menzioni", "display_mentions": "Mostra le menzioni",
@ -2117,6 +2141,10 @@ if(preferredLanguage == "fr"){
"Group Messages": "Group Messages", "Group Messages": "Group Messages",
"Group Messages — New Group Creation": "Group Messages — New Group Creation", "Group Messages — New Group Creation": "Group Messages — New Group Creation",
"Group Messages — Join Group": "Group Messages — Join Group", "Group Messages — Join Group": "Group Messages — Join Group",
"group_key_cant_import": "Can\'t import DM group key",
"group_key_is_invalid_perhaps": "perhaps the key is invalid",
"group_key_was_imported": "Key for DM group %{alias} was imported.\n"
+ "Its messages will be fetched soon.",
"direct_messages_with": "Messages privés avec %{username}", "direct_messages_with": "Messages privés avec %{username}",
"Disable": "Désactiver", "Disable": "Désactiver",
"display_mentions": "Afficher les mentions", "display_mentions": "Afficher les mentions",
@ -2459,6 +2487,10 @@ if(preferredLanguage == "ru"){
"Group Messages": "Групповые сообщения", "Group Messages": "Групповые сообщения",
"Group Messages — New Group Creation": "Групповые сообщения — Создать новую группу", "Group Messages — New Group Creation": "Групповые сообщения — Создать новую группу",
"Group Messages — Join Group": "Групповые сообщения — Присоединиться к группе", "Group Messages — Join Group": "Групповые сообщения — Присоединиться к группе",
"group_key_cant_import": "невозможно импортировать ключ ЛС группы",
"group_key_is_invalid_perhaps": "возможно, неправильный ключ",
"group_key_was_imported": "Ключ для ЛС группы %{alias} импортирован.\n"
+ "Её сообщения будут подгружены в скором времени.",
"direct_messages_with": "Личная переписка с %{username}", "direct_messages_with": "Личная переписка с %{username}",
"Disable": "Отключено", "Disable": "Отключено",
"display_mentions": "Показать упоминания", "display_mentions": "Показать упоминания",
@ -2804,6 +2836,10 @@ if(preferredLanguage == "de"){
"Group Messages": "Gruppennachrichten", "Group Messages": "Gruppennachrichten",
"Group Messages — New Group Creation": "Gruppennachrichten — Neue Gruppe erstellen", "Group Messages — New Group Creation": "Gruppennachrichten — Neue Gruppe erstellen",
"Group Messages — Join Group": "Gruppennachrichten — Gruppe beitreten", "Group Messages — Join Group": "Gruppennachrichten — Gruppe beitreten",
"group_key_cant_import": "Can\'t import DM group key",
"group_key_is_invalid_perhaps": "perhaps the key is invalid",
"group_key_was_imported": "Key for DM group %{alias} was imported.\n"
+ "Its messages will be fetched soon.",
"direct_messages_with": "Direktnachrichten mit %{username}", "direct_messages_with": "Direktnachrichten mit %{username}",
"Disable": "Deaktivieren", "Disable": "Deaktivieren",
"display_mentions": "Zeige Erwähnungen", // Ist das richtig? Ich weiß nicht, in welchem Zusammenhang das benutzt wird. "display_mentions": "Zeige Erwähnungen", // Ist das richtig? Ich weiß nicht, in welchem Zusammenhang das benutzt wird.
@ -3147,6 +3183,10 @@ if(preferredLanguage == "ja"){
"Group Messages": "Group Messages", "Group Messages": "Group Messages",
"Group Messages — New Group Creation": "Group Messages — New Group Creation", "Group Messages — New Group Creation": "Group Messages — New Group Creation",
"Group Messages — Join Group": "Group Messages — Join Group", "Group Messages — Join Group": "Group Messages — Join Group",
"group_key_cant_import": "Can\'t import DM group key",
"group_key_is_invalid_perhaps": "perhaps the key is invalid",
"group_key_was_imported": "Key for DM group %{alias} was imported.\n"
+ "Its messages will be fetched soon.",
"direct_messages_with": "Direct messages with %{username}", "direct_messages_with": "Direct messages with %{username}",
"Disable": "停止", "Disable": "停止",
"display_mentions": "メンションを表示する", "display_mentions": "メンションを表示する",
@ -3486,6 +3526,10 @@ if(preferredLanguage == "pt-BR"){
"Group Messages": "Group Messages", "Group Messages": "Group Messages",
"Group Messages — New Group Creation": "Group Messages — New Group Creation", "Group Messages — New Group Creation": "Group Messages — New Group Creation",
"Group Messages — Join Group": "Group Messages — Join Group", "Group Messages — Join Group": "Group Messages — Join Group",
"group_key_cant_import": "Can\'t import DM group key",
"group_key_is_invalid_perhaps": "perhaps the key is invalid",
"group_key_was_imported": "Key for DM group %{alias} was imported.\n"
+ "Its messages will be fetched soon.",
"direct_messages_with": "Mensagens Diretas com %{username}", "direct_messages_with": "Mensagens Diretas com %{username}",
"Disable": "Desabilitado", "Disable": "Desabilitado",
"display_mentions": "Exibir menções", "display_mentions": "Exibir menções",
@ -3829,6 +3873,10 @@ if(preferredLanguage == "tr"){
"Group Messages": "Grup Mesajları", "Group Messages": "Grup Mesajları",
"Group Messages — New Group Creation": "Grup Mesajları — Yeni Grup Oluştur", "Group Messages — New Group Creation": "Grup Mesajları — Yeni Grup Oluştur",
"Group Messages — Join Group": "Grup Mesajları — Gruba katıl", "Group Messages — Join Group": "Grup Mesajları — Gruba katıl",
"group_key_cant_import": "Can\'t import DM group key",
"group_key_is_invalid_perhaps": "perhaps the key is invalid",
"group_key_was_imported": "Key for DM group %{alias} was imported.\n"
+ "Its messages will be fetched soon.",
"direct_messages_with": "%{username} ile Direk Mesajlar", "direct_messages_with": "%{username} ile Direk Mesajlar",
"Disable": "Kullanılmaz", "Disable": "Kullanılmaz",
"display_mentions": "Bahsedenleri göster", "display_mentions": "Bahsedenleri göster",
@ -4169,6 +4217,10 @@ if(preferredLanguage == "cs"){
"Group Messages": "Group Messages", "Group Messages": "Group Messages",
"Group Messages — New Group Creation": "Group Messages — New Group Creation", "Group Messages — New Group Creation": "Group Messages — New Group Creation",
"Group Messages — Join Group": "Group Messages — Join Group", "Group Messages — Join Group": "Group Messages — Join Group",
"group_key_cant_import": "Can\'t import DM group key",
"group_key_is_invalid_perhaps": "perhaps the key is invalid",
"group_key_was_imported": "Key for DM group %{alias} was imported.\n"
+ "Its messages will be fetched soon.",
"direct_messages_with": "Direct messages with %{username}", "direct_messages_with": "Direct messages with %{username}",
"Disable": "Vypnuto", "Disable": "Vypnuto",
"display_mentions": "Zobrazit zmínky", "display_mentions": "Zobrazit zmínky",

72
js/twister_directmsg.js

@ -359,22 +359,13 @@ function openGroupMessagesJoinGroupModal() {
closeModal(event); closeModal(event);
}); });
modal.content.find('.secret-key-import, .username-import').on('input', importSecretKeypress); modal.content.find('.secret-key-import').on('input',
{parentSelector: '.module', enterSelector: '.import-secret-key'}, inputEnterActivator);
modal.content.find('.import-secret-key').on('click', function (event) { modal.content.find('.import-secret-key').on('click', function (event) {
var elemModule = $(event.target).closest('.module'); groupMsgImportKey($(event.target).closest('.module').find('.secret-key-import').val());
var groupAlias = elemModule.find('.username-import').val().toLowerCase();
var secretKey = elemModule.find('.secret-key-import').val();
twisterRpc('importprivkey', [secretKey, groupAlias], closeModal(event);
function(req, ret) {
groupMsgInviteToGroup(req.groupAlias, [defaultScreenName]);
closeModal(req.elem);
}, {groupAlias: groupAlias, elem: elemModule},
function(req, ret) {
alert(polyglot.t('Error in \'importprivkey\'', {rpc: ret.message}));
}
);
}); });
} }
@ -392,8 +383,54 @@ function groupMsgCreateGroup(description, peersToInvite) {
); );
} }
function groupMsgInviteToGroup(groupAlias, peersToInvite) { function groupMsgImportKey(key) {
_groupMsgInviteToGroupQueue.push({groupAlias: groupAlias, peersToInvite: peersToInvite}); if (parseInt(twisterVersion) < 93800) {
alertPopup({
//txtTitle: polyglot.t(''), add some title (not 'error', please) or just KISS
txtMessage: polyglot.t('group_key_cant_import')
+ ' —\ndaemon is obsolete, version 0.9.38 or higher is required'
});
return;
}
twisterRpc('creategroup', ['whatever', key],
function(req, ret) {
if (!ret) {
alertPopup({
//txtTitle: polyglot.t(''), add some title (not 'error', please) or just KISS
txtMessage: polyglot.t('group_key_cant_import') + ' —\n'
+ polyglot.t('group_key_is_invalid_perhaps')
});
return;
}
groupMsgInviteToGroup(ret, [defaultScreenName],
function () {
twisterRpc('rescandirectmsgs', [defaultScreenName],
function () {}, undefined, function () {});
}
);
alertPopup({
//txtTitle: polyglot.t(''), add some title (not 'error', please) or just KISS
txtMessage: polyglot.t('group_key_was_imported', {alias: ret})
});
}, undefined,
function(req, ret) {
alertPopup({
//txtTitle: polyglot.t(''), add some title (not 'error', please) or just KISS
txtMessage: polyglot.t('group_key_cant_import') + ' —\n' + ret.message
});
}
);
}
function groupMsgInviteToGroup(groupAlias, peersToInvite, cbFunc, cbReq) {
_groupMsgInviteToGroupQueue.push({
groupAlias: groupAlias,
peersToInvite: peersToInvite,
cbFunc: cbFunc,
cbReq: cbReq
});
if (_groupMsgInviteToGroupQueue.length === 1) if (_groupMsgInviteToGroupQueue.length === 1)
doGroupMsgInviteToGroup(); doGroupMsgInviteToGroup();
@ -408,7 +445,10 @@ function doGroupMsgInviteToGroup() {
_groupMsgInviteToGroupQueue.shift(); _groupMsgInviteToGroupQueue.shift();
if (_groupMsgInviteToGroupQueue.length) if (_groupMsgInviteToGroupQueue.length)
setTimeout(doGroupMsgInviteToGroup, 200); setTimeout(doGroupMsgInviteToGroup, 200);
}, null,
if (typeof req.cbFunc === 'function')
req.cbFunc(req.cbReq);
}, {cbFunc: _groupMsgInviteToGroupQueue[0].cbFunc, cbReq: _groupMsgInviteToGroupQueue[0].cbReq},
function(req, ret) { function(req, ret) {
alert(polyglot.t('error', alert(polyglot.t('error',
{error: 'can\'t invite ' + req[1] + ' to ' + req[0] + ' group — ' + ret.message})); {error: 'can\'t invite ' + req[1] + ' to ' + req[0] + ' group — ' + ret.message}));

2
theme_calm/css/style.css

@ -2204,7 +2204,7 @@ textarea.splited-post {
.group-messages-join-group.modal-wrapper { .group-messages-join-group.modal-wrapper {
height: auto; /*about 360px*/ height: auto; /*about 360px*/
margin-top: -240px; margin-top: -204px;
} }
.group-messages-join-group .modal-content .module { .group-messages-join-group .modal-content .module {

4
theme_nin/css/style.css

@ -2974,8 +2974,8 @@ ol.toptrends-list a:hover {
.group-messages-join-group.modal-wrapper { .group-messages-join-group.modal-wrapper {
width: 580px; width: 580px;
height: auto; /*about 360px*/ height: auto; /*about 409px*/
margin: -250px 0 0 -290px; margin: -204px 0 0 -290px;
} }
.group-messages-join-group .modal-content { .group-messages-join-group .modal-content {

Loading…
Cancel
Save