Skip to content

Commit

Permalink
Merge pull request #14 from eurofurence/feature/artistsalley
Browse files Browse the repository at this point in the history
Merging Artist Alley Feature branch to master
  • Loading branch information
Pinselohrkater authored May 14, 2019
2 parents 3967adf + 3513e09 commit b3421e8
Show file tree
Hide file tree
Showing 20 changed files with 576 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ public static string EscapeMarkdown(this string input)
{
return input
.Replace("_", @"\_")
.Replace("*", @"\*");
.Replace("*", @"\*")
.Replace("`", @"\`");
}

public static string RemoveMarkdown(this string input)
{
return input
.Replace("_", "")
.Replace("*", "");
.Replace("*", "")
.Replace("`", "");
}

public static string UppercaseFirst(this string input)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using Eurofurence.App.Domain.Model.ArtistsAlley;
using Eurofurence.App.Domain.Model.MongoDb.Repositories;
using MongoDB.Driver;

namespace Eurofurence.App.Domain.Model.MongoDb.ArtShow
{
public class TableRegistrationRepository :
MongoDbEntityRepositoryBase<TableRegistrationRecord>
{
public TableRegistrationRepository(IMongoCollection<TableRegistrationRecord> collection)
: base(collection)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Eurofurence.App.Common.Abstractions;
using Eurofurence.App.Domain.Model.Abstractions;
using Eurofurence.App.Domain.Model.Announcements;
using Eurofurence.App.Domain.Model.ArtistsAlley;
using Eurofurence.App.Domain.Model.ArtShow;
using Eurofurence.App.Domain.Model.Communication;
using Eurofurence.App.Domain.Model.Dealers;
Expand Down Expand Up @@ -146,6 +147,8 @@ protected override void Load(ContainerBuilder builder)
Register<ItemActivityRepository, IEntityRepository<ItemActivityRecord>, ItemActivityRecord>(builder,
collection => collection.Indexes.CreateOne(
Builders<ItemActivityRecord>.IndexKeys.Ascending(a => a.ImportHash)));

Register<TableRegistrationRepository, IEntityRepository<TableRegistrationRecord>, TableRegistrationRecord>(builder);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Eurofurence.App.Domain.Model.Fragments;
using System;
using System.Collections.Generic;

namespace Eurofurence.App.Domain.Model.ArtistsAlley
{
public class TableRegistrationRecord : EntityBase
{
public class StateChangeRecord
{
public DateTime ChangedDateTimeUtc{ get; set; }
public string ChangedByUid { get; set; }
public RegistrationStateEnum OldState { get; set; }
public RegistrationStateEnum NewState { get; set; }
}

public enum RegistrationStateEnum
{
Pending = 0,
Accepted = 1,
Published = 2,
Rejected = 3
}

public string OwnerUid { get; set; }

public string DisplayName { get; set; }

public string WebsiteUrl { get; set; }

public string ShortDescription { get; set; }

public ImageFragment Image { get; set; }

public RegistrationStateEnum State { get; set; }

public IList<StateChangeRecord> StateChangeLog { get; set; }

public TableRegistrationRecord()
{
this.StateChangeLog = new List<StateChangeRecord>();
}

public void ChangeState(RegistrationStateEnum newState, string uid)
{
StateChangeLog.Add(new StateChangeRecord()
{
ChangedByUid = uid,
ChangedDateTimeUtc = DateTime.UtcNow,
NewState = newState,
OldState = State
});

State = newState;
}
}
}
28 changes: 28 additions & 0 deletions src/Eurofurence.App.Domain.Model/Fragments/ImageFragment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;

namespace Eurofurence.App.Domain.Model.Fragments
{
[DataContract]
public class ImageFragment
{
[Required]
[DataMember]
public int Width { get; set; }

[Required]
[DataMember]
public int Height { get; set; }

[Required]
[DataMember]
public long SizeInBytes { get; set; }

[Required]
[DataMember]
public string MimeType { get; set; }

[Required]
public byte[] ImageBytes { get; set; }
}
}
16 changes: 14 additions & 2 deletions src/Eurofurence.App.Server.KestrelHost/appsettings.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"global": {
"conventionNumber": 23,
"conventionIdentifier": "EF25",
"regSysAuthenticationEnabled": 0
"regSysAuthenticationEnabled": 0
},
"logLevel": 1,
"auditLog": "/tmp/audit.log",
"auditLog": "/tmp/audit.log",
"mongoDb": {
"url": "mongodb://localhost:27017",
"database": "app_dev"
Expand Down Expand Up @@ -38,6 +38,18 @@
"logLevel": 1,
"logFile": "/tmp/collect.log"
},
"artistAlley": {
"telegram": {
"adminGroupChatId": "",
"announcementChannelId": ""
},
"twitter": {
"consumerKey": "",
"consumerSecret": "",
"accessToken": "",
"accessTokenSecret": ""
}
},
"jobs": {
"updateNews": {
"secondsInterval": 60,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace Eurofurence.App.Server.Services.Abstractions.ArtistsAlley
{
public class ArtistAlleyConfiguration
{
public string TelegramAdminGroupChatId { get; set; }
public string TelegramAnnouncementChannelId { get; set; }
public string TwitterConsumerKey { get; set; }
public string TwitterConsumerSecret { get; set; }
public string TwitterAccessToken { get; set; }
public string TwitterAccessTokenSecret { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Eurofurence.App.Domain.Model.ArtistsAlley;

namespace Eurofurence.App.Server.Services.Abstractions.ArtistsAlley
{
public interface ITableRegistrationService
{
Task RegisterTableAsync(string uid, TableRegistrationRequest request);
Task<IEnumerable<TableRegistrationRecord>> GetRegistrations(TableRegistrationRecord.RegistrationStateEnum? state);

Task ApproveByIdAsync(Guid id, string operatorUid);
Task RejectByIdAsync(Guid id, string operatorUid);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace Eurofurence.App.Server.Services.Abstractions.ArtistsAlley
{
public class TableRegistrationRequest
{
public string DisplayName { get; set; }

public string WebsiteUrl { get; set; }

public string ShortDescription { get; set; }

public string ImageContent { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Threading.Tasks;
using Eurofurence.App.Domain.Model.Fragments;
using Eurofurence.App.Domain.Model.Images;

namespace Eurofurence.App.Server.Services.Abstractions.Images
Expand All @@ -10,5 +11,7 @@ public interface IImageService : IEntityServiceOperations<ImageRecord>
Task<Guid> InsertOrUpdateImageAsync(string internalReference, byte[] imageBytes);
Task<byte[]> GetImageContentByIdAsync(Guid id);
byte[] GeneratePlaceholderImage();
ImageFragment GenerateFragmentFromBytes(byte[] imageBytes);
ImageFragment EnforceMaximumDimensions(ImageFragment image, int width, int height);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ namespace Eurofurence.App.Server.Services.Abstractions.Telegram
public interface ITelegramMessageSender
{
Task SendMarkdownMessageToChatAsync(string chatId, string message);
Task SendImageToChatAsync(string chatId, byte[] imageBytes, string message = "");
}

public interface ITelegramMessageBroker : ITelegramMessageSender
{
event Func<string, string, Task> OnSendMarkdownMessageToChatAsync;
event Func<string, byte[], string, Task> OnSendImageToChatAsync;
}
}
Loading

0 comments on commit b3421e8

Please sign in to comment.