-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #242 from 67P/feature/241-direct_messages
(Re)add direct messages for IRC and XMPP
- Loading branch information
Showing
21 changed files
with
206 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<LinkTo @route="user-channel" | ||
@model={{this.usernameWithoutPrefix}} | ||
@model={{this.userChannelId}} | ||
class="hc-sidebar-item {{this.role}}"> | ||
{{@username}} | ||
</LinkTo> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import Controller, { inject as controller } from '@ember/controller'; | ||
|
||
export default class ChannelIndexController extends Controller { | ||
|
||
@controller('channel') channel; | ||
|
||
get allowUserChannels () { | ||
// FIXME allow when fixed for IRC | ||
// TODO implement channel DMs for XMPP | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import Service, { inject as service } from '@ember/service'; | ||
import { isEmpty } from '@ember/utils'; | ||
import extend from 'extend'; | ||
import UserChannel from 'hyperchannel/models/user_channel'; | ||
import channelMessageFromSockethubObject from 'hyperchannel/utils/channel-message-from-sockethub-object'; | ||
|
||
/** | ||
|
@@ -186,7 +187,7 @@ export default class SockethubXmppService extends Service { | |
addMessageToChannel (message) { | ||
if (isEmpty(message.object.content)) return; | ||
|
||
const channel = this.getChannelForMessage(message); | ||
const channel = this.findOrCreateChannelForMessage(message); | ||
const channelMessage = channelMessageFromSockethubObject(message); | ||
|
||
// TODO should check for message and update sent status if exists | ||
|
@@ -221,29 +222,49 @@ export default class SockethubXmppService extends Service { | |
* @returns {Channel} channel | ||
* @public | ||
*/ | ||
getChannelForMessage (message) { | ||
findOrCreateChannelForMessage (message) { | ||
const targetChannelId = message.target['@id']; | ||
let channel; | ||
|
||
if (message.target['@type'] === 'room') { | ||
channel = this.coms.channels.findBy('sockethubChannelId', targetChannelId); | ||
|
||
// TODO Find account for new channel by sockerhubPersonId | ||
console.warn('Received message for unknown channel', message); | ||
// if (!channel) { | ||
// channel = this.coms.createChannel(space, targetChannelId); | ||
// } | ||
if (!channel) { | ||
console.warn('Received message for unknown channel', message); | ||
// channel = this.coms.createChannel(space, targetChannelId); | ||
} | ||
} else { | ||
channel = this.coms.channels.findBy('sockethubChannelId', message.actor['@id']); | ||
// TODO | ||
console.warn('Received message for unknown user channel', message); | ||
// if (!channel) { | ||
// channel = this.coms.createUserChannel(space, message.actor['@id']); | ||
// } | ||
|
||
if (!channel) { | ||
const account = this.coms.accounts.findBy('sockethubPersonId', message.target['@id']); | ||
if (!account) console.warn('Received direct message for unknown account', message); | ||
channel = this.coms.createUserChannel(account, message.actor['@id']); | ||
} | ||
} | ||
|
||
return channel; | ||
} | ||
|
||
/** | ||
* Create a direct-message channel | ||
* | ||
* @param {Account} account | ||
* @param {String} sockethub actor ID | ||
* @returns {UserChannel} user channel | ||
* @public | ||
*/ | ||
createUserChannel (account, sockethubActorId) { | ||
const channel = new UserChannel({ | ||
account: account, | ||
name: sockethubActorId, // e.g. [email protected]/jimmy | ||
displayName: sockethubActorId.match(/\/(.+)$/)[1], | ||
connected: true | ||
}); | ||
return channel; | ||
} | ||
|
||
/** | ||
* Utility function for easier logging | ||
* @private | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
<UserList @users={{this.model.sortedUserList}} | ||
@allowUserChannels={{this.allowUserChannels}} /> | ||
<UserList @users={{this.model.sortedUserList}} @channel={{this.model}} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-corner-down-right"><polyline points="15 10 20 15 15 20"></polyline><path d="M4 4v7a4 4 0 0 0 4 4h12"></path></svg> | ||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-corner-down-right {{@class}}"><polyline points="15 10 20 15 15 20"></polyline><path d="M4 4v7a4 4 0 0 0 4 4h12"></path></svg> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
...ntegration/components/channel-nav-test.js → .../components/channel-nav/component-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
// import { module, test } from 'qunit'; | ||
// import { setupRenderingTest } from 'ember-qunit'; | ||
// import { render } from '@ember/test-helpers'; | ||
// import hbs from 'htmlbars-inline-precompile'; | ||
// import { hbs } from 'ember-cli-htmlbars'; | ||
// | ||
// module('Integration | Component | channel-nav', function(hooks) { | ||
// setupRenderingTest(hooks); | ||
// | ||
// test('it renders', async function(assert) { | ||
// assert.expect(1); | ||
// // Set any properties with this.set('myProperty', 'value'); | ||
// // Handle any actions with this.set('myAction', function(val) { ... }); | ||
// | ||
// await render(hbs`{{channel-nav}}`); | ||
// await render(hbs`<ChannelNav />`); | ||
// | ||
// assert.dom(this.element).hasText(''); | ||
// assert.equal(this.element.textContent.trim(), ''); | ||
// }); | ||
// }); | ||
// |
Oops, something went wrong.