diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index 24e7645..4919310 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts @@ -55,9 +55,9 @@ export class AppComponent implements OnInit { if (p) { this._messagingService.getPermission(); this._messagingService.receiveMessage(); - const chatterChannel = `${p.uid}_chatter`; + const chatterChannel = `${p.id}`; this._signalrService - .init('chatter') + .init('userupdates') .then((r) => { this._signalrService.connection.on( chatterChannel, @@ -69,7 +69,7 @@ export class AppComponent implements OnInit { .catch((err) => { console.error( 'app.component', - 'Unable to initialise chatter hub', + 'Unable to initialise site update hub', err ); }); diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index 7c1fe54..ea35cb6 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -29,7 +29,6 @@ import { ModalModule } from 'ngx-bootstrap/modal'; import { AuthGuard } from './services/auth.guard'; import { ImageService } from './services/image.service'; import { DebugService } from './services/debug.service'; -import { ChatterService } from './services/chatter.service'; import { DebugComponent } from './components/debug/debug.component'; import { InlineEditorModule } from '@qontu/ngx-inline-editor'; import { SidebarComponent } from './components/sidebar/sidebar.component'; @@ -208,7 +207,6 @@ export function provideConfig() { PushRegistrationService, DebugService, MessagingService, - ChatterService, AppInsightsService, JobsService, AudioService, diff --git a/client/src/app/components/debug/debug.component.ts b/client/src/app/components/debug/debug.component.ts index c9b92c5..47c01b0 100644 --- a/client/src/app/components/debug/debug.component.ts +++ b/client/src/app/components/debug/debug.component.ts @@ -4,7 +4,6 @@ import { Component, OnInit } from '@angular/core'; import { DebugService } from 'app/services/debug.service'; import { environment } from 'environments/environment'; import { JobsService } from 'app/services/jobs.service'; -import { ChatterService } from 'app/services/chatter.service'; import { MessagingService } from 'app/services/messaging.service'; import { BehaviorSubject } from 'rxjs/BehaviorSubject'; @@ -23,7 +22,6 @@ export class DebugComponent implements OnInit { constructor( private _debugService: DebugService, - private _chatterService: ChatterService, private _jobsService: JobsService, private _pushNotifications: MessagingService, private _signalrService: SignalRService diff --git a/client/src/app/models/profile.model.ts b/client/src/app/models/profile.model.ts index ed965bb..884f94e 100644 --- a/client/src/app/models/profile.model.ts +++ b/client/src/app/models/profile.model.ts @@ -4,7 +4,6 @@ export class ProfileModel { email: string; name: string; description?: string; - uid?: string; profileImage?: string; apiKey: string; firstName: string; diff --git a/client/src/app/services/chatter.service.ts b/client/src/app/services/chatter.service.ts deleted file mode 100644 index 429c8e9..0000000 --- a/client/src/app/services/chatter.service.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { Injectable } from '@angular/core'; -import { environment } from 'environments/environment'; -import { HttpClient } from '@angular/common/http'; - -@Injectable() -export class ChatterService { - constructor(private _http: HttpClient) {} - - ping(message: string): any { - return this._http.post( - environment.API_HOST + '/chatter/ping', - JSON.stringify({ message: message }) - ); - } -} diff --git a/server/Controllers/ChatterController.cs b/server/Controllers/ChatterController.cs deleted file mode 100644 index 99ea63c..0000000 --- a/server/Controllers/ChatterController.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System.Linq; -using System.Security.Claims; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Identity; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.SignalR; -using PodNoms.Api.Persistence; -using PodNoms.Api.Services.Auth; -using PodNoms.Api.Services.Hubs; - -namespace PodNoms.Api.Controllers { - [Authorize] - [Route("[controller]")] - public class ChatterController : BaseAuthController { - private readonly HubLifetimeManager _chatterHub; - public ChatterController(HubLifetimeManager chatterHub, UserManager userManager, IHttpContextAccessor contextAccessor) - : base(contextAccessor, userManager) { - this._chatterHub = chatterHub; - } - [HttpPost("ping")] - public async Task> Ping([FromBody] string message) { - await _chatterHub.SendAllAsync( - $"{_applicationUser.Id}_chatter", - new object[] { message }); - return Ok(message); - } - } -} \ No newline at end of file diff --git a/server/Models/ViewModels/ProfileViewModel.cs b/server/Models/ViewModels/ProfileViewModel.cs index a0f8672..351530b 100644 --- a/server/Models/ViewModels/ProfileViewModel.cs +++ b/server/Models/ViewModels/ProfileViewModel.cs @@ -8,7 +8,6 @@ public string LastName { get; set; } public string Description { get; set; } public string ProfileImage { get; set; } - public string Uid { get; set; } public string ApiKey { get; set; } } } \ No newline at end of file diff --git a/server/Services/Hubs/ChatterHub.cs b/server/Services/Hubs/UserUpdatesHub.cs similarity index 54% rename from server/Services/Hubs/ChatterHub.cs rename to server/Services/Hubs/UserUpdatesHub.cs index 9b7509d..3f365c4 100644 --- a/server/Services/Hubs/ChatterHub.cs +++ b/server/Services/Hubs/UserUpdatesHub.cs @@ -1,14 +1,14 @@ -using System; +using System; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.SignalR; namespace PodNoms.Api.Services.Hubs { [Authorize] - public class ChatterHub : Hub { - public async Task SendMessage(string user, string message) { + public class UserUpdatesHub : Hub { + public async Task SendMessage(string userId, string message) { string timestamp = DateTime.Now.ToShortTimeString(); - await Clients.All.SendAsync($"{user}_chatter", timestamp, user, message); + await Clients.All.SendAsync(userId, timestamp, userId, message); } } } \ No newline at end of file diff --git a/server/Services/Processor/UrlProcessService.cs b/server/Services/Processor/UrlProcessService.cs index 4db1ce7..cbfc48c 100644 --- a/server/Services/Processor/UrlProcessService.cs +++ b/server/Services/Processor/UrlProcessService.cs @@ -24,16 +24,16 @@ namespace PodNoms.Api.Services.Processor { private readonly IEntryRepository _repository; public ApplicationsSettings _applicationsSettings { get; } - private readonly HubLifetimeManager _chatterHub; + private readonly HubLifetimeManager _userUpdateHub; public UrlProcessService(IEntryRepository repository, IUnitOfWork unitOfWork, IFileUploader fileUploader, IOptions applicationsSettings, - HubLifetimeManager chatterHub, + HubLifetimeManager userUpdateHub, ILoggerFactory logger, IMapper mapper, IRealTimeUpdater pusher) : base(logger, mapper, pusher) { this._applicationsSettings = applicationsSettings.Value; this._repository = repository; this._unitOfWork = unitOfWork; - this._chatterHub = chatterHub; + this._userUpdateHub = userUpdateHub; } private async Task __downloader_progress(string userId, string uid, ProcessProgressEvent e) { @@ -97,8 +97,8 @@ namespace PodNoms.Api.Services.Processor { await _sendProcessCompleteMessage(entry); await _unitOfWork.CompleteAsync(); - await _chatterHub.SendAllAsync( - $"{entry.Podcast.AppUser.Id}_chatter", + await _userUpdateHub.SendAllAsync( + entry.Podcast.AppUser.Id, new object[] { $"{entry.Title} has succesfully been processed" }); } @@ -108,8 +108,8 @@ namespace PodNoms.Api.Services.Processor { entry.ProcessingPayload = ex.Message; await _unitOfWork.CompleteAsync(); await _sendProcessCompleteMessage(entry); - await _chatterHub.SendAllAsync( - $"{entry.Podcast.AppUser.Id}_chatter", + await _userUpdateHub.SendAllAsync( + entry.Podcast.AppUser.Id, new object[] { $"Error processing {entry.Title}" }); } return false; diff --git a/server/Startup.cs b/server/Startup.cs index e8a1687..5e326bb 100644 --- a/server/Startup.cs +++ b/server/Startup.cs @@ -275,7 +275,7 @@ namespace PodNoms.Api { app.UseSignalR(routes => { routes.MapHub("/hubs/audioprocessing"); - routes.MapHub("/hubs/chatter"); + routes.MapHub("/hubs/userupdates"); routes.MapHub("/hubs/debug"); });