Put Easybridge avatar in Docker container

This commit is contained in:
Alex 2020-02-28 20:07:47 +01:00
parent 80a8759eb4
commit 2444302510
4 changed files with 11 additions and 4 deletions

View file

@ -3,6 +3,7 @@ FROM archlinux:latest
RUN mkdir /app RUN mkdir /app
WORKDIR /app WORKDIR /app
ADD static /app/static ADD static /app/static
ADD easybridge.jpg /app/easybridge.jpg
ADD easybridge /app/easybridge ADD easybridge /app/easybridge
ADD templates /app/templates ADD templates /app/templates

View file

@ -25,6 +25,7 @@ type ConfigFile struct {
DbPath string `json:"db_path"` DbPath string `json:"db_path"`
MatrixDomain string `json:"matrix_domain"` MatrixDomain string `json:"matrix_domain"`
SessionKey string `json:"web_session_key"` SessionKey string `json:"web_session_key"`
AvatarFile string `json:"easybridge_avatar"`
} }
var configFlag = flag.String("config", "./config.json", "Configuration file path") var configFlag = flag.String("config", "./config.json", "Configuration file path")
@ -44,6 +45,7 @@ func readConfig() ConfigFile {
Server: "http://localhost:8008", Server: "http://localhost:8008",
DbType: "sqlite3", DbType: "sqlite3",
DbPath: "easybridge.db", DbPath: "easybridge.db",
AvatarFile: "./easybridge.jpg",
SessionKey: hex.EncodeToString(defaultKey), SessionKey: hex.EncodeToString(defaultKey),
} }
@ -166,7 +168,11 @@ func main() {
// Start appservice and web management interface // Start appservice and web management interface
errch := make(chan error) errch := make(chan error)
StartAppService(errch) err = StartAppService(errch)
if err != nil {
log.Fatal(err)
}
StartWeb(errch) StartWeb(errch)
// Wait for an error somewhere // Wait for an error somewhere

View file

@ -30,7 +30,7 @@ func StartAppService(errch chan error) error {
if err == nil { if err == nil {
// If Easybridge account was created, update avatar and display name // If Easybridge account was created, update avatar and display name
err = mx.ProfileAvatar(ezbrMxId(), &connector.FileMediaObject{ err = mx.ProfileAvatar(ezbrMxId(), &connector.FileMediaObject{
Path: "easybridge.jpg", Path: config.AvatarFile,
}) })
if err != nil { if err != nil {
return err return err

View file

@ -58,11 +58,11 @@ func ezbrSystemSendf(user_mx_id string, format string, args ...interface{}) {
// ---- // ----
func roomAlias(protocol string, id RoomID) string { func roomAlias(protocol string, id RoomID) string {
return fmt.Sprintf("_ezbr__%s__%s", safeStringForId(string(id)), protocol) return fmt.Sprintf("%s_%s__%s", registration.SenderLocalpart, safeStringForId(string(id)), protocol)
} }
func userMxId(protocol string, id UserID) string { func userMxId(protocol string, id UserID) string {
return fmt.Sprintf("_ezbr__%s__%s", safeStringForId(string(id)), protocol) return fmt.Sprintf("%s_%s__%s", registration.SenderLocalpart, safeStringForId(string(id)), protocol)
} }
func safeStringForId(in string) string { func safeStringForId(in string) string {